initialisation after power up

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

initialisation after power up

951 次查看
Yaban
Contributor I

Hi i use a mc9s12c32 for a project and it work really great except at boot when i power the mcu.

I use codewarrior 5.1 and monitor AN2548 for flash or USBDM.

 

All work really well except that i always need to trigger a reset interrupt to initialise the mcu correctly.

I do not understand how to make a proper initialisation at power up.

Please some help is welcome>

 

Regards

 

0 项奖励
回复
3 回复数

880 次查看
lama
NXP TechSupport
NXP TechSupport

Hi,

One think I have to highlight because I do not know entire process you are doing.

Be careful that there is no access to the flash memory block while it is E/W. For example, no read from serial monitor, no visualization of the E/W part of the memory in debugger memory window, no code executed out of the  memory block which is E/W.

How to get info the memory block is erased.

There is command erase verify, but this command checks entire flash block which is not suitable for you because you do not want to erase entire flash at once to avoid bootloader code.

In this case, there is the only approach to check the sector after erasing it and it is loop through it and read word values which should be 0xFF.

Of course, probably the best is to go through entire memory you will program at once as a first step. Then you do not have to check it again.

If you think the memory is erased then it is still good to check the word which is going to be W is erased = 0xFFFF  - good to do it to avoid any possible mistakes. If it is not erased then there is an issue because entire sector must be erased again. So the final approach is up to you.

Best regards,
Ladislav

0 项奖励
回复

915 次查看
lama
NXP TechSupport
NXP TechSupport

Hi,

Hmmmmm, deep history....zombie question .

 

You do not need to use serial monitor if you have USB multilink to load the serial monitor to the MCU. Hmm, probably you use it as a bootloader.

(another bootloader...attached)

 

Do you meet following conditions from AN2548?

During initialization after any cold reset, a long break is transmitted before any other SCI  communication takes place. This break is about 30 bit-times to ensure that a Windows-based PC can recognize this as a break. To establish communications with the monitor, the host must send a carriage return ($0D) at the correct baud rate. If the monitor detects some other character, the host baud rate is not correct so it continues to wait in a loop for the $0D character before printing the first prompt sequence. The host must verify the monitor baud rate by initially sending a carriage return at 115.2 kbaud. If this is the correct baud rate, the target MCU will respond with a prompt sequence of $E0, $08, and a “>” prompt character. The prompt sequence is detailed more completely in following sections.

 

I suppose  you have serial cable disconnected for power up reset.

Do you use your own board design or some EVB? If own, may I see schematic for MCU HW  environment?

 

However, I am not absolutely sure I understand your question.

“Hi I use a mc9s12c32 for a project and it work really great except at boot when i power the mcu.”

Does it mean the serial cable is disconnected and you want to run your application code and it does not work after power on?

“All work really well except that I always need to trigger a reset interrupt to initialize the mcu correctly.”

Does it mean the serial cable is connected and you want to initialize serial monitor? In this case I would expect this behavior because there is an initialization sequence – described above.

If the normal mode is expected I would disconnect the cable and check I MODC=1,MODB=MODA=0

Next, I would check all initializations of write once registers in the code whether I do not set them accidentally twice in some approach I am doing.

 

Best regards,

Ladislav

0 项奖励
回复

905 次查看
Yaban
Contributor I

Hi sir Ladislav. 

 

Thanks for your time and reply. 

Yes my bootloader is correctly set-up. 

I can load and run the code no problem. 

 

It's not a serial cable problem. 

 

And you gave me the good answer thank you. 

I found it by myself already this week but you are right. 

My board is a dragonfly and have no pull up on the bdm pin. 

That's why it started always in special mode and do not fetch the reset vector at startup. 

 

I put a pull up and now all work great. 

I debug that check out the register you mentioned in your post after reading the datasheet of the mcu.

 

The serial monitor yes I use it as a bootloader. 

 

I will check out the bootloader you linked to see if it's valuable for me to use it instead. 

Thank you very much for your help. 

If you have some advice about how to check a erase state of a sector it's helpful. 

 

I try to debug my code actually to flash constant in ram to the flash memory using flash.c.

 

Maybe it's just my code because it flash some data in the flash but it does not correspond to the initial data in ram. 

 

I load new data in a ram trough serial port and try to save them in the flash memory after using a flash command from the pc app trough the serial port. 

 

Thanks 

Regards 

0 项奖励
回复