HCS08 - Illegal BP

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

HCS08 - Illegal BP

4,636 次查看
DanielMorley
Contributor I
I am trying to program a HC9SO8 chip with a C compiler
I add a while state and the device works for one pass only. The debugger tells me ILLegal BP and ends code.
 
 
I power down device and the code runs fine.
 

Code:
void main(void) {    int x; EnableInterrupts; /* enable interrupts */                 Initialize();  ConfigurePorts();    x=1;  while (x=1){     x=1;  if (Button1==DOWN){     Reverse();  }    } for(;;) {   __RESET_WATCHDOG(); /* feeds the dog */ } /* loop forever */ /* please make sure that you never leave main */}

 
(Alban: moved post from 16-bit; clear title; format code using SRC button)

Message Edited by Alban on 2006-12-12 11:26 PM

标签 (1)
0 项奖励
回复
7 回复数

1,632 次查看
Sten
Contributor IV
the "while (x=1)"  (assignment instead of comparsion) will always be true and never exit.
0 项奖励
回复

1,632 次查看
bigmac
Specialist III
Hello Daniel,
 
The following comments are additional to Peg's observation about the food deficit to the canine.
 
While not the cause of your illegal BP error, you will need to place the code that must execute multiple times within the "main loop" - within the loop forever block.  Any code prior to this is normally intended to execute once only - except that your code seems to create another never-ending loop (assuming variable x remains at 1), and the following code will never be reached.
 
If you are sensing a mechanical pushbutton, you will also need to consider some de-bounce delay before re-testing the pushbutton state.  Otherwise it would be possible for the reverse() function to execute multiple times for a single keypress, probably not what you intend.
 
Regards,
Mac
 
0 项奖励
回复

1,632 次查看
peg
Senior Contributor IV
Seems to me the dog may be getting hungry.
0 项奖励
回复

1,632 次查看
Alban
Senior Contributor II
As an improvement in future Designs, I suggest we replace the dog by a cat.
At least it will hunt for its food and we won't have to feed it.
This should save money...
 :smileytongue: :smileytongue: :smileytongue: :smileytongue:
0 项奖励
回复

1,632 次查看
rocco
Senior Contributor II
It looks like Alban is spending his vacation on the board. :smileywink: And enjoying himself as well. :smileyhappy:

The problem with a cat is that it won't listen to you, and will reset the MCU when it darn well pleases. :smileytongue: :smileytongue: :smileytongue: :smileytongue:
0 项奖励
回复

1,632 次查看
Alban
Senior Contributor II
Hi Rocco,
 
Daytime TV in the UK is .... undescribable. And so is the Scottish weather this week.
 
To bring a bit more on the innovation side:
I recognize I was carried away by the "kicking" and thought we should stop kick the dog and start kicking the cat who deserves it more.
But I also agree that the "ron-ron" of the cat would also create vibration on the board.and could also add to the EMC. :smileyhappy:
 
Alban.
 
0 项奖励
回复

1,632 次查看
yb
Contributor IV
Hi,
I've found THE solution : using a dead cat... It doesn't need any feeds :smileywink:
 
Sorry....
 
Yvan

Message Edited by yb on 2006-12-1510:25 AM

0 项奖励
回复