EmbeddedRelated.com
Forums

HC912D60A flashing

Started by Madis May 6, 2005
Hello!

Im new to freescale processors and run into the problems while trying
to flash software into it. So maybe you could help me.

I designed one PWB with 912D60A on board. In order to flash it, I
added BDM connector to it (+5V, GND, BDM, Reset), as was recommended
by freescale. After receining that manufactured PWB, I started to find
a algorithm to program it.

So I found out that I need a device called POD. After searching the
web I found one quite simple pod called podex
(http://duch.cz/podex/index.en.html). I made that pod, flashed the HEX
to the avr and started to look for a program for a PC to communicate
to it. That was not that easy anymore. I only need to flash the
device, but I guess almost all the SW avilable is for debugging via
the BDM interface? Or could you recommend me a software which is
compatible with that pod?

After I searched the web for a while, I foud another POD designed by
Malte Avenhaus. It seemed to have program for flasing included. So I
built this one. But I found out that pc program (for flashing) was not
communicating to com port at all.

After that I started to investigate that POD firmware. Few questions
about BDM.
1: in case I have blank uP (just got it from the stock) does it have
(912D60A) any bootloader installed? I guess no.
2: So I have to communicate to it via BDM. But how can I write some
data to that device? I tried to turn port E to output and turn it to
high, but failed.
"my" pod seemed to do the following:
output to BDM pin
C4 (write byte command) FF 01 (BDM status) 10 00 10 00 90
Should it really write that 10 00 twice? That register has 8 bits and
command should have 16 bits of data, that why? But basically
everything sould be ok after that sequence?
After that I tried to turnd portE to high state so POD outputted:
C0 00 09 (DDRE) FF
And after that:
C0 00 08 FF
But port E was not high.

My question is, is there any sense in what I was trying to do? First I
wanted to verify if the BDM interface is fuctional. After I manage to
get that "port E" sample to work, I could modify the pod firmware to
accept S19 format, for example.

Thank you for your advice.

Madis


Hello

I use the Freescale BDM programmer.

It works great everytime and supports all the HC12 and S parts
automatically.

Search for bdm programmer on the Freescale website.

Bob

Message text written by INTERNET:68HC12@68HC...
>
Hello!

Im new to freescale processors and run into the problems while trying
to flash software into it. So maybe you could help me.

I designed one PWB with 912D60A on board. In order to flash it, I
added BDM connector to it (+5V, GND, BDM, Reset), as was recommended
by freescale. After receining that manufactured PWB, I started to find
a algorithm to program it.


Hi!

The reason why Im trying to build up the programmer myself during the
weekend is that deadline of my project is approaching and lead time
for that programmer is about 2 weeks...

So if anybody could pass me a hint what went wrong with my programming
attempt...

Thank you.
Madis >
> I use the Freescale BDM programmer.
>
> It works great everytime and supports all the HC12 and S parts
> automatically.
>
> Search for bdm programmer on the Freescale website.
>
> Bob >
>
> Message text written by INTERNET:68HC12@68HC...
> >
> Hello!
>
> Im new to freescale processors and run into the problems while
trying
> to flash software into it. So maybe you could help me.
>
> I designed one PWB with 912D60A on board. In order to flash it, I
> added BDM connector to it (+5V, GND, BDM, Reset), as was recommended
> by freescale. After receining that manufactured PWB, I started to
find
> a algorithm to program it.


Hi

----- Original Message -----
From: "Madis" <planeetmaa@plan...>
To: <68HC12@68HC...>
Sent: Friday, May 06, 2005 8:45 PM
Subject: [68HC12] HC912D60A flashing > Hello!
>
> Im new to freescale processors and run into the problems while trying
> to flash software into it. So maybe you could help me.
>
> I designed one PWB with 912D60A on board. In order to flash it, I

PWB=PCB?

> added BDM connector to it (+5V, GND, BDM, Reset), as was recommended
> by freescale. After receining that manufactured PWB, I started to find
> a algorithm to program it.
>
> So I found out that I need a device called POD. After searching the
> web I found one quite simple pod called podex
> (http://duch.cz/podex/index.en.html). I made that pod, flashed the HEX
> to the avr and started to look for a program for a PC to communicate
> to it. That was not that easy anymore. I only need to flash the
> device, but I guess almost all the SW avilable is for debugging via
> the BDM interface? Or could you recommend me a software which is
> compatible with that pod?
>
> After I searched the web for a while, I foud another POD designed by
> Malte Avenhaus. It seemed to have program for flasing included. So I
> built this one. But I found out that pc program (for flashing) was not
> communicating to com port at all.
>
> After that I started to investigate that POD firmware. Few questions
> about BDM.
> 1: in case I have blank uP (just got it from the stock) does it have
> (912D60A) any bootloader installed? I guess no.


Right, 912D60A come blank from factory. Except that every D60A part I saw
had SHADOW word programmed to $230 (16MHz crystal). > 2: So I have to communicate to it via BDM. But how can I write some
> data to that device? I tried to turn port E to output and turn it to
> high, but failed.
> "my" pod seemed to do the following:
> output to BDM pin
> C4 (write byte command) FF 01 (BDM status) 10 00 10 00 90
> Should it really write that 10 00 twice? That register has 8 bits and

No, 10 00 shouldn't be outputed twice. But only reason for C4 FF01 command
is to enable BDM firmware commands, actually write C4 FF01 xx 80. 10 00
seams to clear BDM status register.
Command 90 is used to stop running HC12 program and enter BDM mode. > command should have 16 bits of data, that why? But basically
> everything sould be ok after that sequence?
> After that I tried to turnd portE to high state so POD outputted:
> C0 00 09 (DDRE) FF

Every data byte (or word) write (or read) command should output (read) two
bytes. As I see above pod ouputs single FF, not two. When writing/reading a
byte to odd address first byte is ignored. Writing/reading to even address
second byte is ignored. To access DDRE POD should send C0 00 09 xx FF

> And after that:
> C0 00 08 FF


Should be C0 00 08 FF xx. Don't forget about timing too. > But port E was not high.
>
> My question is, is there any sense in what I was trying to do? First I
> wanted to verify if the BDM interface is fuctional. After I manage to
> get that "port E" sample to work, I could modify the pod firmware to
> accept S19 format, for example.
>

To check if POD is working try to read some locations with known value.
Reads above 0xFFF should return FF. Read from registers should return their
default values. Of course you should reset D60A into special single chip
mode first (pull BKGD low, reset part, release BKGD). Try to write something
non zero and non FF to RAM, verify if you can read it back from RAM.

Writing to flash is more tricky. You should load flash programming routines
into D60A RAM and execute these programming routines. Writing these routines
from scratch without some debugging tools is very hard. It looks like you
even don't have some HC12 board with bootloader in flash.

My D60A/DG128A flash write and block erase routines for BDM pod are below.
Imagecraft assembler. Code relocateable.

Short intstructions:

Load code to ram.

1. To bulk erase 28k block load X register with word aligned address below
0x8000, to erase 32k block load X with >=0x8000.
2. Load PC with 0x242, GO (08). Wait while BDM mode is inactive (Check
BDMACT bit of STATUS register). Routines have BGND instructions at the end.
After execution D60A will enter BDM mode and BDMACT (bit6 of BDM status
register) will get set.

To program flash:
1. Write 64bytes of data (single flash sector) to 0x200-0x23F
2. Load X with destination address. Has to be 64byte flash sector aligned.
3. Load PC with 0x240
4. GO (08) and wait while BDM mode is inactive.

Edward

REGBASE=0

A=1
B=2
D60=4
DG128=8
CPU

.INCLUDE "REGHC12.INC" PGM = 1
ERAS = 2
HVEN = 8
FEESWAI = 0x10

.area fe(abs)
.org 0x200
copy: .blkb 0x40

; x points to FB & 0xFFC0
cf: BRA CLOSEFB
BRA FBULK
CLOSEFB:
LEAY copy-pcl1, pc
pcl1:
LDAA #0x40
lck: LDAB 0,y ; in ram
ANDB 0,x ; in flash
; prevent programming bits to 0 more than 1 time
EORB 1,x+
COMB
STAB 1,y+
DBNE a,lck
LEAX -0x40,x
LEAY -0x40,y
LDAA #0x40/2

BRSET *INITRM,#0x20,dg
CPX #0
BMI dg
BRA CLOSEFB0

dg: BSET *FEE32CTL,#PGM
STD 0,x
LDAB #(10*8)/3
DBNE b,.
BSET *FEE32CTL,#HVEN
LDAB #14 ; dly5us
DBNE b,.
w: MOVW 2,y+, 2,x+
LDAB #100 ;dly 30-40us
DBNE b,.
DBNE a,w
BCLR *FEE32CTL,#PGM
LDAB #14 ; dly5us
DBNE b,.
BCLR *FEE32CTL,#HVEN
ORAA #0x80
BGND
;x points to block to erase (aligned)
FBULK:
BRSET *INITRM,#0x20,dg1
CPX #0
BMI dg1
BRA FBULK0

dg1: BSET *FEE32CTL,#ERAS
STD 0,x
LDY #(10*8)/3
DBNE y,.
BSET *FEE32CTL,#HVEN
LDY #(8000*8)/3
DBNE y,.
BCLR *FEE32CTL,#ERAS
LDY #(100*8)/3
DBNE y,.
BCLR *FEE32CTL,#HVEN
BGND

CLOSEFB0:
BSET *FEE28CTL,#PGM
STD 0,x
LDAB #(10*8)/3
DBNE b,.
BSET *FEE28CTL,#HVEN
LDAB #14 ; dly5us
DBNE b,.
w1: MOVW 2,y+, 2,x+
LDAB #100 ;dly 30-40us
DBNE b,.
DBNE a,w1
BCLR *FEE28CTL,#PGM
LDAB #14 ; dly5us
DBNE b,.
BCLR *FEE28CTL,#HVEN
ORAA #0x80
BGND

;x points to block to be erased (X has to be word aligned)
FBULK0:
BSET *FEE28CTL,#ERAS
STD 0,x
LDY #(10*8)/3
DBNE y,.
BSET *FEE28CTL,#HVEN
LDY #(8000*8)/3
DBNE y,.
BCLR *FEE28CTL,#ERAS
LDY #(100*8)/3
DBNE y,.
BCLR *FEE28CTL,#HVEN
BGND

> Thank you for your advice.
>
> Madis > Yahoo! Groups Links




Hi!

first of all, I have to thank you, Edward, my BDM programmer is up and
running.

But I got another issue.

I was looking for the bootloader for D60A and found one from the
freescale homepage (in the same zip with dbug12 stuff). So I
programmed it to the flash and everything is fine. Now its possible to
program my PWB (=PCB) via com port (we need that feature in our
applications to allow easy way for service personnel to perform
firmware upgrades).

But the problem is that I don't know where do I have to load reset and
interrupt vectors in the user program... So maybe somebody can give me
a hint?

Or If somebody can recommend me another nice bootloader, I appreciate.
I guess there is nothing wrong with freescale-s loader, but its always
good to have options.

Thank you, Madis