Tool/software: Code Composer Studio
Hello,
In my application I need to periodically check the status of a button. Ideally when the state changes, I'd like the state change to write to Characteristic4. Because one of the features of Characteristic4 is the ability to notify, my client application will receive a notification of the state change. I am using DIO13 as the button (just like the CC2640r2 LaunchPad). The button is configured as follows:
Board_KEY1 | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS | PIN_IRQ_NEGEDGE, /* Button is active low */
Schematically, this button is tied to GND in the closed state. So when the weight is on the button, DIO13 is at GND. This pin is also used to wakeup the device and initiate advertising. When the button is pushed a single time and immediately released (1-2 seconds), the device wakes up and begins advertising as expected. However when the button is held down by the weight for an extended period 10's of seconds, the device behaves strangely - the current draw increases by a factor of 10+, the device stops advertising sometimes, sometimes requires a power cycle to return to normal function.
For now, I'm updating the state change in the SimplePeripheral_performPeriodicTask(void) shown below.
static void SimplePeripheral_performPeriodicTask(void) { AONBatMonEnable(); int32_t temp = AONBatMonTemperatureGetDegC(); uint32_t batVolt = AONBatMonBatteryVoltageGet(); uint8_t buttonStatus = PIN_getInputValue(Board_PIN_BUTTON0); if(!AONBatMonNewTempMeasureReady()) SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR1, sizeof(int32_t), &temp); if(!AONBatMonNewBatteryMeasureReady()) SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR2, sizeof(uint32_t), &batVolt); //if(SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR4, &buttonStatus) == SUCCESS); SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, sizeof(uint8_t), &buttonStatus); }
Is my implementation incorrect for the application described?
Thanks,
Patrick