2005-09-15 10:07 PM
2005-09-15 01:49 AM
Hi all,
I have narrowed a code error down to this loop: while(!(CMSR & 0x01)) { CMCR |= 0x01; } from which the COSMIC compiler generates the following absolute listing: 1235 850d 2002 jra L572 1236 850f L372: 1237 ; 444 CMCR |= 0x01; 1238 850f 1068 bset _CMCR,#0 1239 8511 L572: 1240 ; 441 while(!(CMSR & 0x01)) 1241 8511 0169fb btjf _CMSR,#0,L372 The problem is that the code is entered and runs either once or twice (normally twice, ~70% chance) but then code execution stops! I have checked this using SCI comms code and code immediately after this loop will not run. Code before this runs as expected. Does anyone have any ideas? I am programming the micro through an inDART ST7 which works fine.2005-09-15 07:25 PM
What is the purpose of this code ? CMSR is a register ? Why loop is running 2 times , it shall be always once
change it to if (!(CMSR & 0x01)) { CMCR |= 0x01; }2005-09-15 10:07 PM
Sorry alok,
CMSR is a status register. To put the CAN peripheral into initialisation mode, you need to set bit 0 of the CMCR register. It will then enter that mode when it is not receiving anything. I cannot guarantee that the module is doing nothing when this code runs, but the next lines require that the CAN module is in initialisation. When bit 0 of the CMSR is set, the module is in initialisation mode. My problem is that this code executes fine but that the line directly after it never executes.