Hello everybody,
Please bear my lack of knowledge. I am HW engineer, and I am not very familiar with microcontroller programming. I have several questions (or maybe just clarifications) regarding a project I am working on.
Well, the facts: I am now developing the schematic in which I will use MC9S12C64. The problem is burning the firmware, but I also want to understand how the boot sectors work. The micro comes blank, I have the s19 file with the firmare and a pc executable which writes the firmware through serial connection. From what I have read, I understood that there are two ways of writing the SW:
1. Use a BDM and write directly the s19 file. How is this done? Can I just load the file in CodeWarrior and hit a burn button?
2. The harder way, which I have seen others used more: use a BDM and burn a serial monitor, then burn the firmware through the serial connection using the provided firmware uploader. This is the way I would prefer, but here I have more questions. I do not know how a bootloader works. After burning the serial monitor with a BDM ( I will build a TBDML, it's easy), for writing the firmware I must close the bootstrap jumper. (Does this tell the micro to load the memory address of the serial monitor?). Then start the firmware loader sw and that's all. Seems simple and efficient as I don't want to open the case for every re-flashing. Did I understand this procedure correct?
I have read that the serial monitor and the firmware must not share the serial connection, but in this application, the firmware will use the serial connection all the time for communication. Does the SM have a special area in the memory, and when the bootstrap jumper is out, it is not loaded at startup?
Next on the list: I have found the application note for the serial monitor, AN2548, with the attached CW projects. I have no knowledge on how to use that source code. Do I just open it in CW, compile it or something and it results an S19 file I can burn with the BDM? Why isn't provided the compiled file directly? Is there anything specific I must program there, as form the AN I saw it is the same code for all HCS12 family of microcontrollers.
Now, the last question, partly related to the previous one: I also have another CW project archive. How can I burn the sw to the micro? Open in CW, compile and use the BDM to write it?
Please excuse the low technical level of the problems, these might be common-sense for developers, but for me everything is new and complicated (remember I am HW engineer with minimal programming or microcontroller knowledge). I might try later on to start understanding more on the microcontroller programming, but now I am just trying to make a product work, having everything at hand.
Yes, there are more ways how to program S12 MCU.
Simplest way is write your project, connect MCU by BDM interface to PC and click on green Debug (F5) button. Debugger (hiwave.exe) will erase MCU and program it by your software.
BDM Interface (like TBDML) is able reset MCU into special mode (MODC pin is low during reset) and load program trough BKGD/MODC pin.
Serial monitor is code which occupied part of MCU flash and work as replacement for BDM interface (works as loader and debugger).
So, you have to load SM into MCU by BDM interface and some loader/debugger software (for example hivawe.exe in CW\Prog directory).
After that you connect MCU with PC by serial cable and create new project (select new connection) with Serial Monitor as default connection. This will create new *.prm linker file where are available only part of flash which is not occupied by SM.
After that you can use directly Debug (F5) button as in case of BDM interface however program load and debugging commands will be transferred via serial port. All other work works almost like in case of with BDM interface.
How configure SM for your MCU/Board:
Please edit S12SerMon2r1.def file
And comment out rest of NVM definitions = add semicolons at line begin
After that you should make (F7) HCS12SerialMon2r1 project and result s19 file load into your MCU by BDM interface.
Complied files are not provided because there are so many options (MCU derivative, Run Load Switch, external clock, clock settings,…)
Unfortunately I don’t have enough experience with Run Load Switch and I didn’t figure out any difference in SM functionality in case of different levels at Run Load Switch.
It is logically that if your application use SCI0 module debugging over the same port will be not possible.
As I already mentioned, code which has to be loaded by Serial Monitor must be compiled/make directly for Serial Monitor as interface (different prm file). This will ensure that user application will not overwrite SM firmware.
EDIT: there is NVM definition for S12C64.
C64:
EEpromStart: equ $0000 ;eeprom start (no EEprom)
EEpromEnd: equ $0000 ;eeprom End
RamStart: equ $3000 ;first RAM location
FlashBlks: equ $01 ;# of flash blks
SectorSize: equ $0200 ;Flash sector size
LowestPage: equ $3C ;lowest page
PagesBlk: equ $04 ;pages per block
softwareID4: equ $3103 ;device ID # for 0M66G maskset.
;softwareID4: equ $3102 ;device ID # for 2L09S maskset.