Yahoo Groups archive

AVR-Chat

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

Thread

USART

USART

2009-09-23 by Emerson Santos

Hi people ...

I´m a newbie in AVR USART , and i have a problem that i can understand.. I
make a code below

...

#asm("SEI");

main
while (1)
      {

       WR_SERIAL(0x04);

      };
}

....


unsigned char WR_SERIAL(unsigned char dado)
{

      if (!(UCSRA & (1<<UDRE)) )
        {
          return;
        }

       UDR = dado;


}

interrupt [USART_TXC] void usart_tx_isr(void)
{
 OK=~OK;
 for(;;);
}

...

Yes, is a ingenous and simple code, the usart is set in 4800, no parity, 8
bits ... etc etc

My problem is that the interruption is working if i run my program with JTAG
e AVRSTUdio (I run in a ATmega32) in steoping mode... but out the AVRStudio
.. nothing happening the TX is working all time and not have a stop that i
like.

I read the DS and the thing really is like the DS , but works only in the
AStudio ...

Thanks for any help and sorry for my bad english :)

Emerson


[Non-text portions of this message have been removed]

Re: [AVR-Chat] USART

2009-09-23 by David Kelly

On Wed, Sep 23, 2009 at 12:17:34PM -0300, Emerson Santos wrote:
> Hi people ...
> 
> I?m a newbie in AVR USART , and i have a problem that i can
> understand.. I make a code below
> 
> ...
> 
> #asm("SEI");
> 
> main
> while (1)
>       {
> 
>        WR_SERIAL(0x04);
> 
>       };
> }
> 
> ....

[...]

> My problem is that the interruption is working if i run my program
> with JTAG e AVRSTUdio (I run in a ATmega32) in steoping mode... but
> out the AVRStudio .. nothing happening the TX is working all time and
> not have a stop that i like.

Why is #asm("SEI"); sitting outside of main()? I don't recognize the
language used above for main() while the rest of the code appears to be
C. User code execution starts at main() so your SEI should be after the
entry point to main().

If using avr-gcc one can:

#include <avr/interrupt.h>

main()
{
	sei();
	while(1) {
		WR_SERIAL( 0x04 );
	}
}

-- 
David Kelly N4HHE, dkelly@HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.

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.