This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Part Number: MSP432P401R
Tool/software: Code Composer Studio
Hello Fellows,
I am constructing a project on the msp432 with CCS, I need to programe some tasks for the receive UART interruption. But when a start using the interruption I have see the tasks doesn't realize. So to debug the problem, I put a printf inside the "if" then and I verify the interruption occurs twice. I share my code:
#include "msp.h" /* Standard Includes */ #include <stdint.h> #include <stdbool.h> #include <stdio.h> #include <uart2.h> uint8_t txData,messageInProgress, charsReceived; volatile bool bleState = true; extern uint8_t btConnected, deviceConn; char expectedCommandResponse[6]; volatile bool buffReceive; /*UART BLUETOOTH CONFIGURATION*/ void uart_init(void){ /*CONFIGURE UART*/ EUSCI_A2->CTLW0 |= EUSCI_A_CTLW0_SWRST; /*BEGIN INITIALIZATION PROCESS FOR BAUD RATE 115200*/ EUSCI_A2->CTLW0 |= EUSCI_A_CTLW0_SSEL__SMCLK; /*CONFIGURE EUSCI CLOCK SMCLK*/ /*BAUD RATE CALCULATION*/ EUSCI_A2->BRW = 78; EUSCI_A2->MCTLW = ( 2 << EUSCI_A_MCTLW_BRF_OFS ) | EUSCI_A_MCTLW_OS16; EUSCI_A2->CTLW0 &= ~(EUSCI_A_CTLW0_SWRST); /*INITIALIZE EUSCI STATE MACHINE*/ //EUSCI_A2->IFG &= ~(EUSCI_A_IFG_RXIFG); EUSCI_A2->IE |= EUSCI_A_IE_RXIE; /*ENABLE THE UART RX INTERRUPT*/ /*ENABLE NVIC IN EUSCI_A2 INTERRUPT*/ __enable_interrupt(); NVIC->ISER[0] = 1 << ((EUSCIA2_IRQn) & 31); } /*UART PORTS*/ void confg_uart_wire(void){ P3->SEL0 |= UARTMSP432_P3_3_UCA2TXD | UARTMSP432_P3_2_UCA2RXD; /*SET 2 UART PIN AS SECOND FUNCTION*/ P3->SEL1 &= ~(UARTMSP432_P3_3_UCA2TXD | UARTMSP432_P3_2_UCA2RXD); /*SET 2 UART PIN AS SECOND FUNCTION*/ } /*CONFIGURE INPUT OUTPUT TO SAVE ENERGY*/ void confg_IO (void){ P1->OUT = 0x00; P1->DIR = 0xFF; P2->OUT = 0x00; P2->DIR = 0xFF; P3->OUT = 0x00; P3->DIR = 0xFF; P4->OUT = 0x00; P4->DIR = 0xFF; P5->OUT = 0x00; P5->DIR = 0xFF; P6->OUT = 0x00; P6->DIR = 0xFF; P7->OUT = 0x00; P7->DIR = 0xFF; P8->OUT = 0x00; P8->DIR = 0xFF; P9->OUT = 0x00; P9->DIR = 0xFF; P10->OUT = 0x00; P10->DIR = 0xFF; PJ->OUT = 0x00; PJ->DIR = 0xFF; } /*UART CLOCK SYSTEM*/ void uart_CSY(void){ CS->KEY = CS_KEY_VAL; /*UNLOCK CS MODULE REGISTER ACESS*/ CS->CTL0 = 0; /*RESET TUNING PARAMETERS*/ CS->CTL0 = CS_CTL0_DCORSEL_3; /*SET DCO TO 12MHz (NOMINAL, CENTER OF 8-16MHz RANGE)*/ CS->CTL1 = CS_CTL1_SELA_2 | /*SELECT ACLK = REFO*/ CS_CTL1_SELS_3 | /*SMCLK = DCO*/ CS_CTL1_SELM_3; /*MCLK = DCO*/ CS->KEY = 0; } void sendBlutoothByte(unsigned char byte){ while (!(EUSCI_A2->IFG & EUSCI_A_IFG_TXIFG)); /*EUSCI_A2 TX BUFFER READY?*/ EUSCI_A2->TXBUF = byte; /*TX -> RX CHARACTER*/ } void sendBlutoothString(unsigned char* string){ while(*string) sendBlutoothByte(*string++); /*ADVANCE THOUGH STRING TILL END*/ } /*UART INTERRUPT SERVICE ROUTINE */ void EUSCIA2_IRQHandler(void){ if (EUSCI_A2->IFG & EUSCI_A_IFG_RXIFG){ /*DETECT IF RX INTERRUPT WAS ACTIVATED*/ buffReceive = EUSCI_A2->RXBUF; printf("%d\n",buffReceive); } }
main.c
#include "msp.h" #include "main.h" #include <stdint.h> #include <stdbool.h> #include <stdio.h> #include <uart2.h> uint8_t btConnected, deviceConn; void main(void){ WatchDogHold(); confg_IO(); confg_uart_wire(); uart_CSY(); uart_init(); headersApp(); while(1){ } void headersApp(void){ sendBlutoothString("test\n"); } void WatchDogHold(void){ WDTCTL = WDTPW | WDTHOLD; /*STOP WATCHDOG TIMER*/ }
What could I be doing wrong?
Hi
I have solved the problem i have change the interrupt code:
/*UART INTERRUPT SERVICE ROUTINE */ void EUSCIA2_IRQHandler(void){ if (EUSCI_A2->IFG & EUSCI_A_IFG_RXIFG){ /*DETECT IF RX INTERRUPT WAS ACTIVATED*/ buffReceive = EUSCI_A2->RXBUF; stateOfBluetooth(state); } EUSCI_A2->IFG &= ~(EUSCI_A_IFG_RXIFG); }
**Attention** This is a public forum