Trouble with Linux and Interrupt-driven UART

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm new to both the Linux and AVR scene (yes, I could be doing this on my XP box, but I figured I might as well learn a little bit about Linux in the process).

Anyway, I followed Dean's awesome tutorial on UART found here:

https://www.avrfreaks.net/index.p...

and was able to successfully communicate with Minicom via serial. However, when I try to make the communication interrupt driven:

https://www.avrfreaks.net/index.p...

the UART does not work. However, when compiled and loaded on the AVR via my Windows machine, everything works fine.

Please note that I am using an Atmega8518 on the STK500, Eclipse for the IDE, AVR-GCC, and Minicom. Also, I changed the ISR vector to ISR(UART_RX_vect), which is required for the 8515. I also added a statement which toggles an LED in the ISR, and since the LED does not toggle, I concluded that the program is not even entering the ISR.

I have searched on this issue, and the best I found was someone with the same issue posted in Dean's Interrupt-driven USART tutorial. However, no definitive answer (from what I could tell) was given as to what was causing this issue.

Any help would be most appreciated.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Stupid suggestion:

You need to enable the RXIEN and UDRIE interupts, or sthg like that

axos88

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd like to bring this topic back form the dead.

I seem to be having the exact same problem with my linux environment, or so it seams.

For reference, as SGMustadio suggested, mpukki seemed to have the same problem: https://www.avrfreaks.net/index.p...

In my case I am using an atmega32 with the Olimex AVR-ISP500. Dean's original tutorial, the one without interrupts works fine, but I am unable to get the interrupt driven one to work.

I unfortunately do not have a Windows machine to test this on, but if it comes down to testing that, I would be more then happy to arrange it.

Currently I am using Dean's code, cut and paste with the addition of adding a blinking LED in the for loop. The LED will blink indefinitely until I send something to the port. When that happens the chip stops, ie, if the LED was off, it remains off. And nothing is returned to minicom.

I'll post my code for completeness:

#include  
#include 
#include  


#define F_CPU 8000000 

#define USART_BAUDRATE 38400
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1) 



// LED is connected to PB0 (pin 1 on the chip)
#define LEDPIN 0


int main (void) 
{ 

   DDRB = 0x1F; // PB0-PB4 output
   PORTB = 0x00; // Set all pins low


   UCSRB |= (1 << RXEN) | (1 << TXEN);   // Turn on the transmission and reception circuitry 
   UCSRC |= (1 << URSEL) | (1 << UCSZ0) | (1 << UCSZ1); // Use 8-bit character sizes 

   UBRRL = BAUD_PRESCALE; // Load lower 8-bits of the baud rate value into the low byte of the UBRR register 
   UBRRH = (BAUD_PRESCALE >> 8); // Load upper 8-bits of the baud rate value into the high byte of the UBRR register 

   UCSRB |= (1 << RXCIE); // Enable the USART Recieve Complete interrupt (USART_RXC) 
   sei(); // Enable the Global Interrupt Enable flag so that interrupts can be processed 

   for (;;) // Loop forever 
   { 
        PORTB |= _BV(LEDPIN); // Turn LED on
        _delay_ms(1000); // Wait 1000 ms (1 sec)

        PORTB &= ~(_BV(LEDPIN)); // Turn LED off
        _delay_ms(1000); // Wait 1000 ms (1 sec)

         // Do nothing - echoing is handled by the ISR instead of in the main loop 
   }    
} 

ISR(USART_RXC_vect) 
{ 
   char ReceivedByte; 
   ReceivedByte = UDR; // Fetch the recieved byte value into the variable "ReceivedByte" 
   UDR = ReceivedByte; // Echo back the received byte back to the computer 
}

I am compiling and writing to the chip with a Makefile from Pat Deegan. I'll include that as well, it may help in the debugging process.

Thank you for your time,
-P

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Solved.
The problem was my makefile. I used the following template:

http://www.sax.de/~joerg/mfile/