[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] UART again
From: |
Carsten Scharfenberg |
Subject: |
[avr-gcc-list] UART again |
Date: |
Fri, 2 Nov 2001 17:28:18 +0100 |
Hi,
last month Ron submitted code for a buffered UART transmitter based upon TX
Complete Interrupt which arose the question of using the Data Register Empty
Interrupt. - So I did, but whenever I enable UDRIE in UCR no UART interrupts
seem to be triggered.
Here's a sample code of mine which uses three interrupts - everyone switching
another led on and off when being called: SIG_UART_TRANS for showing if any
TXC interrupts are triggered, SIG_UART_DATA for showing if any UDRE
interrupts are triggered and SIG_OVERFLOW0 for showing if the whole
controller is working as it should.
#include <io.h>
#include <interrupt.h>
#include <sig-avr.h>
void init();
int main()
{
init();
outp( 0, UDR );
for(;;);
return 0;
}
INTERRUPT( SIG_OVERFLOW0 )
{
static led = 0;
if( led & 1 )
sbi( PORTB, 7 );
else
cbi( PORTB, 7 );
led++;
}
INTERRUPT( SIG_UART_TRANS )
{
static led = 0;
if( led & 1 )
sbi( PORTB, 0 );
else
cbi( PORTB, 0 );
outp( 0, UDR );
led++;
}
INTERRUPT( SIG_UART_DATA )
{
static led = 0;
if( led & 1 )
sbi( PORTB, 1 );
else
cbi( PORTB, 1 );
outp( 0, UDR );
led++;
}
void init()
{
/******* UART Setup Code ****/
outp( 0x26, UBRR );
outp( 0x68, UCR );
/******* Port B Setup Code ****/
outp( 0xff, DDRB );
outp( 0xff, PORTB );
/******* Timer0 Setup Code ****/
outp( 0x07, TCCR0 );
outp( 0x00, TCNT0 );
outp( 0x01, TIMSK );
/******* Enable All Interrupts ****/
sei();
}
This is the result:
if enable only the TXC interrupt, everything works fine. If I enable the UDRE
interrupt whithout having a corresponding interrupt service routine only the
timer led is blinking - no matter if TXC is also enabled. And if I enable
UDRE while having a corresponding interrupt service routine (as shown above)
nothing happens - all leds are dead.
why this?
I haven't had any problems like these when I wrote such code in Assembler
with AVR-Studio.
Carsten
- [avr-gcc-list] UART again,
Carsten Scharfenberg <=