Part Number: MSP430FR4133
We currently need to read characters from Serial Input, but we are unable to correctly trigger the ISRs.
We've tried the code example from the resource explorer but doesn't seem to be working.
We are using an RFID module (EM-18 Reader Module) that operates with a baud rate of 9600. (We've verified that the sensor works)
Here's our code:
#include <msp430.h> #include "driverlib/MSP430FR2xx_4xx/eusci_a_uart.h" #define GPIO_PIN0 (0x0001) #define GPIO_PIN1 (0x0002) #define GPIO_PORT_P1 1 #define GPIO_PRIMARY_MODULE_FUNCTION (0x01) void Init_UART(void) { //Configure UART pins, which maps them to a COM port over the USB cable //Set P1.0 and P1.1 as Secondary Module Function Input. GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN1, GPIO_PRIMARY_MODULE_FUNCTION); GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P1, GPIO_PIN0, GPIO_PRIMARY_MODULE_FUNCTION); /* * UART Configuration Parameter. These are the configuration parameters to * make the eUSCI A UART module to operate with a 9600 baud rate. These * values were calculated using the online calculator that TI provides at: * software-dl.ti.com/.../index.html */ //SMCLK = 1MHz, Baudrate = 9600 //UCBRx = 6, UCBRFx = 8, UCBRSx = 17, UCOS16 = 1 EUSCI_A_UART_initParam param = {0}; param.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK; param.clockPrescalar = 6; param.firstModReg = 13; param.secondModReg = 34; param.parity = EUSCI_A_UART_NO_PARITY; param.msborLsbFirst = EUSCI_A_UART_LSB_FIRST; param.numberofStopBits = EUSCI_A_UART_ONE_STOP_BIT; param.uartMode = EUSCI_A_UART_MODE; param.overSampling = 1; if(STATUS_FAIL == EUSCI_A_UART_init(EUSCI_A0_BASE, ¶m)) { return; } EUSCI_A_UART_enable(EUSCI_A0_BASE); EUSCI_A_UART_clearInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT); // Enable EUSCI_A0 RX interrupt EUSCI_A_UART_enableInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT); } // void conditionalBlink() { PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode // to activate previously configured port settings P4DIR |= 0x01; // Set P4.0 to output direction for(;;) { volatile unsigned int i; // volatile to prevent optimization P4OUT ^= 0x01; // Toggle P4.0 using exclusive-OR i = 10000; // SW Delay do i--; while(i != 0); } } /** * main.c */ void wait_for_char(){ volatile int i=0; for(i=0;i<1000;i++){} } volatile unsigned char buffer[256]; volatile unsigned int bufpos = 0; char process_flag = 0; int main(void) { volatile uint8_t receivedChar = 'q'; int i = 0; WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode //__disable_interrupt(); Init_UART(); __enable_interrupt(); while(1) { if( process_flag) { //EUSCI_A_UART_transmitData (EUSCI_A0_BASE, ); conditionalBlink(); process_flag = 0; break; } } return 0; #pragma vector=USCIAB1RX_VECTOR __interrupt void USCI0RX_ISR (void) { conditionalBlink(); buffer[bufpos] = UCA0RXBUF; bufpos++; if(bufpos == 255) { process_flag = 1; bufpos = 0; } }
Currently it doesn't seem to be entering the ISR.
Any suggestions would be very helpful.