Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

Beginner wants to Program UART in C

Beginner wants to Program UART in C

2006-12-08 by pjcxb

I have so far only written basic logic using "C" for a Mega8 and would 
like to extend this to use of the UART for RS232 comms to external 
devices.  Would someone kindly point me in the right direction to find 
some introductory information and some "C" code to do this task?

With thanks,
Peter

Re: Beginner wants to Program UART in C

2006-12-08 by Don Kinzer

--- In AVR-Chat@yahoogroups.com, "pjcxb" <p.j.bro@...> wrote:
> Would someone kindly point me in the right direction to find 
> some introductory information and some "C" code to do this task?
The best way to start is to read the USART section in the mega8 
datasheet; it begins on page 133 of the 10/2006 edition.  Several 
pages into that section, you'll find C code examples for initializeing 
the USART and for transmitting/receiving in polled mode.  Once you 
understand that process and if you have an understanding of Interrupt 
Service Routines in general it is a small step to move on to interrupt 
driven transmission/reception.

Don
ZBasic Microcontrollers
http://www.zbasic.net

Re: [AVR-Chat] Beginner wants to Program UART in C

2006-12-08 by John Clymer

Have you checked the UART/USART section of the MCU datasheet?  I just 
checked the ATmega88 datasheet, and it provides sample C code for all 
UART operations.  I believe the ATmega8 datasheet provides this as well.

As far as serial in general, there are many pages describing PC serial 
ports.  While they tend to be PC specific, the intro sections generally 
describe serial communications, RS-232, shift registers and such.  One 
of the (many) useful pages full of information is Beyond Logic, try:

http://www.beyondlogic.org/serial/serial.htm#1

Jan Axelson also is a good source of links (and information if you buy 
the book.)

http://www.lvr.com/serport.htm

If I google:

http://www.google.com/search?q=avr+uart+library&hl=en&lr=

I get plenty of links to pages providing serial port libraries.

ATMEL has written Application Note AVR244: UART as ANSI Terminal 
Interface - describing how to connect the AVR to the PC via HyperTerminal.

http://www.atmel.com/dyn/resources/prod_documents/doc2547.pdf

I hope this helps.  Enjoy.

John

pjcxb wrote:
Show quoted textHide quoted text
>
> I have so far only written basic logic using "C" for a Mega8 and would
> like to extend this to use of the UART for RS232 comms to external
> devices. Would someone kindly point me in the right direction to find
> some introductory information and some "C" code to do this task?
>
> With thanks,
> Peter
>
>

Re: [AVR-Chat] Beginner wants to Program UART in C

2006-12-08 by Jim Wagner

There is some C code example (for IAR-C, I think) in the
Mega8 data sheet. Look in the section about the UART.

Jim

On Fri, 08 Dec 2006 07:44:59 -0000
 "pjcxb" <p.j.bro@paradise.net.nz> wrote:
> I have so far only written basic logic using "C" for a
> Mega8 and would 
> like to extend this to use of the UART for RS232 comms to
> external 
> devices.  Would someone kindly point me in the right
> direction to find 
> some introductory information and some "C" code to do
> this task?
> 
> With thanks,
> Peter
> 

---------------------------------------------------------------
The Think Different Store
http://www.thinkdifferentstore.com/
For All Your Mac Gear
---------------------------------------------------------------

Re: [AVR-Chat] Beginner wants to Program UART in C

2006-12-09 by James Ronald

I suggest downloading Pascal Stang's AVRlib.  It's a pretty good AVR GCC 
Function Library with source, examples and it's GPL.  It should work well 
for the ATmega8, ATmega128.
Show quoted textHide quoted text
>I have so far only written basic logic using "C" for a Mega8 and would
> like to extend this to use of the UART for RS232 comms to external
> devices.  Would someone kindly point me in the right direction to find
> some introductory information and some "C" code to do this task?
>
> With thanks,
> Peter

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.