avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-gcc-list] basic UART Transmit interrupt problem


From: Woodward, Mark P
Subject: RE: [avr-gcc-list] basic UART Transmit interrupt problem
Date: Thu, 03 Jul 2003 11:00:43 -0700

Hi Darren,

I should have mentioned it before, but SIG_UART0_TRANS gives me exactly the
same behavior.  Your reasoning does make sense though.  The pointer to my
interrupt routine must be getting written over somehow.  Am I perhaps
compiling incorrectly?  Here is my compilation procedure

avr-gcc -g -Os -mmcu=atmega128 -c -o Test.o Test.c
avr-gcc -o Test.elf Test.o
avr-objcopy -O srec Test.elf Test.srec
uisp --erase -dprog=dapa
uisp --upload -dprog=dapa if=Test.srec

I really appreciate your help.  Again, any suggestions would be greatly
appreciated.

best,

-Mark

> -----Original Message-----
> From: Darren P [SMTP:address@hidden
> Sent: Wednesday, July 02, 2003 7:42 PM
> To:   Woodward, Mark P; address@hidden
> Subject:      RE: [avr-gcc-list] basic UART Transmit interrupt problem
> 
> Hi,
> Your problem is that you have not defined the ISR correctly, "SIGNAL(
> SIG_UART_TRANS )" should be "SIGNAL( SIG_UART0_TRANS )", you must specify
> which UART the ISR is for (there are 2 UARTs in the Mega128).
> 
> The reason the uC would restart is because gcc places "jmp 0x0000" (jump
> to
> the reset vector) at vector locations where no ISR has been defined.
> 
> Regards,
> Darren
> 
> > Hello all,
> >
> > I run an atmega128L and am currently trying to transmit to the uart
> using
> > the transmit interrupt.  The problem is, when I send a byte after
> enabling
> > the transmit interrupt via
> >
> >   UCSR0B = (1<<TXEN)|(1<<TXCIE);
> >   udr0 = 'A';
> >
> > the byte gets sent, but then the program restarts from main, without
> > triggering my interrupt.  It's weird behavior.  Any help would be
> greatly
> > appreciated.  Here is the code.
> >
> > #include <avr/interrupt.h>
> > #include <avr/io.h>
> > #include <avr/signal.h>
> >
> > static volatile unsigned char *uart_data_ptr;
> > static volatile unsigned char uart_counter;
> > static volatile unsigned char led;
> >
> > SIGNAL( SIG_UART_TRANS ) {
> >   uart_data_ptr++;
> >
> >   if(--uart_counter)
> >     outp(*uart_data_ptr, UDR0);
> > }
> >
> > void setRedLed(int on) {
> >   if(on) {
> >     cbi(PORTA, 2);
> >   } else {
> >     sbi(PORTA, 2);
> >   }
> > }
> >
> > void initRedLed(void) {
> >   sbi(DDRA, 2);
> >   setRedLed(0);
> > }
> >
> > //I am transmitting at 57600
> > void init(void) {
> >   UBRR0H = 0;
> >   UBRR0L = 15;
> >
> >   UCSR0A = 1<<U2X;
> >
> >   UCSR0B = (1<<TXEN)|(1<<TXCIE);
> >
> >   UCSR0C = (1<<UCSZ1)|(1<<UCSZ0);
> > }
> >
> > void uart_send(unsigned char *buf, unsigned char size) {
> >   if(!uart_counter) {
> >     uart_counter = size;
> >     uart_data_ptr = buf;
> >     UDR0 = *buf;
> >     // CRASHES HERE AND JUMPS BACK TO MAIN,
> >     // THE BYTE DOES GET SENT
> >     // DOESN'T CRASH IF I DON'T ENABLE TXCIE
> >   }
> > }
> >
> > int main(void) {
> >   unsigned char i, j, k, l, m;
> >
> >   initRedLed();
> >
> >   // Debug to know restarted
> >   led = 0;
> >   for(m=0; m<10; m++) {
> >     setRedLed(!led);
> >     led = ~led;
> >     for(i=0; i<255; i++)
> >       for(j=0; j<255; j++)
> >         for(l=0; l<100; l++)
> >           k++;
> >   }
> >
> >   init();
> >   sei();
> >
> >   uart_send("HELLO WORLD", 12);
> >
> >   for(;;) { k++; }
> > }
> >
> > _______________________________________________
> > avr-gcc-list mailing list
> > address@hidden
> > http://www.avr1.org/mailman/listinfo/avr-gcc-list
> 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]