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.

BOOSTXL-SENSORS: + red MSP432 board issues

Part Number: BOOSTXL-SENSORS

Hi team,

 

I am working with the red 432P launchpad and BOOSTXL-SENSORS I just received and seeing odds things. Using the latest ET-GUI from:

http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/BOOSTXL-SENSORS/latest/index_FDS.html

 

Launching the GUI, and programming it as per the users guide. Changed the baud on the GUI and Windows to 115200, used the GUI to successfully program the MCU, everything loaded fine. But the GUI always says “waiting for data”. There is nothing in the guide about needing button inputs but I started pressing them and it takes pressing S3 (which is reset?) for it to connect. Doing that allows it to connect. Still no sensor data is streaming. You have to press S3 again and you get a single momentary ping of sensor data for the accelerometer (no other sensors ever register). I have closed the GUI and unpluged/re plugged the launchpad and it’s the same. I have done nothing out of the ordinary, so I’m at a loss.

What do you suppose is going on?

 

Thanks,

Billy

  • Hello Billy,

    Let me check the same and see what the issue is. Some of the demo examples seem to be broken and I am working on debugging the same.
  • Thanks Amit!

    I’m confident you will find the same thing. When you do at least I’ll know its not just me :)

    Maybe there's another version of the binary/project/source somewhere internally before it was broken.
  • Hello Billy,

    I imported the application from the latest SDK in CCSv8, built and downloaded the firmware. After that I used the GUI to connect to read the data and it worked as expected and it has been running for the last 3 minutes without any issues. I can see the data change for the Ambient Light and Board Movement getting recorded.

    When i try to download the firmware using the GUI it fails to program though.
  • Hi Amit,

    The GUI programs it fine, I did so twice hoping it was just a bad load. You may have had a baud issue or port issue or something else. I did not know this exact same project existed in the SDK. I would have gone that route from the jump. I went this route with the BOOSTXL-SENSORS package for simplicity and because thats what a customer I was helping was following.

    So in the end if the SDK project works but the binary packaged in the GUI-ET here doesn’t, can you/someone replace the binary? I see the GUI is pulling that locally in the package from:

    \\BOOSTXL-SENSORS_GUI_ET\BOOSTXL-SENSORS_GUI+ET\target   ->  BOOSTXL-SENSORS_SensorGUI_MSP432P401R.out

    Thanks,

    Billy

  • Hello Billy,

    That is why I am trying to get the GUI to program the device, to see what the issue is. In case it is just the out file is incorrect or broken, then it is rather simple to fix it.
  • Hi Amit,

    Well you don't need to worry about comparing the binary's anymore, its not that.  I am beginning to think I have a bad sensor boosterpack. Its the exact same situation using the CCS project out of the SDK on this machine, Win 7/32 bit. Everything loads and programs just fine, drivers are fine, com ports fine, it connects but still no live data. I have to keep hitting the reset button and only get a 1 time ping of data each time I press it. And that’s just data from the 3 sensors on the right, see my screenshot. I've yet to see any other sensors become active.

    I then took it to my personal Win 10/64 bit, grabbed the GUI package, launched it and its identical. I have to keep pressing reset and just get a 1 time ping and only on those 3 sensors:

    What do you think? Bad boosterpack?

    Thanks,

    Billy

  • Hello Billy,

    Yes, it may be a bad booster pack. Since the booster pack communication is over I2C, you may want to connect a scope or LA probe to the SCL and SDA to see if the transactions are going through!
  • Hi BillyO,

    From what I know the GUI MSP430 Software example in this link is deprecated software-dl.ti.com/.../index_FDS.html

    Use the one at the most recent MSP430 SDK release.

    -kel
  • Hi Kel,

    Hm, I don’t think that’s right. Its directly linked in the latest users guide and I don’t see the GUI even in 432 SDK. Yes the project source in the 432 SDK appears to be a complete clone of the BOOSTXL-SENSORS package, but there is not a GUI.

    In other words you have no choice but to get the BOOSTXL-SENSORS package to obtain the GUI.

    Thanks,
    Billy
  • Hi BillyO,

    I encountered your problem before. TI Engineer told me that MSP430 Sensors GUI Example Program in this link is deprecated software-dl.ti.com/.../index_FDS.html

    So you flash your MSP430 LP with the hex or bin file from "C:\ti\simplelink_msp432p4_sdk_1_60_00_12\examples\nortos\MSP_EXP432P401R\demos\boostxl_sensors_sensorgui_msp432p401r"

    Then use the GUI software only at software-dl.ti.com/.../index_FDS.html

    Maybe you can re-confirm this within TI.

    -kel
  • Hi Kel,

    We think alike :) Yes I did exactly that yesterday (2 posts above). The source project built from CCS, or loaded from the GUI is the same result (for me). I went another step further and did it on my personal Win 10 machine (previously on a Win 7).

    Like I said 2 posts ago I’m confident now that I have a bad boosterpack. You have to constantly press reset over and over to get a single ping of readings and even then, only 3 sensors report. This is with the binary loaded from the GUI, OR being built via the CCS source in the SDK.

    Thanks,
    Billy
  • Okay. But, to be more sure that your BP is bad, try at another Launchpad. You can get code at Sensors Actuator Plugin SDK to test each sensor.

    -kel
  • Hello Billy,

    After debug we did determine that the TMP007 is not populated on the new boards as it has been OBSOLETE. The suggested workaround is to comment the code that initializes the TMP007 and reads data from it. We will file a software change request so that it can be made customizable based on the new board. Also attached is the code for the same, in case other forum users run into the same issue.

    I will close the forum post in case there are no further issues.

    //*****************************************************************************
    //
    // Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
    //
    // 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.
    //
    // MSP432 Low Power main.c
    //
    // 		Description: Source code for the implementation of the Bosch BoosterPack with
    // 		an MSP432P401R launchpad for low power consumption. BoosterPack includes:
    // 		- Inertial Measurement Unit (IMU) sensor with an accelerometer and gyroscope
    // 		- Magnetometer
    // 		- Environmental sensor with pressure, ambient temperature and humidity
    // 		- Ambient light sensor
    // 		- Infrared temperature sensor
    //
    // Adapted by Michael Arriete
    //
    //****************************************************************************
    #include <stdbool.h>
    #include <stdint.h>
    #include <string.h>
    #include <ti/devices/msp432p4xx/inc/msp432.h>
    #include "stdio.h"
    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>
    #include "i2c_driver.h"
    #include "demo_sysctl.h"
    #include "bmi160_support.h"
    #include "bme280_support.h"
    #include "tmp007.h"
    #include "opt3001.h"
    #include "uart_driver.h"
    
    //***** Definitions *****
    #define CPU_FREQ                    (48000000)
    #define USING_BOSCH_BP
    #define SAMPLE_TIME_1				(53)
    #define SAMPLE_TIME_2				(26)
    #define SAMPLE_TIME_4				(13)
    #define SAMPLE_TIME_6				(8)
    #define SAMPLE_TIME_8				(6)
    #define SAMPLE_TIME_10				(5)
    #define NUM_AVGR_SUMS				2 //x^2 frames
    
    //***** Function Prototypes *****
    void startCrystalOscillator(void);
    void setSystemClock(uint32_t CPU_Frequency);
    void configureGPIO(void);
    void startWakeUpTimerA(uint16_t ulClockMS);
    void stopWakeUpTimerA(void);
    int32_t movingAvg(int prevAvg, int16_t newValue);
    
    
    //***** 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,
    };
    
    const uint8_t timeSamplesBMI [6] = {
    		SAMPLE_TIME_1, 		//Sample at 1 time per second
    		SAMPLE_TIME_2, 		//Sample at 2 times per second
    		SAMPLE_TIME_4, 		//Sample at 4 times per second
    		SAMPLE_TIME_6, 		//Sample at 6 times per second
    		SAMPLE_TIME_8, 		//Sample at 8 times per second
    		SAMPLE_TIME_10, 	//Sample at 10 times per second
    };
    
    const uint8_t timeSamplesBMM [6] = {
    		SAMPLE_TIME_1, 		//Sample at 1 time per second
    		SAMPLE_TIME_2, 		//Sample at 2 times per second
    		SAMPLE_TIME_4, 		//Sample at 4 times per second
    		SAMPLE_TIME_6, 		//Sample at 6 times per second
    		SAMPLE_TIME_8, 		//Sample at 8 times per second
    		SAMPLE_TIME_10, 	//Sample at 10 times per second
    };
    
    const uint8_t timeSamplesBME [6] = {
    		SAMPLE_TIME_1, 		//Sample at 1 time per second
    		SAMPLE_TIME_2, 		//Sample at 2 times per second
    		SAMPLE_TIME_4, 		//Sample at 4 times per second
    		SAMPLE_TIME_6, 		//Sample at 6 times per second
    		SAMPLE_TIME_8, 		//Sample at 8 times per second
    		SAMPLE_TIME_10, 	//Sample at 10 times per second
    };
    
    const uint8_t timeSamplesTMP [6] = {
    		SAMPLE_TIME_1, 		//Sample at 1 time per second
    		SAMPLE_TIME_2, 		//Sample at 2 times per second
    		SAMPLE_TIME_4, 		//Sample at 4 times per second
    		SAMPLE_TIME_6, 		//Sample at 6 times per second
    		SAMPLE_TIME_8, 		//Sample at 8 times per second
    		SAMPLE_TIME_10, 	//Sample at 10 times per second
    };
    
    const uint8_t timeSamplesOPT [6] = {
    		SAMPLE_TIME_1, 		//Sample at 1 time per second
    		SAMPLE_TIME_2, 		//Sample at 2 times per second
    		SAMPLE_TIME_4, 		//Sample at 4 times per second
    		SAMPLE_TIME_6, 		//Sample at 6 times per second
    		SAMPLE_TIME_8, 		//Sample at 8 times per second
    		SAMPLE_TIME_10, 	//Sample at 10 times per second
    };
    
    //Default time sample values for each sensor
    volatile uint8_t sampleTimePeriodBMI = 2;
    volatile uint8_t sampleTimePeriodBMM = 5;
    volatile uint8_t sampleTimePeriodBME = 0;
    volatile uint8_t sampleTimePeriodTMP = 0;
    volatile uint8_t sampleTimePeriodOPT = 0;
    
    // Changed by the GUI -  default ~ 0.0156 seconds  1/32KHz * WDT_A_CLOCKDIVIDER_512
    volatile uint8_t wdtWakeUpPeriodIndex = 6;
    
    // BMI160/BMM150
    BMI160_RETURN_FUNCTION_TYPE returnValue;
    struct bmi160_gyro_t        s_gyroXYZ;
    struct bmi160_accel_t       s_accelXYZ;
    struct bmi160_mag_xyz_s32_t s_magcompXYZ;
    
    // BME280 
    s32 returnRslt;
    s32 g_s32ActualTemp   = 0;
    u32 g_u32ActualPress  = 0;
    u32 g_u32ActualHumity = 0;
    
    // OPT3001
    uint16_t rawData;
    float    convertedLux;
    
    // TMP007
    uint16_t rawTemp;
    uint16_t rawObjTemp;
    float    tObjTemp;
    float    tObjAmb;
    
    //Timer Counter
    uint16_t WDTcount = 0;
    
    //Receive UART Variables
    #define NUM_RX_CHARS 64
    char rxMsgData[NUM_RX_CHARS] = "";
    int numMsgsRx = 0;
    int tempIndex = 5;
    int numChars = 0;
    
    //Calibration off-sets
    int8_t accel_off_x;
    int8_t accel_off_y;
    int8_t accel_off_z;
    s16 gyro_off_x;
    s16 gyro_off_y;
    s16 gyro_off_z;
    
    //gesture recognition
    int getGestures = 1;
    int dominant = 0;
    uint16_t gyroAbsX, gyroAbsY, gyroAbsZ;
    uint16_t deltaAccelX, deltaAccelY, deltaAccelZ;
    int16_t prevAccelX = 0;
    int16_t prevAccelY = 0;
    int16_t prevAccelZ = 0;
    int16_t prevGyroX = 0;
    int16_t prevGyroY = 0;
    int16_t prevGyroZ = 0;
    int16_t stillCount = 0;
    int32_t gyroAvgX = 0.0;
    int32_t gyroAvgY = 0.0;
    int32_t gyroAvgZ = 0.0;
    int32_t accelAvgX = 0.0;
    int32_t accelAvgY = 0.0;
    int32_t accelAvgZ = 0.0;
    
    //Sensor Status Variables
    bool BME_on = true;
    bool BMI_on = true;
    bool TMP_on = true;
    bool OPT_on = true;
    
    
    /***********************************************************
      Function:
     */
    int main(void)
    {
    	volatile uint32_t index;
    
    	// Stop WDT and disabling master interrupts
    	MAP_WDT_A_holdTimer();
    	MAP_Interrupt_disableMaster();
    
    	// Enabling SRAM Bank Retention
    	SYSCTL->SRAM_BANKRET |= SYSCTL_SRAM_BANKEN_BNK7_EN;
    	for (index = 0;index < 100;index++);
    
    #ifdef USE_LPM	
    	// Configure I/O to minimize power consumption
    	configureGPIO();
    
    	// Turn off PSS high-side & low-side supervisors to minimize power consumption
    	MAP_PSS_disableLowSide();
    	MAP_PSS_disableHighSide();
    #endif
    
    	// Configure clocks
    	startCrystalOscillator();
    	setSystemClock(CPU_FREQ);
    
    #ifdef USING_BOSCH_BP
    	//Initialize uart
    	uartInit();
    
    	// Initialize i2c
    	initI2C();
    
    #endif	
    
    	MAP_Interrupt_enableMaster();
    
    #ifdef USING_BOSCH_BP	
    	// Initialize bmi160 sensor
    	bmi160_initialize_sensor();
    	returnRslt = bmi160_config_running_mode(APPLICATION_NAVIGATION);
    	bmi160_accel_foc_trigger_xyz(0x03, 0x03, 0x01, &accel_off_x, &accel_off_y, &accel_off_z);
    	bmi160_set_foc_gyro_enable(0x01, &gyro_off_x, &gyro_off_y, &gyro_off_z);
    
    	// Initialize bme280 sensor
    	bme280_data_readout_template();
    	returnRslt = bme280_set_power_mode(BME280_SLEEP_MODE);
    
    	//Initialize opt3001 sensor
    	sensorOpt3001Init();
    
    	//Initialize tmp007 sensor
    	//sensorTmp007Init();
    #endif
    
    	//Enable TMP, OPT, and BME sensors
    	sensorTmp007Enable(true);
    	sensorOpt3001Enable(true);
    	returnRslt = bme280_set_power_mode(BME280_NORMAL_MODE);
    
    	// Using the wdt as interval timer to wake up from LPM3
    	while(1)
    	{
    		// Stop WDT
    		MAP_WDT_A_holdTimer();
    		MAP_WDT_A_clearTimer();
    		MAP_Interrupt_disableInterrupt(INT_WDT_A);
    
    		//Set frequency back to full speed if reading/converting data
    		if((WDTcount%timeSamplesBME[sampleTimePeriodBME] == 0) ||
    				(WDTcount%timeSamplesBMM[sampleTimePeriodBMM] == 0) ||
    				(WDTcount%timeSamplesBMI[sampleTimePeriodBMI] == 0) ||
    				//(WDTcount%timeSamplesTMP[sampleTimePeriodTMP] == 0) ||
    				(WDTcount%timeSamplesOPT[sampleTimePeriodOPT] == 0) ||
    				(WDTcount == 53))
    		{
    			if (getGestures)
    			{
    
    				gyroAbsX = abs(s_gyroXYZ.x);
    				gyroAbsY = abs(s_gyroXYZ.y);
    				gyroAbsZ = abs(s_gyroXYZ.z);
    
    				gyroAvgX = movingAvg(gyroAvgX, gyroAbsX );
    				gyroAvgY = movingAvg(gyroAvgY, gyroAbsY );
    				gyroAvgZ = movingAvg(gyroAvgZ, gyroAbsZ );
    
    
    
    				if( gyroAvgX > 1000 || gyroAvgY > 1000 || gyroAvgZ > 1000 )
    				{
    					stillCount = 0;
    					if ( gyroAvgY > gyroAvgX )
    					{
    						if ( gyroAvgY > gyroAvgZ )
    						{
    							dominant = 2; //gyro Y
    						}
    						else
    						{
    							dominant = 3; //gyro Z
    						}
    
    					}
    					else if ( gyroAvgZ > gyroAvgX )
    					{
    						dominant = 3; //gyro Z
    					}
    					else
    					{
    						dominant = 1; //gyro X
    					}
    				}
    				else{
    
    					deltaAccelX = abs(s_accelXYZ.x - prevAccelX);
    					deltaAccelY = abs(s_accelXYZ.y - prevAccelY);
    					deltaAccelZ = abs(s_accelXYZ.z - prevAccelZ);
    
    					accelAvgX = movingAvg(accelAvgX, deltaAccelX);
    					accelAvgY = movingAvg(accelAvgY, deltaAccelY);
    					accelAvgZ = movingAvg(accelAvgZ, deltaAccelZ);
    
    
    					if ( accelAvgX > 100 || accelAvgY > 100 || accelAvgZ > 100 )
    					{
    						stillCount = 0;
    
    						if ( accelAvgY > accelAvgX )
    						{
    							if ( accelAvgY > accelAvgZ )
    							{
    								dominant = 5; //accel Y
    							}
    							else
    							{
    								dominant = 6; //accel Z
    							}
    
    						}
    						else if ( accelAvgZ > accelAvgX )
    						{
    							dominant = 6; //accel Z
    						}
    						else
    						{
    							dominant = 4; //accel X
    						}
    
    					}
    					else{
    						stillCount++;
    						if (stillCount>3)
    						{
    							dominant = 0; //still condition
    						}
    
    					}
    
    				}
    //				//contrsuct JSON string for GUI
    //				snprintf(test.txString, 30,
    //						"{\"dominant\":{\"code\":%d}}\n",
    //						dominant);
    //
    //				//Send UART data JSON string
    //				sendText();
    
    				prevAccelX = s_accelXYZ.x;
    				prevAccelY = s_accelXYZ.y;
    				prevAccelZ = s_accelXYZ.z;
    			}
    		}
    
    		//Mag update frequency
    		if (WDTcount%timeSamplesBMM[sampleTimePeriodBMM] == 0)
    		{
    			if(BMI_on)
    			{
    				//Read Mag value (BMM) through BMI
    				returnValue = bmi160_bmm150_mag_compensate_xyz(&s_magcompXYZ);
    
    				//contrsuct JSON string for BMM
    				snprintf(test.txString, 60,
    						"{\"mag\":{\"x\":%d,\"y\":%d,\"z\":%d}}\n",
    						s_magcompXYZ.x, s_magcompXYZ.y, s_magcompXYZ.z);
    
    				//Send UART data JSON string
    				sendText();
    			}
    		}
    		//Accel and Gyro update frequency
    		if (WDTcount%timeSamplesBMI[sampleTimePeriodBMI] == 0)
    		{
    			if(BMI_on)
    			{
    				//Read Accel and Gyro values
    				returnValue = bmi160_read_accel_xyz(&s_accelXYZ);
    				returnValue = bmi160_read_gyro_xyz(&s_gyroXYZ);
    
    				//contrsuct JSON string for BMI
    				snprintf(test.txString, 120,
    						"{\"dominant\":{\"code\":%d},"
    						"\"gyro\":{\"x\":%d,\"y\":%d,\"z\":%d},"
    						"\"accel\":{\"x\":%d,\"y\":%d,\"z\":%d}}\n",
    						dominant,
    						s_gyroXYZ.x, s_gyroXYZ.y, s_gyroXYZ.z,
    						s_accelXYZ.x, s_accelXYZ.y, s_accelXYZ.z);
    
    				//Send UART data JSON string
    				sendText();
    			}
    		}
    		//**Will need to separate each sensor into own if statements to allow GUI to change each sensor's sampling rates
    		//TMP update frequency
    #if 0
    		if (WDTcount%timeSamplesTMP[sampleTimePeriodTMP] == 0)
    		{
    			if(TMP_on)
    			{
    				// Read/convert tmp007 and opt3001 data
    				sensorTmp007Read(&rawTemp, &rawObjTemp);
    				sensorTmp007Convert(rawTemp, rawObjTemp, &tObjTemp, &tObjAmb);
    
    				//contrsuct JSON string for TMP
    				snprintf(test.txString, 60,
    						"{\"ir_temp\":{\"obj_temp\":%5.2f}}\n",
    						tObjTemp);
    
    				//Send UART data JSON string
    				sendText();
    			}
    		}
    #endif
    		//OPT update frequency
    		if (WDTcount%timeSamplesOPT[sampleTimePeriodOPT] == 0) {
    			if(OPT_on)
    			{
    				//Read and convert OPT values
    				sensorOpt3001Read(&rawData);
    				sensorOpt3001Convert(rawData, &convertedLux);
    
    				//contrsuct JSON string for OPT
    				snprintf(test.txString, 60,
    						"{\"light\":{\"lux\":%5.2f}}\n",
    						convertedLux);
    
    				//Send UART data JSON string
    				sendText();
    			}
    		}
    		//BME update frequency
    		if (WDTcount%timeSamplesBME[sampleTimePeriodBME] == 0) {
    			if(BME_on)
    			{
    				//Read BME environmental data
    				returnRslt = bme280_read_pressure_temperature_humidity(
    						&g_u32ActualPress, &g_s32ActualTemp, &g_u32ActualHumity);
    
    				//contrsuct JSON string for BME
    				snprintf(test.txString, 60,
    						"{\"enviro\":{\"humid\":%d,\"press\":%d,\"amb_temp\":%d}}\n",
    						g_u32ActualHumity, g_u32ActualPress, g_s32ActualTemp);
    
    				//Send UART data JSON string
    				sendText();
    			}
    		}
    		//Reset WDTcount when max count has been reached
    		if (WDTcount == 53) {
    			//Reset WDT counter after reaching roughly one second
    			WDTcount = 0;
    		}
    		WDTcount++;
    
    		// Check to see if there is any message from the host
    		if (receiveText(rxMsgData,NUM_RX_CHARS)){
    			numMsgsRx++;
    			numChars = strlen(rxMsgData);
    
    			//Parses through UART received data and changes sampling rates and on/off statuses accordingly
    			if (numChars > 6) {
    				switch(rxMsgData[2]){
    				case 's':  // e.g. {"s":10} or {"s":8} or {"s":4) to set sampling rates of 10Hz, 8Hz or 4Hz
    					switch(rxMsgData[3]){
    					case 'i':
    						tempIndex = 6;
    						if (rxMsgData[tempIndex] == '"'){
    							tempIndex = 7;  // this accommodates values that have been converted to strings
    						}
    						switch (rxMsgData[tempIndex]){
    						case '0':
    							sampleTimePeriodBMI = 0;
    							break;
    						case '1':
    							sampleTimePeriodBMI = 1;
    							break;
    						case '2':
    							sampleTimePeriodBMI = 2;
    							break;
    						case '3':
    							sampleTimePeriodBMI = 3;
    							break;
    						case '4':
    							sampleTimePeriodBMI = 4;
    							break;
    						case '5':
    							sampleTimePeriodBMI = 5;
    							break;
    						default:
    							break;
    						}
    						break;
    						case 'm':
    							tempIndex = 6;
    							if (rxMsgData[tempIndex] == '"'){
    								tempIndex = 7;
    							}
    							switch (rxMsgData[tempIndex]){
    							case '0':
    								sampleTimePeriodBMM = 0;
    								break;
    							case '1':
    								sampleTimePeriodBMM = 1;
    								break;
    							case '2':
    								sampleTimePeriodBMM = 2;
    								break;
    							case '3':
    								sampleTimePeriodBMM = 3;
    								break;
    							case '4':
    								sampleTimePeriodBMM = 4;
    								break;
    							case '5':
    								sampleTimePeriodBMM = 5;
    								break;
    							default:
    								break;
    							}
    							break;
    							case 't':
    								tempIndex = 6;
    								if (rxMsgData[tempIndex] == '"'){
    									tempIndex = 7;
    								}
    								switch (rxMsgData[tempIndex]){
    								case '0':
    									sampleTimePeriodTMP = 0;
    									break;
    								case '1':
    									sampleTimePeriodTMP = 1;
    									break;
    								case '2':
    									sampleTimePeriodTMP = 2;
    									break;
    								case '3':
    									sampleTimePeriodTMP = 3;
    									break;
    								case '4':
    									sampleTimePeriodTMP = 4;
    									break;
    								case '5':
    									sampleTimePeriodTMP = 5;
    									break;
    								default:
    									break;
    								}
    								break;
    								case 'o':
    									tempIndex = 6;
    									if (rxMsgData[tempIndex] == '"'){
    										tempIndex = 7;
    									}
    									switch (rxMsgData[tempIndex]){
    									case '0':
    										sampleTimePeriodOPT = 0;
    										break;
    									case '1':
    										sampleTimePeriodOPT = 1;
    										break;
    									case '2':
    										sampleTimePeriodOPT = 2;
    										break;
    									case '3':
    										sampleTimePeriodOPT = 3;
    										break;
    									case '4':
    										sampleTimePeriodOPT = 4;
    										break;
    									case '5':
    										sampleTimePeriodOPT = 5;
    										break;
    									default:
    										break;
    									}
    									break;
    									case 'e':
    										tempIndex = 6;
    										if (rxMsgData[tempIndex] == '"'){
    											tempIndex = 7;
    										}
    										switch (rxMsgData[tempIndex]){
    										case '0':
    											sampleTimePeriodBME = 0;
    											break;
    										case '1':
    											sampleTimePeriodBME = 1;
    											break;
    										case '2':
    											sampleTimePeriodBME = 2;
    											break;
    										case '3':
    											sampleTimePeriodBME = 3;
    											break;
    										case '4':
    											sampleTimePeriodBME = 4;
    											break;
    										case '5':
    											sampleTimePeriodBME = 5;
    											break;
    										default:
    											break;
    										}
    										break;
    
    					}
    					break;
    					case 'i': //e.g.: {"i":0} or {"i":1}
    						if (rxMsgData[5] == '1'){
    							returnRslt = bmi160_config_running_mode(APPLICATION_NAVIGATION);
    							BMI_on = true;
    						} else {
    							returnRslt = bmi160_config_running_mode(ACCEL_PEDOMETER);
    							BMI_on = false;
    						}
    						break;
    					case 't': //e.g.: {"t":0} or {"t":1}
    						if (rxMsgData[5] == '1'){
    							sensorTmp007Enable(true);
    							TMP_on = true;
    						} else {
    							sensorTmp007Enable(false);
    							TMP_on = false;
    						}
    						break;
    					case 'o': //e.g.: {"o":0} or {"o":1}
    						if (rxMsgData[5] == '1'){
    							sensorOpt3001Enable(true);
    							OPT_on = true;
    						} else {
    							sensorOpt3001Enable(false);
    							OPT_on = false;
    						}
    						break;
    					case 'e': //e.g.: {"e":0} or {"e":1}
    						if (rxMsgData[5] == '1'){
    							returnRslt = bme280_set_power_mode(BME280_NORMAL_MODE);
    							BME_on = true;
    						} else {
    							returnRslt = bme280_set_power_mode(BME280_SLEEP_MODE);
    							BME_on = false;
    						}
    						break;
    					case 'r':
    						if (rxMsgData[5] == '1'){
    							getGestures = 1;
    						} else {
    							getGestures = 0;
    							dominant = 0;
    						}
    						break;
    				}
    			}
    		}
    		// Configure WDT
    		// For LPM3 Clock Source should be BCLK or VLOCLK
    		MAP_WDT_A_initIntervalTimer(WDT_A_CLOCKSOURCE_BCLK/*WDT_A_CLOCKSOURCE_ACLK*/,
    				wdtWakeUpPeriod[wdtWakeUpPeriodIndex]);
    		MAP_Interrupt_enableInterrupt(INT_WDT_A);
    
    		// Start WDT
    		MAP_WDT_A_startTimer();
    
    		//Go to LPM0 (Cannot use LPM3 because we won't accurately receive UART data)
    		MAP_PCM_gotoLPM0();
    	}
    }
    
    /***********************************************************
      Funtion:
    
       Works as a simple moving averager. Used for gesture recognition.
    
     */
    int32_t movingAvg(int prevAvg, int16_t newValue)
    {
    	return (((prevAvg << NUM_AVGR_SUMS) + newValue - prevAvg) >> NUM_AVGR_SUMS);
    
    
    
    }
    
    /***********************************************************
      Function:
    
       The following function is responsible for starting XT1 in the
       MSP432 that is used to source the internal FLL that drives the
       MCLK and SMCLK.
     */
    void startCrystalOscillator(void)
    {
    	/* Configuring pins for peripheral/crystal HFXT*/
    	MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ,
    			GPIO_PIN3 | GPIO_PIN4, GPIO_PRIMARY_MODULE_FUNCTION);
    
    	/* Configuring pins for peripheral/crystal LFXT*/
    	MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ,
    			GPIO_PIN0 | GPIO_PIN1, GPIO_PRIMARY_MODULE_FUNCTION);
    }
    
    /***********************************************************
      Function:
    
       The following function is responsible for setting up the system
       clock at a specified frequency.
     */
    void setSystemClock(uint32_t CPU_Frequency)
    {
        /* Setting the external clock frequency. This API is optional, but will
        * come in handy if the user ever wants to use the getMCLK/getACLK/etc
        * functions
        */
        MAP_CS_setExternalClockSourceFrequency(32768, CPU_Frequency);
    	MAP_CS_setReferenceOscillatorFrequency(CS_REFO_32KHZ);
    
        /* Before we start we have to change VCORE to 1 to support the 24MHz frequency */
        MAP_PCM_setCoreVoltageLevel(PCM_AM_LDO_VCORE0);
        MAP_FlashCtl_setWaitState(FLASH_BANK0, 1);
        MAP_FlashCtl_setWaitState(FLASH_BANK1, 1);
    
        /* Starting HFXT and LFXT in non-bypass mode without a timeout. */
        MAP_CS_startHFXT(false);
        MAP_CS_startLFXT(false);
    
        /* Initializing the clock source as follows:
        *      MCLK = HFXT/2 = 24MHz
        *      ACLK = LFXT = 32KHz
        *      HSMCLK = HFXT/4 = 6MHz
        *      SMCLK = HFXT/2 = 12MHz
        *      BCLK  = REFO = 32kHz
        */
        MAP_CS_initClockSignal(CS_MCLK, CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_2);
        MAP_CS_initClockSignal(CS_ACLK, CS_LFXTCLK_SELECT, CS_CLOCK_DIVIDER_1);
        MAP_CS_initClockSignal(CS_HSMCLK, CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_8);
        MAP_CS_initClockSignal(CS_SMCLK, CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_4);
        MAP_CS_initClockSignal(CS_BCLK, CS_REFOCLK_SELECT, CS_CLOCK_DIVIDER_1);
    }
    
    /***********************************************************
      Function:
     */
    void configureGPIO(void)
    {
    	/* Configure I/O to minimize power consumption before going to sleep */
    	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P1, PIN_ALL8);
    	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P2, PIN_ALL8);
    	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P3, PIN_ALL8);
    	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P4, PIN_ALL8);
    	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P5, PIN_ALL8);
    	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P6, PIN_ALL8);
    	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P7, PIN_ALL8);
    	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P8, PIN_ALL8);
    	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P9, PIN_ALL8);
    	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P10, PIN_ALL8);
    	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PJ, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3);
    	MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, PIN_ALL8);
    	MAP_GPIO_setAsOutputPin(GPIO_PORT_P2, PIN_ALL8);
    	MAP_GPIO_setAsOutputPin(GPIO_PORT_P3, (PIN_ALL8 & ~GPIO_PIN6));
    	MAP_GPIO_setAsOutputPin(GPIO_PORT_P4, (PIN_ALL8 & ~(GPIO_PIN1 | GPIO_PIN6)));
    	MAP_GPIO_setAsOutputPin(GPIO_PORT_P5, (PIN_ALL8 & ~(GPIO_PIN0 | GPIO_PIN2)));
    	MAP_GPIO_setAsOutputPin(GPIO_PORT_P6, (PIN_ALL8 & ~GPIO_PIN7));
    	MAP_GPIO_setAsOutputPin(GPIO_PORT_P7, PIN_ALL8);
    	MAP_GPIO_setAsOutputPin(GPIO_PORT_P8, PIN_ALL8);
    	MAP_GPIO_setAsOutputPin(GPIO_PORT_P9, PIN_ALL8);
    	MAP_GPIO_setAsOutputPin(GPIO_PORT_P10, PIN_ALL8);
    	MAP_GPIO_setAsOutputPin(GPIO_PORT_PJ, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3);
    }
    
    /***********************************************************
      Function:
     */
    void startWakeUpTimerA(uint16_t ulClockMS)
    {
    	ulClockMS = (ulClockMS * 32768)/1000;
    
    	/* TimerA UpMode Configuration Parameter */
    	Timer_A_UpModeConfig upConfig =
    	{
    			TIMER_A_CLOCKSOURCE_ACLK,              // ACLK Clock Source
    			TIMER_A_CLOCKSOURCE_DIVIDER_1,         // ACLK/1 = 32KHz
    			ulClockMS,                             // tick period
    			TIMER_A_TAIE_INTERRUPT_DISABLE,        // Disable Timer interrupt
    			TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE ,   // Enable CCR0 interrupt
    			TIMER_A_SKIP_CLEAR                     // Clear value
    	};
    
    	MAP_Timer_A_configureUpMode(TIMER_A0_BASE, &upConfig);
    	MAP_Timer_A_enableCaptureCompareInterrupt(TIMER_A0_BASE,
    			TIMER_A_CAPTURECOMPARE_REGISTER_0);
    
    	MAP_Interrupt_enableInterrupt(INT_TA0_0);
    	MAP_Timer_A_startCounter(TIMER_A0_BASE,TIMER_A_UP_MODE);
    }
    
    /***********************************************************
      Function:
     */
    void stopWakeUpTimerA(void)
    {
    	MAP_Interrupt_disableInterrupt(INT_TA0_0);
    	MAP_Timer_A_stopTimer(TIMER_A0_BASE);
    }
    
    /***********************************************************
      Function: TA0_0_IRQHandler
     */
    void TA0_0_IRQHandler(void)
    {
    	MAP_Timer_A_clearCaptureCompareInterrupt(TIMER_A0_BASE,
    			TIMER_A_CAPTURECOMPARE_REGISTER_0);
    
    #ifdef USE_LPM
    	MAP_Interrupt_disableSleepOnIsrExit();
    #endif
    }
    
    /***********************************************************
      Function: WDT_A_IRQHandler
     */
    void WDT_A_IRQHandler(void)
    {
    	//MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
    	// Waking up from LMP3 take us to PCM_AM_LDO_VCORE0 instead of PCM_AM_LF_VCORE0
    //	MAP_PCM_setPowerState(PCM_AM_LDO_VCORE0);
    //    MAP_PCM_setCoreVoltageLevel(PCM_AM_DCDC_VCORE0);
    
    #ifdef USE_LPM    
    	MAP_Interrupt_disableSleepOnIsrExit();
    #endif    
    }
    
    /***********************************************************
      Function: PORT1_IRQHandler
     */
    void PORT1_IRQHandler(void)
    {
    	uint32_t debounce;
    	uint32_t status;
    
    	MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
    
    	status = MAP_GPIO_getEnabledInterruptStatus(GPIO_PORT_P1);
    
    	if(status & GPIO_PIN1)
    	{
    	}
    
    	/* Delay for switch debounce */
    	for(debounce = 0; debounce < 10000; debounce++)
    		MAP_GPIO_clearInterruptFlag(GPIO_PORT_P1, status);
    
    #ifdef USE_LPM    
    	MAP_Interrupt_disableSleepOnIsrExit();
    #endif
    }
    
    /***********************************************************
      Function: PORT5_IRQHandler
     */
    void PORT5_IRQHandler(void)
    {
    	uint32_t status;
    
    	status = MAP_GPIO_getEnabledInterruptStatus(GPIO_PORT_P5);
    
    	MAP_GPIO_disableInterrupt(GPIO_PORT_P5, GPIO_PIN2);
    	MAP_Interrupt_disableInterrupt(INT_PORT5);
    
    	if(status & GPIO_PIN2)
    	{
    	}
    
    	/* Delay for switch debounce */
    	MAP_GPIO_clearInterruptFlag(GPIO_PORT_P5, status);
    
    #ifdef USE_LPM
    	MAP_Interrupt_disableSleepOnIsrExit();
    #endif
    }
    
    /***********************************************************
      Function: _system_pre_init
     */
    int _system_pre_init(void)
    {
    	// stop WDT
    	MAP_WDT_A_holdTimer();                        // Hold watchdog timer
    
    	// Perform C/C++ global data initialization
    	return 1;
    }
    

  • Thanks for all of the help confirming this with me Amit!

    -Billy

**Attention** This is a public forum