# HG changeset patch # User Paul Boddie # Date 1539863781 -7200 # Node ID 412fcc6d7b0cac8fb94a14228e53422ac8699b43 # Parent e2302e08b02e28cdc7c10379839e54cf0f9bd1b4 Test with higher-priority interrupt, disabling DMA, due to instability. diff -r e2302e08b02e -r 412fcc6d7b0c main.c --- a/main.c Thu Oct 18 13:36:42 2018 +0200 +++ b/main.c Thu Oct 18 13:56:21 2018 +0200 @@ -64,16 +64,16 @@ init_dma(); dma_init(0, 0, 3); - dma_set_interrupt(0, U1RX, 1); + /* dma_set_interrupt(0, U1RX, 1); */ dma_set_transfer(0, PHYSICAL(message), sizeof(message) - 1, HW_PHYSICAL(UART_REG(1, UxTXREG)), 1, 1); dma_on(0); - /* Set UART interrupt priority below CPU priority. */ + /* Set UART with interrupt. */ uart_init(1, 115200); - uart_init_interrupt(1, UxRIF, 1, 3); + uart_init_interrupt(1, UxRIF, 4, 3); uart_on(1); interrupts_on(); @@ -90,16 +90,19 @@ { /* Check for a UART receive interrupt condition (UxRIF). */ - if (REG(UARTIFS) & UART_INT_FLAGS(1, UxRIF)) + uint32_t ifs = REG(UARTIFS) & UART_INT_FLAGS(1, UxRIF); + + if (ifs) { + /* Clear the UART interrupt condition. */ + + CLR_REG(UARTIFS, ifs); + /* Write the received data back. */ while (REG(UART_REG(1, UxSTA)) & 1) uart_write((char) REG(UART_REG(1, UxRXREG))); - /* Clear the UART interrupt condition. */ - - CLR_REG(UARTIFS, UART_INT_FLAGS(1, UxRIF)); INV_REG(PORTA, 1 << 2); } }