The Godfather talking
You can run, but you can't hide.
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 18, 2019, 06:47:18 06:47


Login with username, password and session length


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

Posts: 472

Thank You
-Given: 43
-Receive: 1872



« on: April 21, 2019, 08:46:54 08: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
****
Online Online

Posts: 290

Thank You
-Given: 227
-Receive: 106


Tuco ... dead or Alive


« Reply #1 on: April 21, 2019, 10:34:24 10: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
Senior Member
****
Offline Offline

Posts: 472

Thank You
-Given: 43
-Receive: 1872



« Reply #2 on: April 21, 2019, 11:24:44 11: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
****
Online Online

Posts: 290

Thank You
-Given: 227
-Receive: 106


Tuco ... dead or Alive


« Reply #3 on: April 21, 2019, 11:50:50 11: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, 11:56:56 11: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: 339

Thank You
-Given: 141
-Receive: 2455


« Reply #4 on: April 21, 2019, 04:45:23 16: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