How to run from Flash? (MC9S08SH8)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to run from Flash? (MC9S08SH8)

535 Views
Neomar
Contributor I

Hi,

 

I have my code (MC9S08SH8) running OK from RAM during debug but I am not able to run it permanently from flash.

I believe I am doing the programming process correctly. It works with some compiled  examples I downloaded but not with my code.

I believe it's a matter of memory map or something like that but since I am new to the Codewarrior development environment I am not able to figure out how to solve this.

 

Any idea or recommended documentation?

 

Regards

 

Neomar Giacomini

Labels (1)
0 Kudos
4 Replies

327 Views
JimDon
Senior Contributor III

What about the watchdog?

Did you turn that off?

Show us some code....

0 Kudos

327 Views
Neomar
Contributor I

Thanks for answering my post.

I was able to solve the issue.

The code was actually running but I was unable to notice that because my only feedback was through the serial port which was at a wrong baudrate. (continue reading, its interesting)

That problem happened because while debugging I got exactly 9600bps with the configs I had. Therefore able to communicate with my desktop software and develop everything with no problems. After flashing the device the frequency moved to another range but I wasnt aware about that change.

The change happened because when you download the code for debug purposes the tool/codewarrior seems to automatically set a few registers (ICSSC, ICSTRM, ICSC1 and ICSC2) (not sure if they are all needed, still did not had time to go in details) probably in order to communicate at a more precise speed during the debug. I therefore was getting the 9600bps with that configuration done automatically by the tools. While powering the board standalone with no proper configs on (ICSSC, ICSTRM, ICSC1 and ICSC2) it was not communicating and my first thoughts were that the code was not running but it was but god know at what baudrate. (no scope/data acquisition tool here to measure).

After realizing this I got compared the configs (original versus the ones appearing during debug) and added to my code the ones I found during debug... and guess what? PROBLEM SOLVED.

0 Kudos

327 Views
bigmac
Specialist III

Hello,

 

It is unclear whether you have taken into account that there will be a significant unit-to-unit variation of the internal clock reference frequency associated with the ICS module.

 

So assuming that you are using FEI mode, the trim settings to adjust the reference frequency to a specific value will need to be calibrated separately for each device, which is usually done when the code is programmed to the device.  This calibration process will store the trim values in flash memory at addresses 0xFFAF (8-bit value) and 0xFFAE (bit 0 only for fine trim).  The initialisation code following reset must then transfer the non-volatiile calibration values into the ICSTRM and ICSSC registers.

 

This process is essential to consistently obtain a sufficiently accurate baud rate for the SCI module.

 

Regards,

Mac

 

0 Kudos

327 Views
kef
Specialist I

Is reset vector set up properly?

0 Kudos