Hello,
I use the DSPS sample with hardware flow control on pins :
TX : p1.0
RX : p1.2
RTS : p0.7
CTS : p0.5
I use a PAN1740 USB devkit and a pad that receive serial over bluetooth data from module.
When I plug a line (RTS or CTS) from my PIC to the module, this one crash (maybe reset) after a little time...
The code of the PIC :
inline void usart_write(char data) {
RTS = 0; // Host ready for transmit
while(CTS == 1); // Wait for device ready
while(PIR1bits.TXIF == 0); // Wait for empty buffer
TXREG = data;
while(TXSTAbits.TRMT == 0); // Wait for transmit end
RTS = 1; // Transmit end
}
RTS for PIC is an output and CTS an input.
Without flow control the pad receive wrong data because module sometime sleep.
What am I doing wrong ?
Thanks,
Morgane Vallée