Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 28, 2024, 02:14:50 14:14


Login with username, password and session length


Pages: [1]
Print
Author Topic: XC8 RS232 Eusart Configuration  (Read 5184 times)
0 Members and 1 Guest are viewing this topic.
intel
Hero Member
*****
Offline Offline

Posts: 520

Thank You
-Given: 53
-Receive: 2142



« on: April 21, 2019, 02:46:54 14:46 »


7 Bits Odd 2 Stop Bits on 18F45K22 with XC8 I need to communicate with RS232. MCC does not support it. I couldn't find a sample code in my searches. Do you have a library or code? Thanks.
Logged

In life, most genuine mentor is science.
TucoRamirez
Senior Member
****
Offline Offline

Posts: 307

Thank You
-Given: 257
-Receive: 115


Tuco ... dead or Alive


« Reply #1 on: April 21, 2019, 04:34:24 16:34 »

something like this?

https://github.com/etiq/OpenLab-PIC18F4550-EUSART-examples
Logged

Whoever double crosses me and leaves me alive... he understands nothing about Tuco.
intel
Hero Member
*****
Offline Offline

Posts: 520

Thank You
-Given: 53
-Receive: 2142



« Reply #2 on: April 21, 2019, 05:24:44 17:24 »

Thanks for your interest TucoRamirez. But these codes are only supported with Hardware.

Your code:
Code:
unsigned char config_1 = USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_LOW;

I can't do anything with hardware support. As an example (requirement for me):

1 Start Bit
7 Data Bit
Odd Parity
2 Stop Bit

This CCS C is also very easy. But so far, I've prepared the code with XC8. The different configuration was a surprise for me.

For CCS C:
#users232(baud = 9600, parity = O, xmit = PIN_C6, rcv = PIN_C7, bits = 7, stream = PORT1)

I couldn't do that with the XC8. I'm hoping it could be with an XC8 Uart library.

Logged

In life, most genuine mentor is science.
TucoRamirez
Senior Member
****
Offline Offline

Posts: 307

Thank You
-Given: 257
-Receive: 115


Tuco ... dead or Alive


« Reply #3 on: April 21, 2019, 05:50:50 17:50 »

i wonder if the CCS implementation is a software one...  

so do you need a soft lib?

you can do 7N2 using 8N1 by shifting and putting manually a stop bit on your send char function
« Last Edit: April 21, 2019, 05:56:56 17:56 by TucoRamirez » Logged

Whoever double crosses me and leaves me alive... he understands nothing about Tuco.
Wilksey
Cracking Team
Senior Member
****
Offline Offline

Posts: 413

Thank You
-Given: 161
-Receive: 2549


« Reply #4 on: April 21, 2019, 10:45:23 22:45 »

set the UART to 8 bits and set the most significant bit when sending, this becomes the stop bit and the real stop bit acts as a second one, giving seven data bits and two stop bits
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC