Hi,
I am working on MSP430FR2422 and i am new to this board. I am currently working on the UART and I am trying to receive the data coming from UART external peripheral and I want to receive the data but here I am not able to do that . I am giving input to UART com port that should go to the P1.5 which is the UCA0RXD which we are using. Here the main problem we are facing is that when the ISR is called the routine is executed and the dat is not being saved in UCARXBUF . I am attaching the code and also I have seen the driver as well as register library example from the resource explorer but I didn't find any significant clue from that.
/******************************************************************************
#include "driverlib.h"
//#include "Board.h"
#define GPIO_PORT_UCA0TXD GPIO_PORT_P1
#define GPIO_PIN_UCA0TXD GPIO_PIN4
#define GPIO_FUNCTION_UCA0TXD GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_UCA0RXD GPIO_PORT_P1
#define GPIO_PIN_UCA0RXD GPIO_PIN5
#define GPIO_FUNCTION_UCA0RXD GPIO_PRIMARY_MODULE_FUNCTION
uint16_t i;
uint8_t RXData = 0, TXData = 0;
char mystr[20]="Hello_World\r\n";
unsigned long int m=0;
uint8_t check = 0;
#include<stdio.h>
void main(void)
{
//Stop Watchdog Timer
WDT_A_hold(WDT_A_BASE);
//Set ACLK = REFOCLK with clock divider of 1
CS_initClockSignal(CS_ACLK,CS_REFOCLK_SELECT,CS_CLOCK_DIVIDER_1);
//Set SMCLK = DCO with frequency divider of 1
CS_initClockSignal(CS_SMCLK,CS_DCOCLKDIV_SELECT,CS_CLOCK_DIVIDER_1);
//Set MCLK = DCO with frequency divider of 1
CS_initClockSignal(CS_MCLK,CS_DCOCLKDIV_SELECT,CS_CLOCK_DIVIDER_1);
//Configure UART pins
GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_UCA0TXD,
GPIO_PIN_UCA0TXD,
GPIO_FUNCTION_UCA0TXD
);
GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_UCA0RXD,
GPIO_PIN_UCA0RXD,
GPIO_FUNCTION_UCA0RXD
);
/*
* Disable the GPIO power-on default high-impedance mode to activate
* previously configured port settings
*/
PMM_unlockLPM5();
//Configure UART
//SMCLK = 1MHz, Baudrate = 115200
//UCBRx = 8, UCBRFx = 0, UCBRSx = 0xD6, UCOS16 = 0
EUSCI_A_UART_initParam param = {0};
param.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK;
param.clockPrescalar = 8;
param.firstModReg = 0;
param.secondModReg = 0xD6;
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 = EUSCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION;
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_TRANSMIT_INTERRUPT);
// Enable USCI_A0 RX interrupt
EUSCI_A_UART_enableInterrupt(EUSCI_A0_BASE,
EUSCI_A_UART_TRANSMIT_INTERRUPT);
// Enable global interrupts
__enable_interrupt();
while (1)
{
// Increment TX data
// Load data onto buffer
int f;
for(f=0;mystr[f]!='\0';f++)
{
//UCA0TXBUF=mystr[f];
EUSCI_A_UART_transmitData(EUSCI_A0_BASE,mystr[f]);
}
for(m=0;m<10000;m++);
// while(check != 1);
//check = 0;
}
}
//******************************************************************************
//
//This is the USCI_A0 interrupt vector service routine.
//
//******************************************************************************
#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_UCTXIFG:
// RXData=UCA0RXBUF;
RXData = EUSCI_A_UART_receiveData(EUSCI_A0_BASE);
// Check value
//if(!(RXData == TXData))
//{
// while(1);
//}
//check =1;
break;
case USCI_UART_UCRXIFG: break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
}
}