cnt_poll, cnt_sensor, cnt_rec volatile..
Closed this issue · 1 comments
wun-4711 commented
Hello,
thank you for your fine work!
Just my two cents after wondering over my code:
static uint8_t cnt, last_cnt;
last_cnt = IBusServo.cnt_rec;
while ( last_cnt == (cnt = IBusServo.cnt_rec) ) {
//sleepy...wait for new data
}
that became a endless loop instead of waiting about 7ms...
You should declare (File IBusBM.h):
volatile uint8_t cnt_poll; // count received number of sensor poll messages
volatile uint8_t cnt_sensor; // count times a sensor value has been sent back
volatile uint8_t cnt_rec; // count received number of servo messages
Regards, wun
bmellink commented
Thanks for the suggestion on adding the volatile keyword to these vars. I will make that change in the code.