I have a for loop that prints the iterator to a 16x2 LCD screen. It prints "000", waits 500 ms, and then prints "001" over and over (the LED on RB0 blinks) without incrementing. I tried it on another PIC with no results. How can I get it to increment? Code is in C for a PIC16F1789.
void main(void) {
init();
LCD_init();
for(uint8_t i = 0; i <= 255; i++) {
char str[3];
sprintf(str, "%03u", i);
LCD_cmd(LCD_CLEAR);
LCD_string(str);
LATB ^= 0x01;
__delay_ms(500);
}
}