Other Parts Discussed in Thread: MSP430F2418,
Based on the PAN1326 datasheet on page 38 the average BLE "Advertising, discoverable" current is 121uA. However, I am measuring an average system current of 800uA. I need to reduce the current draw as much as possible, and need help to achieve the ~130uA that is theoretically possible.
The MSP430F2418 used is in LPM3 and if I assert the nShutdown pin on the PAN1326, board current drops to 15uA. From this I have concluded the current is being drawn by the PAN1326 module, and that it is not entering the correct power state. I am using Bluetopia v1.5 for the stack and the code is based on a modified version of the SPPLE Demo Lite example.
Schematic excerpts are shown below. VBAT is 3.4V and S1 and S2 are jumpers in the VBAT position. I have included my modified SPPLEDemo.c and MainThread() and IdleFunction() implementations below.
/* The following function is responsible for checking the idle state */
/* and possibly entering LPM3 mode. */
static void IdleFunction(void *UserParameter)
{
if(BLEdataToProcess)
return; // still work to be done
#ifdef __CONNECTION_TIMEOUT__
//if ((ConnectionID != 0) && (connection_timeout != 0)) // 05/23/2017
if ((ConnectionID != 0) && (flgBLEOperationOn == 1)) // 05/23/2017
{
return; //do not sleep
}
#endif
/* If the stack is Idle and we are in HCILL Sleep, then we may enter */
/* LPM3 mode (with Timer Interrupts disabled). */
if((BSC_QueryStackIdle(BluetoothStackID)) && (SleepEnabled))
{
/* Attempt to suspend the UART. */
if(!HCITR_COMSuspend(0))
{
/* Enter MSP430 LPM3 with Timer Interrupts disabled (we will */
/* require an interrupt to wake us up from this state). */
//HAL_LowPowerMode((unsigned char)FALSE);
#if 1
if((BEACON_INT_FLAG ==1) && (Pkt_Rcd ==0) && (RxCount==0) && (RxState==0))
//if((Pkt_Rcd ==0) && (RxCount==0) && (RxState==0))
{
//FRAM_POWEROFF(); //comment out 05/18/2017 // 06/06/2017
PwrDown_FlashIC(); // ensure flash is powered off
HAL_LowPowerMode((unsigned char)FALSE);
}
#else
HAL_LowPowerMode((unsigned char)FALSE);
#endif
/* Check to see if a wakeup is in progress (by the Controller).*/
/* If so we will disable sleep mode so that we complete the */
/* process. */
if(!HCITR_UartSuspended(0))
SleepEnabled = FALSE;
}
else
{
/* Failed to suspend the UART which must mean that the */
/* controller is attempting to do a wakeup. Therefore we will */
/* flag that sleep mode is disabled. */
SleepEnabled = FALSE;
}
}
}
/* The following function is the main user interface thread. It */
/* opens the Bluetooth Stack and then drives the main user interface.*/
static void MainThread(void)
{
int Result;
BTPS_Initialization_t BTPS_Initialization;
HCI_DriverInformation_t HCI_DriverInformation;
HCI_HCILLConfiguration_t HCILLConfig;
HCI_Driver_Reconfigure_Data_t DriverReconfigureData;
/* Flag that sleep is not currently enabled. */
SleepEnabled = FALSE;
/* Configure the UART Parameters. */
HCI_DRIVER_SET_COMM_INFORMATION(&HCI_DriverInformation, 1, 115200, cpHCILL);
HCI_DriverInformation.DriverInformation.COMMDriverInformation.InitializationDelay = 100;
/* Set up the application callbacks. */
BTPS_Initialization.GetTickCountCallback = GetTickCallback;
BTPS_Initialization.MessageOutputCallback = DisplayCallback;
/* Initialize the application. */
if((Result = InitializeApplication(&HCI_DriverInformation, &BTPS_Initialization)) > 0)
{
/* Save the Bluetooth Stack ID. */
BluetoothStackID = (unsigned int)Result;
/* Register a sleep mode callback if we are using HCILL Mode. */
if((HCI_DriverInformation.DriverInformation.COMMDriverInformation.Protocol == cpHCILL) || (HCI_DriverInformation.DriverInformation.COMMDriverInformation.Protocol == cpHCILL_RTS_CTS))
{
HCILLConfig.SleepCallbackFunction = HCI_Sleep_Callback;
HCILLConfig.SleepCallbackParameter = 0;
DriverReconfigureData.ReconfigureCommand = HCI_COMM_DRIVER_RECONFIGURE_DATA_COMMAND_CHANGE_HCILL_PARAMETERS;
DriverReconfigureData.ReconfigureData = (void *)&HCILLConfig;
/* Register the sleep mode callback. Note that if this */
/* function returns greater than 0 then sleep is currently */
/* enabled. */
Result = HCI_Reconfigure_Driver(BluetoothStackID, FALSE, &DriverReconfigureData);
if(Result > 0)
{
/* Flag that sleep mode is enabled. */
SleepEnabled = TRUE;
}
}
//FRAM_POWERON(); //comment out 05/18/2017 // 06/06/2017
//FRAM_POWEROFF(); //comment out 05/18/2017 // 06/06/2017
BTPS_AddFunctionToScheduler(IdleFunction, NULL, 0); //FOR MANAGEMENT
if(BTPS_AddFunctionToScheduler(BLEApplication, NULL,5))
/* Add the idle function (which determines if LPM3 may be entered)*/
/* to the scheduler. */
//if(BTPS_AddFunctionToScheduler(IdleFunction, NULL, 0))
{
/* Loop forever and execute the scheduler. */
while(1)
BTPS_ExecuteScheduler();
}
}
}