For enabling and using UART in CC3200 using SDK without interrupt, visit CC3200 Launchpad - Enabling UART.
If you are having problem with simple UART transaction, please go through the above mentioned post and come back to learn interrupt handling.
There are only a very few more steps to enable and using Interrupt handler for UART. This should be considered as continuation of the above mentioned post.
All the APIs below are prefixe 'MAP_'. But, it can also be used without the prefix. But, prefix is recommended to reduce the size of the binary by mapping the APIs pre-written on the internal ROM chip.
//To enable the Global Interrupt
MAP_IntEnable(FAULT_SYSTICK);
Enabling the global interrupt will make all the unmasked peripheral interrupt to be visible to the interrupt controller.
//Registers a handler for UART1 interrupt
MAP_UARTIntRegister(UARTA1_BASE, UART1_IntHandler);
Registers the interrupt handler with the name given by the second parameter for the UART1. The interrupt handler shall contain the ISR to be run on occurrence of the interrupt.
//Enables interrupt for UART1
MAP_UARTIntEnable(UARTA1_BASE, UART_INT_RX | UART_INT_RT);
The above API unmasks the individual UART interrupts as given by the second parameter. The second parameter can be OR'd value of any or all possible interrupt sources. Here, the macro UART_INT_RX refers to the interrupt on reception of a data at the RX register. UART_INT_RT refers to the Receive timeout interrupt which occurs after pre-defined timeout after the reception of data. Transmit interrupt can also be enabled by OR'ing UART_INT_TX macro. The TIs CC3200 comes with 8 byte Transmit and Receive FIFO to help buffering of serially sent or received data. It also can help reduce the frequency of interrupt.
The Interrupt handler should use the same name as registered with UARTIntRegister as follows.
//Interrupt handler
void UART1_IntHandler() {
unsigned char ch;
while((ch = MAP_UARTCharGetNonBlocking(UARTA1_BASE) != -1) {
chararray[i++] = ch;
}
}
No comments:
Post a Comment
Comment will be published after moderation only. Do not advertise here.