View previous topic :: View next topic |
Author |
Message |
lupoccs
Joined: 31 Jul 2018 Posts: 8
|
rs232 break character |
Posted: Tue Jul 31, 2018 4:52 am |
|
|
I use a DSPIC33EP64MC206 and a CCS 5.074
I would like to transmit a break character with rs232.
How can I set up the break transmission with #use rs232? Or with setup_serial?
Thank You |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Tue Jul 31, 2018 6:59 am |
|
|
Basically you can't.
The PIC UART does not support generating a break (unlike UART's like the 16450 on the PC).
You have to turn off the UART, set the pin low, wait, then turn the UART back on.
Code: |
set_uart_speed(FALSE); |
disables the UART.
Then
Code: |
output_low(TX_PIN); //for your transmit pin
delay_ms(xx); //for however long the break needs to be
set_uart_speed(xxxx); //to start the UART again (with the baud rate you want). |
|
|
|
lupoccs
Joined: 31 Jul 2018 Posts: 8
|
|
Posted: Tue Jul 31, 2018 7:48 am |
|
|
I see in the user manual (datasheet) of DSPIC33EP64MC206 in the UxSTA: UARTx STATUS AND CONTROL REGISTER section that there is the bit 11 that enable the break character transmission, and I can't find a way to change that bit with built in function of CCS compiler.
Anyway i transmit 3 characters on serial line and I see the 3 characters with oscilloscope on TX pin.
Then I created a direct access to the control register and I set the bit 11 and I see that the break character is transmitted INSTEAD of the first of the 3 characters.
If I set the bit 11 and transmit 4 characters (first character twice) I obtain a break character and the 3 characters I want.
Thank You |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Tue Jul 31, 2018 7:53 am |
|
|
No.
That is for synchronous mode only.
It is described in the family reference manual as for sync, but in fact no mention is made of what it'll do in async mode.
Worth trying. Dead easy:
Code: |
#byte U1STA=getenv("SFR:U1STA")
#bit U1TXBRK=U1STA.11
U1TXBRK=TRUE; //will set it.
while (U1TXBRK)
; //wait to complete
|
It should send a 12bit character if it works. |
|
|
lupoccs
Joined: 31 Jul 2018 Posts: 8
|
|
Posted: Tue Jul 31, 2018 8:33 am |
|
|
If I set the bit the while never ends, because the bit "enables" the break character transmission but doesn't transmit it, in fact the break character is transmitted only on the next true character transmission.
So if I set the bit and transmit a character and wait for the end of break character transmission all works fine.
Thank You for support.
Now it's OK. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Tue Jul 31, 2018 10:25 am |
|
|
That is interesting that it works. Given the manual says 'sync', and the picture they show is a sync transaction (with clock), I doubted it would work....
One of those 'hidden extras'. |
|
|
|