There are several problems:
First, you misunderstand the mask definitions for port and data direction registers in mc9s12xdp512.inc. They indicate the bit number in the byte, useful in some cases to assist the programmer in creating self-documenting code. Your code is:
BSET DDRAB_DDRA7, #%00000001
BSET PORTA_PA7, #%00000001
To use bit masks, it should be more like this (note the "m" prefix):
BSET DDRAB, #mDDRAB_DDRA7
BSET PORTAB, #mPORTAB_PA7
But the definitions for PORTAB and DDRAB are meant to be used with Word instructions, allowing you to set parameters of both PortA and PortB simultaneously. For byte operations (such as the BSET instruction), you should use the byte-oriented PORTA and DDRA designations instead. However, my advice to you is to take advantage of the existing user LED on PortP (PP7). That will eliminate any chance of mis-counting pin numbers on the header or wiring errors on your part when hooking up your LED. Also, bit masks and BSET instructions are tricky for beginners. There's no harm in defining the entire port as outputs and setting all the bits high. In that case, the correct code would be:
MOVB #$FF, DDRP
MOVB, #$FF, PORTP
(By the way, there's a similar problem using bit masks with the two MOVB instructions that follow in your code. I suggest you just use the CLR instruction: CLR DDRJ, followed by CLR PORTJ).
Secondly, you are not using a BDM pod, therefore you must rely on the Serial Monitor to load your program into Flash. The Serial Monitor resides in the top 2K of flash, in a protected block. This block is also where the vectors reside (e.g. Reset Vector). The Serial Monitor implements a User Vector Table, just below the protected Flash block, to deal with this issue. Therefore you must change the ORG directive at the end of your program to $F7FE. The way it is now, your resulting s-record file references an address in the protected Flash block, so you get the "can't write Flash/EEPROM" error in uBug12X.
The complete CW project for the demo program for this board (in assembler) can be found at
http://support.technologicalarts.ca/docs/Adapt9S12X/Code/S12XCWDemo.rarIt's a good place to start (i.e. modifying a "known-good" working program).
An App Note for using CW with this board can be found at:
http://support.technologicalarts.ca/docs/Adapt9S12X/Using%20CodeWarrior%20Assembler%20with%20Adapt9S...I suggest you use uBug12X to load the demo, to get some experience with uBug12x. The modified version of the demo s19 file, with UserVectors to work with the Serial Monitor, can be found at:
http://support.technologicalarts.ca/docs/Adapt9S12X/Code/s12xSM-demo.s19Ignore the "out of bounds error" and you'll find that it has loaded and runs when you switch to Run and press Reset. Use a terminal program set to 115Kbaud, and press <ENTER> to interact with the demo menu.
Best regards,
Carl Barnes
www.technologicalarts.comA complete selection of HC11/HC12/HCS12(X) modules!
--
Alban Edit: modified links to be clickableMessage Edited by Alban on
2007-10-15 08:15 AM