CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

rs232 break character

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
lupoccs



Joined: 31 Jul 2018
Posts: 8

View user's profile Send private message

rs232 break character
PostPosted: Tue Jul 31, 2018 4:52 am     Reply with quote

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: 19195

View user's profile Send private message

PostPosted: Tue Jul 31, 2018 6:59 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jul 31, 2018 7:48 am     Reply with quote

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: 19195

View user's profile Send private message

PostPosted: Tue Jul 31, 2018 7:53 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jul 31, 2018 8:33 am     Reply with quote

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: 19195

View user's profile Send private message

PostPosted: Tue Jul 31, 2018 10:25 am     Reply with quote

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'.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group