#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#define LED2 PTBD_PTBD7void MCU_init(void); /* Device initialization function declaration */void test(void){
short int i,j;
for(i=0;i<=600;i++){
for(j=0;j<=600;j++){
LED2 = 0;
} //j end
} //i end
} //test endvoid main(void) {/* Uncomment this function call after using Device Initialization
to use the generated code */
/* MCU_init(); *///EnableInterrupts; /* enable interrupts *//* include your code here */
PTBDD_PTBDD7 = 1; //Set PTB7 as an output
LED2 = 1; //turn off LED2
test(); //turn on LED2
LED2 = 1; //turn off LED2
Hi,
I copied your function from your post and dropped it into a CW5 example project and it works for me!
The short int is implemented as two bytes on the stack so 600 is no trouble.
The double loop takes about 9.5 million cycles on an s08GB60 so yes the COP is going to cause you grief if it is enabled.
So apart from that I don't know what your problem is.
Regards Peg
Hi all,
thank you for your kindly help.
it's really helpful for me as the beginner.
juz as you mentioned,when i disable the SOPT1_COPE.
everything works fine now...
thank you all again...
Hi,
Glad to hear you found your problem,
When you get "weird" problems like this you should run your code in a simulator or debugger, in this case you would have got your answer fairly quickly.
Regards Peg