News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Serial RS232

Started by Giuseppe MPO, May 18, 2022, 04:41 PM

Previous topic - Next topic

Giuseppe MPO

I have to communicate with a card with an 8-bit RS232 serial protocol with parity,
but I see that the Positron only deals with 8-bit data without parity or 7 with parity.
How can I do this 9-bit transmission?

Mapo

Giuseppe,
with 18F26K22 I set this
Declare Hserial_RCSTA = %11010000                  ' Enable serial port and continuous receive - 9 BIT
Declare Hserial_TXSTA = %01100100                  ' Enable transmit and asynchronous mode - 9 Bit

calculate your parity and send
TXSTA1.0 = Bit9_Var
HRSOut Buffer2

Yasin

There may be a misunderstanding. If parity is enabled in a communication with 8 data bits, the communication format will be 9 bits. Serial hardware can be used if the mcu used supports parity. It can be used in software serial communication.

tumbleweed

As long as the uart supports 9-bit mode then you can do as Mapo suggests.

You have to manually calculate the parity and then set the TX9D bit before loading the TXREG.

Same with receive...the parity bit will be in the RX9D bit (or simply ignore it).

keytapper

It isn't clear if OP means a soft serial transmission.
Ignorance comes with a cost