Can someone *please* tell me what I'm overlooking here:
Code:
#include <avr32/io.h>
#include "compiler.h"
#include "board.h"
#include "power_clocks_lib.h"
#include "gpio.h"
#include "usart.h"
// comment out whichever channel isn't being used...
//#define TEST_USART (&AVR32_USART0)
//#define TEST_USART_IRQ AVR32_USART0_IRQ
#define TEST_USART (&AVR32_USART1)
#define TEST_USART_IRQ AVR32_USART1_IRQ
// global vars
int usart_isr_count = 0;
int n = 0;
U8 rxbuff[100];
// USART interrupt service routine
__attribute__((__interrupt__))
static void usart_rx_isr( void )
{
volatile int rxByte;
usart_isr_count++; // count the interrupts
rxByte = (TEST_USART->rhr & AVR32_USART_RHR_RXCHR_MASK) >> AVR32_USART_RHR_RXCHR_OFFSET;
rxbuff[n++] = rxByte;
if(n>99) {
n = 0; // set a breakpoint here to view buffer
}
}
int main(void)
{
pcl_switch_to_osc(PCL_OSC0, FOSC0, OSC0_STARTUP);
// comment out the two lines to the port not being used below
static const gpio_map_t USART_GPIO_MAP =
{
//{18, 0}, // usart 0 rx mapping
//{19, 0} // usart 0 tx mapping
{24, 0}, // usart 1 rx mapping
{23, 0} // usart 1 tx mapping
};
// USART options.
static const usart_options_t USART_OPTIONS =
{
.baudrate = 4800,
.charlength = 8,
.paritytype = USART_NO_PARITY,
.stopbits = USART_1_STOPBIT,
.channelmode = USART_NORMAL_CHMODE
};
// Assign GPIO to USART.
gpio_enable_module(USART_GPIO_MAP, sizeof(USART_GPIO_MAP) / sizeof(USART_GPIO_MAP[0]));
// Disable all interrupts.
Disable_global_interrupt();
// Initialize interrupt vectors.
INTC_init_interrupts();
// register interrupt handler
INTC_register_interrupt(&usart_rx_isr, TEST_USART_IRQ, AVR32_INTC_INT0);
// Initialize USART in RS232 mode.
usart_init_rs232(TEST_USART, &USART_OPTIONS, FOSC0);
TEST_USART->ier = 0x00000001; //AVR32_USART_IER_RXRDY_MASK;
Enable_global_interrupt();
while (true); // wait for interrupts on the serial port
}
USART 1 works perfectly, but when configured for USART0, the ISR never triggers...
It seems like the USART_GPIO_MAP would be the issue here but the values used are what I find in the uc3b0256.h
Any insight would be much appreciated!
Thanks in advance,
Walt |