Other Parts Discussed in Thread: CAPTIVATE-FR2676, CAPTIVATE-PGMR
Hello All,
I am new to MSP430, However i have worked on TM4C Micro-controller using Tiva C SDK.
I am using MSP430FR2676 MCU for which I have CAPTIVATE-FR2676 with a CAPTIVATE-PGMR board
I want to interface a sensor and a MCU using UART communication on MSP430FR2676. For which i created an empty project and imported MSP430FR2xx_4xx driver library.
I am refering the eusci_a_uart_ex1_loopbackAdvanced example code from the driverlib and included the required part in my code.
Now for two Uart interface i am using eUSCI A0 and eUSCI A1 on pins P5.1(UCA0RXD), P5.2(UCA0TXD) and P2.6(UCA1RXD), P2.5(UCA1TXD) respectively.
As on CAPTIVATE-FR2676 P5.1 and P5.2 are avliable i tried testing the UARt communicationon the same.
However i am not able to establish UART communication on the P5.1 and P5.2 port. Can anyone please help with the solution for the same?
Attached is the code snippet for eUSCI A0
//Communication UART Port
#define EUSCA0_UART_PORT GPIO_PORT_P5
#define EUSCA0_UART_RX GPIO_PIN1
#define EUSCA0_UART_TX GPIO_PIN2
#define EUSCA0_UART_FUNCTION_MODE_TXD GPIO_PRIMARY_MODULE_FUNCTION
#define EUSCA0_UART_FUNCTION_MODE_RXD GPIO_PRIMARY_MODULE_FUNCTION
void IntClock(void) { //Set ACLK = REFOCLK with clock divider of 1 MAP_CS_initClockSignal(CS_ACLK,CS_REFOCLK_SELECT,CS_CLOCK_DIVIDER_1); //Set SMCLK = DCO with frequency divider of 1 MAP_CS_initClockSignal(CS_SMCLK,CS_DCOCLKDIV_SELECT,CS_CLOCK_DIVIDER_1); //Set MCLK = DCO with frequency divider of 1 MAP_CS_initClockSignal(CS_MCLK,CS_DCOCLKDIV_SELECT,CS_CLOCK_DIVIDER_1); } int UARTInit(void) { MAP_GPIO_setAsPeripheralModuleFunctionInputPin(EUSCA0_UART_PORT, EUSCA0_UART_TX, EUSCA0_UART_FUNCTION_MODE_TXD); MAP_GPIO_setAsPeripheralModuleFunctionInputPin(EUSCA0_UART_PORT, EUSCA0_UART_RX, EUSCA0_UART_FUNCTION_MODE_RXD); //Configure UART //SMCLK = 1MHz, Baudrate = 115200 //UCBRx = 8, UCBRFx = 0, UCBRSx = 0xD6, UCOS16 = 0 CommUartParam.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK; CommUartParam.clockPrescalar = 8; CommUartParam.firstModReg = 0; CommUartParam.secondModReg = 0xD6; CommUartParam.parity = EUSCI_A_UART_NO_PARITY; CommUartParam.msborLsbFirst = EUSCI_A_UART_LSB_FIRST; CommUartParam.numberofStopBits = EUSCI_A_UART_ONE_STOP_BIT; CommUartParam.uartMode = EUSCI_A_UART_MODE; CommUartParam.overSampling = EUSCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION; if (STATUS_FAIL == EUSCI_A_UART_init(EUSCI_A0_BASE, &CommUartParam)) { return ERROR; } // Enable UART MAP_EUSCI_A_UART_enable(EUSCI_A0_BASE); // Clear USCI_A0 interrupt MAP_EUSCI_A_UART_clearInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT); // Enable USCI_A0 RX interrupt MAP_EUSCI_A_UART_enableInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT); return SUCCESS; } void UARTSend(const uint8_t *pTransmitBuffer, uint8_t ui8Len) { while(ui8Len--) { // Load data onto buffer MAP_EUSCI_A_UART_transmitData(EUSCI_A0_BASE, *pTransmitBuffer++); } } #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=USCI_A0_VECTOR __interrupt #elif defined(__GNUC__) __attribute__((interrupt(USCI_A0_VECTOR))) #endif void EUSCI_A0_ISR(void) { switch(__even_in_range(UCA0IV,USCI_UART_UCTXCPTIFG)) { case USCI_NONE: break; case USCI_UART_UCRXIFG: ui8RxData = MAP_EUSCI_A_UART_receiveData(EUSCI_A0_BASE); if((ui8CommRxData == NULL) || (ui8CommIndex >= BUFFER_SIZE)) { //Call Response or status Handling function memset(ui8Buffer,'\0',COMMUNICATION_BUFFER_SIZE-1); ui8Index = 0; } else { ui8Buffer[ui8Index++] = ui8RxData; } break; case USCI_UART_UCTXIFG: break; case USCI_UART_UCSTTIFG: break; case USCI_UART_UCTXCPTIFG: break; } }
As the UART was not working on above pins i changed the pins to P1.4 and P1.5 with same code snippet but here only UART send is working,
But not UART receive is not working so Please check and let me know if i am missing out any config steps ?
Please help me at the earliest
Thanks and regards
Utkarash