This line isn't working as expected:
uartPushPos = (uartPushPos + 1) % UART_TX_BUFF_LENGTH;
However this below, which in theory does the same, does work:
//if (uartPushPos == UART_TX_BUFF_LENGTH - 1){
if (uartPushPos >= UART_TX_BUFF_LENGTH - 1){
uartPushPos = 0;
} else {
uartPushPos++;
}
UartPopPos is type char, and UART_TX_BUFF_LENGTH is a preprocessor variable set to 16.
Why does the second code segment work, but not the first?
If it makes much of a difference, I'm using the SourceBoost BoostC compiler for the PIC microcontroller 16f.
Thanks