Hi all: To saving power I implement the function to read data after interrupt is triggered..
below are my codes.. My expectation is..
Let CPU enter idle mode to wait interrupt by call _WFI() After interrupt is triggered start to read data and call _WFE() to save power. After read out 100 datas, CPU enter idle mode to wait interrupt triggered again...
However, the function of LIS3DH_ReadOutZYX(XYZ_Data) is always called even there is no any interrupt is triggered. How can I revise my code to meet my requirements? Thanks..
int main(void)
{
BSP_Init();
static bool bPoweSaving = true;
int16_t XYZ_Data[3]={0};
uint8_t reg = 0;
ret_code_t err_code;
static int i = 0;
while(true)
{
/* Start transaction with a slave with the specified address. */
if( bPoweSaving)
{
__WFI();
}
else
{
__WFE();
}
bPoweSaving = false;
err_code = LIS3DH_ReadOutZYX(XYZ_Data);
}
i ++;
if (i > 100)
bPoweSaving = true;
}