Hi guys (and gals) I am working on trying to use PDCA to receive data from a USART on a couple of projects. Both have periods of no data that I would like to use to trigger an USART Timeout to indicate that a data cycle is one and the PDCA needs to switch input buffers. I put a test toggle output in mi USART Timeout interrupt ISR to see how often it triggers. Baud is 9600, trigger rate for Timeout is 4us, regardless of what value I load RTOR with! Below is my code for the USART - I hope someone can point out the errors of my ways - this is one time the wife can't!
void init_USART_0(void) { static const gpio_map_t USART_GPIO_MAP = { {USART_0_RX_PIN, USART_0_RX_FUNCTION}, {USART_0_TX_PIN, USART_0_TX_FUNCTION}, }; static const usart_options_t USART_0_OPTIONS = { .baudrate = USART_0_BAUD_RATE, .charlength = USART_0_CHARLENGTH, .paritytype = USART_0_PARITY, .stopbits = USART_0_STOPBITS, .channelmode = USART_0_MODE }; gpio_enable_module(USART_GPIO_MAP, sizeof(USART_GPIO_MAP) / sizeof(USART_GPIO_MAP[0])); usart_init_rs232(USART_0, &USART_0_OPTIONS, CLOCK_PBA_FREQ); return; } void USART_0_Interrupt_Init(void) { Disable_global_interrupt(); INTC_init_interrupts(); INTC_register_interrupt(&usart_0_int_handler, USART_0_IRQ, AVR32_INTC_INT0); USART_0->rtor = 8 << AVR32_USART_RTOR_TO_OFFSET; USART_0->cr = USART_0->cr | 1 << AVR32_USART_CR_STTTO_OFFSET; //USART_0->rtor =1024; USART_0->ier = AVR32_USART_IER_TIMEOUT_MASK; //USART_0->cr = AVR32_USART_RETTO_MASK; gpio_tgl_gpio_pin(TEST_LED); Enable_global_interrupt(); return; } __attribute__((__interrupt__)) void usart_0_int_handler(void) { int c,b; if (USART_0->csr & AVR32_USART_TIMEOUT_MASK) { gpio_tgl_gpio_pin(TEST_LED); usart_reset_status(USART_0); if (buffer_pointer) { pdca_reload_channel( PDCA_CHANNEL_NUMBER, (void *)Buffer_2, sizeof(Buffer_2)); } else { pdca_reload_channel( PDCA_CHANNEL_NUMBER, (void *)Buffer_1, sizeof(Buffer_1)); } /* Switch to the other input buffer */ buffer_pointer = !buffer_pointer; buffer_ready = !buffer_pointer; USART_0->cr = AVR32_USART_RETTO_MASK; } }
Thanks,
David