Yahoo Groups archive

AVR-Chat

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

Message

Re: [AVR-Chat] Sample "c" code

2007-06-18 by David VanHorn

On 6/18/07, joe_magee44 <joe_magee44@yahoo.com> wrote:
> Hello I have just acquired a mega128, and intend using it for a
> software  radio control. I have dabbled in the past in Uprocessors,
> (Z80) a long time ago. I used machine code, and hand assembled it....
> I dropped it at that point and havent done any since. I am looking for
> some serial routines in , preferably "C" or assembly. I need to teach
> myself allover again :-(
> Any pointers to some source code would be appreciated.
> Thanks in advance.
> Joe

You'll find the AVR a lot more "friendly" than the Z-80 environment.

One thing to watch for, is that the control registers for some of
USART0, and all of USART1 are in SRAM, so you'll need LDS and STS to
access them instead of IN and OUT.   One easy way to code it, is to
use IN and OUT everywhere, and fix them when the assembler complains.
:)

Another is the UDRIE int, which will int you whenever the transmit reg is empty.
Normally I have a routine that checks my serial out buffer, and turns
on UDRIE if there's stuff to send, and another one in the UDRIE int
that turns OFF udrie when the buffer goes empty.  Otherwise you'll be
getting into the UDRIE ISR every other instruction!

Other than that, it's pretty straightforward, I can send you routines,
but mine are written for cooperative multitasking. I would recommend
that you walk through it in simulation, so that you see the whole
process.

Attachments

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.