here,
My origin code
OCR0A=30;
uint16_t start=TCNT1;
uint16_t w;
for(uint8_t i=0;i<6;i++){
pwm=pgm_read_byte(&forward[i]); // mark here
// delay
do{
w=TCNT1;
} while(w-start>300);
}
OCR0A=127;
compile it, and look into asm, I found my code's business was changed. it became some other like bellow
OCR0A=30;
uint16_t start=TCNT1;
uint16_t w;
for(uint8_t i=0;i<6;i++){
// delay
do{
w=TCNT1;
} while(w-start>300);
}
pwm=pgm_read_byte(&forward[5]); // mark here
OCR0A=127;
Attention on line "mark here".
In my origin code. pwm
should be used by timer overflow interrupt. the second code is not really generated by compiler. I wrote it just for convenience describe
Any suggestion? Thanks