View previous topic :: View next topic |
Author |
Message |
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
SOLVED: dsPIC33CK64MP205 9 bit serial |
Posted: Wed Mar 04, 2020 10:03 am |
|
|
Good day All.
I was wondering if anybody played with this PIC.
Having trouble with 9 bit serial.
If I putc(0x131) I can see on a scope that I transmit 9 bits but bit 9 is low and not high.
Datasheet states that bits 8-15 on Txreg are unimplemented, yet there is a 9 bit mode and as I was saying there are 9 bits transmitted but bit 9 is always low.
Any thoughts.
Last edited by alan on Thu Mar 05, 2020 1:22 am; edited 1 time in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19587
|
|
Posted: Wed Mar 04, 2020 11:46 am |
|
|
I've used 9bit with no problem.
Key is you need 9bit in the #USE_RS232, and the keyword 'LONG_DATA'.
If you don't have LONG_DATA selected, the extra 9th bit comes from
RS232_ERRORS and you have to set this bit separately. If you use
'LONG_DATA', getc returns a 16bit int and putc accepts a 16bit value. |
|
|
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
Posted: Thu Mar 05, 2020 1:21 am |
|
|
Solved.
I am using the RS485.c driver file for all my projects, so everything regarding 9 bit serial are in there and have been using it for years now, of course by this time heavily modified.
But on this particular chip you need to put the 1st byte in register UxP1 which then appends a "1" to the serial byte and the rest of the message in the standard Tx register. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19587
|
|
Posted: Thu Mar 05, 2020 1:50 am |
|
|
The UART you have there doesn't actually support a normal 9bit mode. The
only way it generates 9bit is as an 'address', and the UxP1 register allows
the extra bit to be enabled for this. Not a good chip choice if you want to
actually do very much with 9bit.
Using it as you do, it'll work, but does mean you have to bodge.... |
|
|
|