Hello
Having a weird issue. UART code that works perfectly on a dsPIC30F4011 doesn't want to work on a PIC24FV16KA301. On the PIC24 the UART starts to drop characters after the first four. If I send '1234ABCD' I get '1234ABD' on the other end.
Same problem at all baud rates down to 9600. Loop-back mode - same behavior. Oddly enough, in MPLAB SIM it works fine.
Function is super simple - check for the buffer full flag, cram data if it's not full, spin otherwise. If I rely on the UTXBF flag to check for a full buffer, I start loosing characters. If I rely on the TRMT flag, everything works fine - all the way up to 115kb/sec.
Checking the UTXBF flag works fine on the dsPIC30.
Weirdness. Anyone else experience a similar issue?
void flush_buffer(void)
{
tx_c = 0;
while(tx_c < ob_idx)
{
//if(U1STAbits.TRMT == 1)
if(U1STAbits.UTXBF == 0)
{
U1TXREG = output_buffer[tx_c];
tx_c = tx_c + 1;
}
}
ob_idx = 0;
return;
}