program works fine in debug, not working once i do power on reset?

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

program works fine in debug, not working once i do power on reset?

跳至解决方案
5,097 次查看
ponalagappan
Contributor III

Hi,

I am flashing code in MC9s12p32 microcontroller using PE micro USB multilink with codewarrior ver 5.1.

In my code, i just sending CAN message periodically. it is working fine in debug mode, once i do power on reset it is not working, while at the same time, doing reset in debug window  using (halt/reset/start) options is working fine in multiple times.

I tried following things:

1. created an example project and used the startup and .prm file as it is.

2. Disabled all interrupts just to check whether any unimplemented ISR is causing issue.

3. Gave time delay after Osc initialization.

But none of above helped me in fixing this issue.

Could anyone suggest idea to fix this problem?

Thanks

Alagappan

标记 (3)
0 项奖励
回复
1 解答
4,728 次查看
ponalagappan
Contributor III

Hello Zhang,

It got worked on the same day. the root cause was hanging at while loop in CAN initialization.

CAN is available at port M, i configured port M as follows

PTM = 0x00;
DDRM = 0x00;
RDRM = 0x00;
PERM = 0x00;
WOMM = 0x00;

then it started working. Power on reset values of most of these registers are 0 only. Even

i tried writing again 0. After this changes it is working in standalone mode.

Thanks

Pon

在原帖中查看解决方案

0 项奖励
回复
8 回复数
4,729 次查看
ponalagappan
Contributor III

Hello Zhang,

It got worked on the same day. the root cause was hanging at while loop in CAN initialization.

CAN is available at port M, i configured port M as follows

PTM = 0x00;
DDRM = 0x00;
RDRM = 0x00;
PERM = 0x00;
WOMM = 0x00;

then it started working. Power on reset values of most of these registers are 0 only. Even

i tried writing again 0. After this changes it is working in standalone mode.

Thanks

Pon

0 项奖励
回复
4,728 次查看
ponalagappan
Contributor III

Hello Zhang,

Like you said i measured Clock at standalone mode. it is ok. GPIO toggling also fine in standalone.

only my CAN communication is not working at standalone, but found working at only debug mode.

TSEG1, TSEG2 baud rate calculations are fine

Thanks

Alagappan

0 项奖励
回复
4,728 次查看
ponalagappan
Contributor III

Measured clock in scope and it looks proper sine noiseless.

I found the place where it is hanging. I am using a while loop to validate the exiting of initialization mode

 while( !( CANCTL1_INITAK ) ); /* Wait for successful init mode    */ 

Here it is hanging. If i comment this line, other applications are working normally.

But it is not hanging in this while loop in debug mode.

Thanks

Alagappan

0 项奖励
回复
4,728 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Here is some tips.

Check the clock source of CAN.
The default source of clock for S12P is internal IRC1M oscillator and the bus clock is set to 8MHz after reset. External crystal is not initialized.
However, bit CANCTL1_CLKSRC is set to ‘0’ by default. That means the source of clock for CAN module is external crystal. But the crystal is not running, so the INITAK will be ‘1’ forever (initialization mode cannot be leaved) and SYNCH bit will be ‘0’ because the initialization was not finished.

So, as a solution, set CANCTL1_CLKSRC to ‘1’ or start up the external crystal.


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
4,728 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Pon,

I don't see your project, from my understanding, your program can't well run in standalone mode(without connecting debugger), Correct? I can provide you some tips FYI.

1. verify if your code is successfully downloaded to flash. to test it, toggle a led in your code, in standalone running mode, can you see the led blinking?

2. if step 1 is passed test successfully, please verify if the problem is only in CAN module? can you also check other CLOCK involved modules function normal? Some peripheral relies on accurate clock setting. when use debugger download code, clock is trimmed by debug tool automatically. While in standalone mode, clock is not trimmed. If the problem is because of the inaccurate clock, please trim clock manually in code.


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

4,592 次查看
WayneCherish
Contributor I

Hi Zhang:

 

I also met this problem while flashing program to MPC5744.

Firstly, when I set [un-check] to "Attatch to Running Target" in Startup page of Flash configuration,  i can see my project running with PE debugger. But when I reset the MPC5744, or when I disconnect my PE and use 12V power, an elder version of project runs.

 

Secondly, when I set [check] of this item, the error show as below:

Connection from "127.0.0.1" via 127.0.0.1. Connection from port "54999" to 7224
PE-ERROR: Warning. Can't read registers while part is running.
PE-ERROR: Warning. Can't read memory while part is running. @0 (4 bytes)
PE-ERROR: Warning. Can't read memory while part is running. @0 (4 bytes)
PE-ERROR: Warning. Can't read memory while part is running. @0 (4 bytes)
PE-ERROR: Warning. Can't read memory while part is running. @0 (4 bytes)
PE-ERROR: Warning. Can't read memory while part is running. @4002d44(4 bytes)
PE-ERROR: Warning. Can't read memory while part is running. @4002d44(4 bytes)
PE-ERROR: Warning. Can't read memory while part is running.  @4002d44(4 bytes)
Interrupt command received. Halting execution.
No breakpoints currently set.
Disconnected from "127.0.0.1" via 127.0.0.1. Disconnection by port "54999" from 7224
Target Disconnected.

 

In conclusion, I try these method, but neither of them can make me flashing my new project.

HELP!

0 项奖励
回复
4,728 次查看
ponalagappan
Contributor III

Hello Zhang,

Your understanding of my problem is correct. Now i am using internal oscillator and my bus clock is 16 MHz. 

Like you said i will try toggling port pin, measure clock at ECLK pin, then i will check for CAN and i will let you updated on status of problem?

Thanks

Alagappan

0 项奖励
回复
4,728 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

ok. Thanks.

0 项奖励
回复