Never mind, I figured it out, I have this line on when configure the interrupt. MAP_Interrupt_enableSleepOnIsrExit(); Therefore, It went sleep right after interrupt. Thanks all for the help, Below is my working code., Eddy /* * ------------------------------------------- * MSP432 DriverLib - v3_21_00_05 * ------------------------------------------- * * --COPYRIGHT--,BSD,BSD * Copyright (c) 2016, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * --/COPYRIGHT--*/ /****************************************************************************** * MSP432 UART - PC Echo with 12MHz BRCLK * * Description: This demo echoes back characters received via a PC serial port. * SMCLK/DCO is used as a clock source and the device is put in LPM0 * The auto-clock enable feature is used by the eUSCI and SMCLK is turned off * when the UART is idle and turned on when a receive edge is detected. * Note that level shifter hardware is needed to shift between RS232 and MSP * voltage levels. * * MSP432P401 * ----------------- * | | * | | * | | * RST -| P1.3/UCA0TXD|----> PC (echo) * | | * | | * | P1.2/UCA0RXD| //#include "printf.h" #include #include "msp.h" #include #include #include #include #include #include //#include /* 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 */ //***** Global Data ***** const uint8_t wdtWakeUpPeriod [8] = { WDT_A_CLOCKDIVIDER_2G, WDT_A_CLOCKDIVIDER_128M, WDT_A_CLOCKDIVIDER_8192K, WDT_A_CLOCKDIVIDER_512K, WDT_A_CLOCKDIVIDER_32K, WDT_A_CLOCKDIVIDER_8192, WDT_A_CLOCKDIVIDER_512, WDT_A_CLOCKDIVIDER_64, }; // Changed by the GUI - default ~ 0.0156 seconds 1/32KHz * WDT_A_CLOCKDIVIDER_512 volatile uint8_t wdtWakeUpPeriodIndex = 6; //Timer Counter uint16_t WDTcount = 0; const eUSCI_UART_Config uartConfig = { EUSCI_A_UART_CLOCKSOURCE_SMCLK, // SMCLK Clock Source 78, // BRDIV = 78 2, // UCxBRF = 2 0, // UCxBRS = 0 EUSCI_A_UART_NO_PARITY, // No Parity EUSCI_A_UART_LSB_FIRST, // LSB First EUSCI_A_UART_ONE_STOP_BIT, // One stop bit EUSCI_A_UART_MODE, // UART mode EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION // Oversampling }; /* Graphic library context */ //Receive UART Variables #define NUM_RX_CHARS 64 char rxMsgData[NUM_RX_CHARS] = ""; int numMsgsRx = 0; int tempIndex = 5; int numChars = 0; #define MAX_STR_LENGTH 271 uint8_t rx_buffer[1024]; uint16_t bufferIndex = 0; #define FALSE 0 #define TRUE 1 typedef struct{ unsigned char newStringReceived; char txString[MAX_STR_LENGTH]; char rxString[MAX_STR_LENGTH]; }s_test; extern s_test test; s_test test = { FALSE, "", "" }; /* Variable for storing lux value returned from OPT3001 */ float lux; /* Timer_A Up Configuration Parameter */ const Timer_A_UpModeConfig upConfig = { TIMER_A_CLOCKSOURCE_ACLK, // ACLK Clock SOurce TIMER_A_CLOCKSOURCE_DIVIDER_1, // ACLK/1 = 3MHz 200, // 200 tick period TIMER_A_TAIE_INTERRUPT_DISABLE, // Disable Timer interrupt TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE, // Disable CCR0 interrupt TIMER_A_DO_CLEAR // Clear value }; /* Timer_A Compare Configuration Parameter (PWM) */ Timer_A_CompareModeConfig compareConfig_PWM = { TIMER_A_CAPTURECOMPARE_REGISTER_3, // Use CCR3 TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE, // Disable CCR interrupt TIMER_A_OUTPUTMODE_TOGGLE_SET, // Toggle output but 100 // 50% Duty Cycle }; bool receiveText(char* data, int maxNumChars){ bool result = false; if(test.newStringReceived == TRUE){ result = true; strncpy(data,test.rxString,maxNumChars); test.newStringReceived = FALSE; } return result; } void sendText(){ unsigned int i; for (i = 0; i = MAX_STR_LENGTH){ rxInProgress = FALSE; }else{ pieceOfString[charCnt++] = data; //charCnt++; } } } } void EUSCIA0_IRQHandler(void) { uint32_t status = MAP_UART_getEnabledInterruptStatus(EUSCI_A0_BASE); //char receiveByte = UCA0RXBUF; //This is the address where the received byte is stored //int receiveByte_2 = 0x10; //uartReceive(data); //MAP_UART_clearInterruptFlag(EUSCI_A0_BASE, status); if(status & EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG) { char data = UCA0RXBUF; //RXBUF0; uartReceive(data); //rx_buffer[bufferIndex] = UCA0RXBUF; //bufferIndex++; __no_operation(); //MAP_UART_transmitData(EUSCI_A0_BASE, receiveByte); } MAP_UART_clearInterruptFlag(EUSCI_A0_BASE, status); }
↧