Hi All I cannot get the USART in a AT90USB1287 to respond to the RX interrupt. I have read the '1287 data sheet several times now. I guess I am overlooking something but I am darned if I know what.
Attached are the source and make files for a simple app that demonstrates the problem. It transmits the text to TeraTerm on a PC but typing anything there never interrupts at the USART1 vector. The vector is there in the interrupt table at 0x32 and points to the correct location. I can scope the incoming characters right on the RX pin (PD2). It is compiled with avr-gcc (WinAVR 20090313) 4.3.2 and loaded into a AT90USB128716AU with a 14.7456MHz crystal on a STK501. The other numbers on the '1287 are 0740-6G3879A. Can anyone offer a suggestion? Thanks Ron
makefile
Description: Binary data
// A test of the usb1287 serial interface.
//
#include <avr/interrupt.h>
#define SB(a) (1<<a)
typedef unsigned char uint8;
typedef unsigned int uint16;
#define CRYSTAL 14745600L
#define BAUD 19200L
void Delay(int milliseconds);
volatile uint8 Buffer[] = "Hello ";
volatile uint8 byte;
volatile uint8* ptr;
int main(void)
{
DDRC = 0xff;
PORTC = 0xff;
DDRD = 0x01;
uint16 count = (uint16)(CRYSTAL / 16L / BAUD - 1);
UBRR1 = count;
UCSR1B = SB(RXCIE1) | SB(TXCIE1) | SB(RXEN1) | SB(TXEN1);
UCSR1C = SB(UCSZ11) | SB(UCSZ10);
sei();
PORTD |= 0x01;
ptr = Buffer;
UDR1 = *ptr++;
while (1)
{
while (*ptr != '\0') {;}
Delay(10);
ptr = Buffer;
UDR1 = *ptr++;
}
return 0;
}
ISR(USART1_RX_vect)
{
byte = UDR1;
PORTC = ~byte;
UDR1 = byte;
}
ISR(USART1_TX_vect)
{
if (*ptr != '\0')
{
UDR1 = *ptr++;
}
}
void Delay(int milliseconds)
{
volatile int i, j, k;
for (i=0; i<milliseconds; i++)
for (j=0; j<550; j++)
k = j;
}
_______________________________________________ AVR-chat mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/avr-chat
