Hello... Good Evening for everyone...
well.. I'm a beginner on Embedded Systems... and this problem is driving me CRAZY!!! I'm working with the XGATE and CPU cores.. where xgate is producer and CPU consumer. Im using very perpherics of MCU... PIT, ECT, SCI,etc... I have only 1 variable shared between the cores... and im using Semaphore for read and write on this variable in both cores...
Im running the code with Cyclone Pro.. when i run the code... everything works fine... but... after some time.. (1 hour, 3 hours, 30 minutes..this time varies =/) ... my code stop run and in the debugger window.. show ILLEGAL_BP ... and in the HC12 registers... IP have the value E524D always!!!!
I'm newer in CW and CW debugger.. and i dont know what happen... please ...somebody can give me some kinds for i find what its the cause of this problem???
Thanks for your attention.. and sorry if i port in wrong place...
解決済! 解決策の投稿を見る。
Hii guys... FIRST...sorry for the delay of this reply... i wanted to make sure that i finally found the problem... and FINALLY i found the PROBLEM!!!! SECOND: Thank you so much for the kinds... were extremaly important to me to find the error.
Well.. reading your posts, Edward and Radek... I decided to try the wires test in JTAG cyclone and my board.. and remove the reset wire... I left my program running, with the window of the debugger open, and when I touched in cyclone.. the messages ILLEGAL_BP started appearing... so... for my surprise... i found the POWER CONECTOR loose!!!!!!!!!!!! I think my Housekeeper tryied to clean my desktop and did it unintentionally. I left a very large poster in my desk saying: PLEASE DONT TOUCH ANYTHING! REALLY!.. but iit was not enough... Anyway.. I reconnected the power adaptor in cyclone... restarts the code in debugger... and starts the tests... For my happiness .. no more ILLEGAL_BP messages!!! the problem was resolved! No more crashes... no more unnespected resects... everything works fine now!!!
Guys, thanks for listening and especially for try to help me!!! and apologizes for my carelessness!!!
one more time.. thanks! =D.
Hii guys... FIRST...sorry for the delay of this reply... i wanted to make sure that i finally found the problem... and FINALLY i found the PROBLEM!!!! SECOND: Thank you so much for the kinds... were extremaly important to me to find the error.
Well.. reading your posts, Edward and Radek... I decided to try the wires test in JTAG cyclone and my board.. and remove the reset wire... I left my program running, with the window of the debugger open, and when I touched in cyclone.. the messages ILLEGAL_BP started appearing... so... for my surprise... i found the POWER CONECTOR loose!!!!!!!!!!!! I think my Housekeeper tryied to clean my desktop and did it unintentionally. I left a very large poster in my desk saying: PLEASE DONT TOUCH ANYTHING! REALLY!.. but iit was not enough... Anyway.. I reconnected the power adaptor in cyclone... restarts the code in debugger... and starts the tests... For my happiness .. no more ILLEGAL_BP messages!!! the problem was resolved! No more crashes... no more unnespected resects... everything works fine now!!!
Guys, thanks for listening and especially for try to help me!!! and apologizes for my carelessness!!!
one more time.. thanks! =D.
Unfortunately ILLEGAL_BP could means almost anything. In general this message indicates that behavior of MCU is different from behavior expected by debugger (program lost).
In general there could be two reasons:
Typical reasons for unexpected behavior which could cause ILLEGAL_BP:
Ad A)
Your program should be able to handle all interrupts, include unexpected. Here you can find simple code for interrupt catcher:
https://community.freescale.com/docs/DOC-93775
This code you can use for debugging or directly in your software.
Ad B)
In case when you use watchdog: Please check if your software contains any loop where you didn’t update ARMCOP register (typically Flash write routine,…).
Note: COP and CM resets are undebugable by BDM interface. During reset is BDM communication interrupted. I would like recommend use some LEDs for debugging COP and CM resets (BDM interface disconnected).
Ad C)
There are two basic way how detect stack overflow. You can simple increase stack size and check behavior. Or you can use watermark technique: Connect MCU by BDM interface, fill stack area by some char (for example 0xBB), run MCU, after some time stop MCU, look at stack area and check how many 0xBB chars was overwritten.
Hello... Unfortunately... my code stops again... =/ this time.. it stops, restart and stops again... this is very weird... reading your kinds... Im doing the first test: I remove the Cyclone Pro JTAG from my board... and starts the code again... the code performed very well about 12 hours aproximatelly... so I had to leave and take my notebook. After... i tryed run with cyclone again... after 3 hours aproximatelly... the code stoped... Now i remove again the Cyclone JTAG and starts the code. it's been running 5 hours and still running. Well.. my code colect data and send to my computer via SCI and Im saving in a txt file. I have a TimeStamp variable that i checked.. and i noticed that code dont restarts... Now i checked again and meanwhile the code running normally. Can my Cyclone have a problem??? WHat do you think??? Or its more likely that problem is in Software??
Anyway thanks again...
ps: This problem is driving me crazy! :smileyconfused:
Most likely the problem is in your software. I hope you have some version control database? If so, then it is easiest to step back few revisions and see if problems goes away or not and check the differences. If not, then you should try to narrow search by determining what causes reset (and "illegal_bp"). Illegal opcode trap and COP must have dedicated handlers, which should beep, light something, loop forever, signal flags in NO_INIT memory segment or something else. Illegal address reset makes ILAF flag set in CRGINT register. But you need to care to not clear it when setting RTIE, LOCKIE or SCMIE interrupt mask bits. For example RTIE should be set as follows:
CRGINT = (CRGINT & ~CRGINT_ILAF_MASK) | CRGINT_RTIE_MASK;
, any other variants like CRGINT_RTIE = 1 will clear ILAF and make you unable to see this bit set.
From your description it looks like issue with CyclonePro or driver in PC.
But software issue is more probable.
My recommendation about unexpected interrupts is still valid.
ILAF flag is the simplest thing what you could check. But in case S12XE, ILAF flag you can find in CRGFLG register (CRGINT is it in case of S12XD).
Eduard wanted point to typical issue with Read-Modify-Write for flag clearing. In short: Command CRGFLG_ILAF=1; will read CRGFLG register, modify ILAF flag and write back whole byte into CRGFLG register. This way we clear all pending flags. Correct way is for example: CRGFLG = 0x04; //clear ILAF flag.
More info about this topic you can find in application note AN2554 Clearing and Disabling Interrupt Flags. http://www.freescale.com/files/microcontrollers/doc/app_note/AN2554.pdf
Just idea for one more test: Could you connect CyclonePro to board by few wires (you need BKGD-1, GND-2, RESET-4 and VDD-6 pin)? After programming try disconnect wire to RESET pin on BDM connector. This way you can detect if MCU reset is caused by BDM Interface or by MCU itself.
Radek, thanks for pointing that ILAF migrated from CRGINT on S12XD to CRGFLG on S12XE. I didn't know that. Sequence to enable RTIE without clearing ILAF was really odd on S12XD. Now on S12XE it is more similar to clearing timer flags.
Maybe I misunderstood the issue. I thought that João has hang/reset issues both, with and without Cyclone connected.
If the issue is only with Cyclone, then I think it is quite normal to have problems with BDM debugging in noisy environment, especially with weak pullups on BGND and/or RESET pins. You switch table lamp and ... have to restart.
Well... first.. thanks for your answer...the ILLEGAL_BP really could means almost anything... =/ ... Yesterday, after posting this message (2:00 am aproximatelly in Brazil)... I noticed that my only shared variable was declared as INT... So.. I change to VOLATILE INT, starts the code again.. and I went to sleep.
When I woke up today (8:30 am aproximatelly)..for my surprise.. the code not stops!!!! Now.. is 11:50 am, and the code still running....
I think the problem was resolved... however,, if the code stops again.. im check your tips ok?! Anyway...
Thanks so much for your attention and answer...