I'm experiencing a problem on UART communication at low speed (1200 bauds)
On higher speeds (2400...9600 bauds) I can read correct incoming datas but at 1200 bauds datas become wrong.
here is my code
main:
Code: Select all
...
CLKDIVbits.PLLPRE=0;
PLLFBD=68;
CLKDIVbits.PLLPOST=0;
//here freq=140Mhz
PPS_Mapping(67, _INPUT, _U1RX); // RP67=RD3=Rx1
PPS_Mapping(65, _OUTPUT, _U1TX); // RP65=RD1=Tx1
PPS_Mapping(97, _INPUT, _U2RX); // RP97=RF1=Rx2
PPS_Mapping(96, _OUTPUT, _U2TX); // RP96=RF0=Tx2
Delay_ms(100);
UART2_Init_Advanced(1178, _UART_8BIT_NOPARITY, 1, _UART_LOW_SPEED); //at this baud rate, most of char are received
delay_ms(100);
//
LigneTFT1=1;
ColonneTFT=12;
Start_TP();
Start_screen();
U2MODEbits.UARTEN=1;
IEC1bits.U2RXIE=1;
IFS1bits.U2RXIF=0;
...
Code: Select all
void Rx2Interrupt() iv Rx2IntAdr
{
unsigned int x1;
char Txt1[3];
Txt1[0]=UART2_Read() & 0x7F ; //because I'm working on 7 bits I removed bit7
Txt1[1]=0;
WriteOnTFT (txt1,LigneTFTx,LigneTFTy,CL_RED); // to display on TFT. Notice even if this line deplaced away(with long time timer interrupt) the problem is the same
IFS1bits.U2RXIF=0;
}
[/code]