Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

9bit UARTs

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
trend

Bascom Member



Joined: 02 Jan 2005
Posts: 3

PostPosted: Tue Feb 01, 2005 7:27 am    Post subject: 9bit UARTs Reply with quote

Hello, I have a device that communicates serially.. but with 9n1.. 1
start, 8 data bits + 1addressing bit, + 1 stop.

How do I setup the 2nd UART on an AVR for this?

I saw this code whenI was searchingaround:

CONFIG COM2 = Dummy , Synchrone = 1 , Parity = None , Stopbits = 1 ,
Databits = 9 , Clockpol = 0


but.. the guy said he got compilation errors when he tried to
compile it..


2ndly,
Could I still use a max232 chip to shift the voltages? basically I
am wondering if the max232 operates on the low level voltages.. and
doesn't actually care what data is going across the line.


thanks guys!
Lee
Back to top
View user's profile
naicheben

Bascom Member



Joined: 18 Nov 2004
Posts: 47
Location: Leck

germany.gif
PostPosted: Tue Feb 01, 2005 8:32 am    Post subject: Reply with quote

the max232 does't care about the Datas send through it. It's just a levelconverter. Sounds as if you used the part before so just use it like in other applications.

regards,
Ingmar
Back to top
View user's profile
trend

Bascom Member



Joined: 02 Jan 2005
Posts: 3

PostPosted: Tue Feb 01, 2005 4:07 pm    Post subject: Reply with quote

ok, that is what I thought.. but just wanted to double check.

thanks!

Now anyone know how to set uarts up for 9bit ?

thanks-Lee
Back to top
View user's profile
DToolan

Bascom Member



Joined: 14 Aug 2004
Posts: 1384
Location: Dallas / Fort Worth, Texas (USA)

blank.gif
PostPosted: Tue Feb 01, 2005 10:38 pm    Post subject: Reply with quote

To set up a usart for 9-bit communications you have to SET UCSR0A.0 (usart zero, bit zero) or SET UCSR1A.0 (usart one, bit zero... these names may vary depending on your chip). This bit in usart control register A represents the MPC bit. This instructs the usart to generate a received character interrupt on reception of address character only (this is when the 9th bit is set). This also means you will need to enable the usart's RXC interrupt, enable all interrupts and have an RXC interrupt routine for the usart in question.

Upon reception of an address character, the interrupt service routine for that usart will be vectored to. You will need to test this address character for whatever address you decide to trigger on. When you have an address match, you RESET UCSR0A.0 or UCSR1A.0 so the usart will generate interrupts for the incoming data characters attributed to that address.

Most protocols have either a set frame size (number of characters following address) or an end of frame character. You will need to test for this condition in the data stream. Also, most protocols have a timeout period in case a frame is interrupted in mid-stream.... this you will also need to test for.

Upon detecting end of frame or timeout... you again SET UCSR0A.0 or UCSR1A.0 to enable interrupts on address characters only. This restarts the whole process and ignores data characters (characters without the 9th bit set).

I'd be surprised if this interface was RS232 as most multi-drop addressing is done over an RS485 or similar interface.
Back to top
View user's profile Yahoo Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
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
You cannot attach files in this forum
You cannot download files in this forum