Hello Everyone,
I am working on MSP432P401M microcontroller. I want to transmitt 0x55 value in TXBUF. The value is transmitted based on an UART interrupt.
My code is:-
#include "MSP432P401M.h"
void init_uart(void)
{
// Configure UART pins
P1->SEL0 |= BIT2 | BIT3; // set 2-UART pin as secondary function
// Configure UART
EUSCI_A0->CTLW0 |= EUSCI_A_CTLW0_SWRST; // Put eUSCI in reset
EUSCI_A0->CTLW0 = EUSCI_A_CTLW0_SWRST | EUSCI_B_CTLW0_SSEL__SMCLK;//EUSCI_B_CTLW0_SSEL__ACLK; // Remain eUSCI in reset
// EUSCI_B_CTLW0_SSEL__SMCLK; // Configure eUSCI clock source for SMCLK
// Baud Rate calculation
// 12000000/(16*9600) = 78.125
// Fractional portion = 0.125
// User's Guide Table 21-4: UCBRSx = 0x10
// UCBRFx = int ( (78.125-78)*16) = 2
EUSCI_A0->BRW = 78; // 12000000/16/9600
EUSCI_A0->MCTLW = (2 << EUSCI_A_MCTLW_BRF_OFS) | EUSCI_A_MCTLW_OS16;
EUSCI_A0->CTLW0 &= ~EUSCI_A_CTLW0_SWRST; // Initialize eUSCI
EUSCI_A0->IFG &= ~EUSCI_A_IFG_RXIFG; // Clear eUSCI RX interrupt flag
// EUSCI_A0->IFG &= ~EUSCI_A_IFG_TXIFG;
EUSCI_A0->IE |= EUSCI_A_IE_RXIE; // Enable USCI_A0 RX interrupt
//EUSCI_A0->IE |=EUSCI_A_IE_TXIE;
// Enable sleep on exit from ISR
SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk;
// Enable global interrupt
// __enable_irq();
P1->DIR |= BIT0;
P1->OUT &=~BIT0;
// EUSCI_A0->TXBUF=0x55;
// Enable eUSCIA0 interrupt in NVIC module
NVIC->ISER[0] = 1 << ((EUSCIA0_IRQn) & 31);
}
// UART interrupt service routine
void EUSCIA0_IRQHandler(void)
{
EUSCI_A0->TXBUF=0x55;
}
When I debug the code value0x55 is not transmitted in TXBUF. that means UART interrupt is not generated.When I add EUSCI_A0->TXBUF=0x55 in main code(void init_uart) and interrupt is comment out ,the 0X55 value is transmitted in TXBUF.
Why?