code architecture problem ( randomly crashing )

5 posts / 0 new
Last post
mohit3112
Offline
Last seen:8 months 1 week ago
Expert
加入:2014-08-04 13:45
code architecture problem ( randomly crashing )

In my code i am implementing a state machine , once scheduler is triggered da14580 takes data from sensor, process it, and goes to sleep (waiting for next sensor interrupt to come)
sensor gives interrupt every 20ms , my problem is that this code is randomly crashing , I want to ask is it possible to go into sleep mode between two consecutive samples ( if they are 20ms apart ) .
I am using PAN1740 ( in debug environment)

void WKUP_QUADEC_Handler(void)
{

环境运输及工务局局长ord16(SET_FREEZE_REG, FRZ_WDOG);

NVIC_DisableIRQ(WKUP_QUADEC_IRQn);

SetBits16 (CLK_AMBA_REG PCLK_DIV 0);
SetBits16(CLK_AMBA_REG, HCLK_DIV, 0);

if((GetBits16(CLK_PER_REG, WAKEUPCT_ENABLE) != 0))
{
环境运输及工务局局长ord16(WKUP_RESET_IRQ_REG, 1);
SetBits16(WKUP_CTRL_REG, WKUP_ENABLE_IRQ, 0);
}

if(GetBits16(SYS_STAT_REG, PER_IS_DOWN))
periph_init();

if(app_ble_ext_wakeup_get())
{
app_disable_sleep();
SetBits32(GP_CONTROL_REG, BLE_WAKEUP_REQ, 1);
if( CurrentState == SLEEP)
{
app_ble_ext_wakeup_off();
app_adv_start();
}
}

if(CurrentState == SLEEP && (PastState == COMPUTING || PastState == INITILISATION))
{
set_state(VALIDATION,SLEEP);
}
else if(CurrentState == IDLE && PastState == VALIDATION )
{
set_state(VALIDATION,IDLE);
}
else if(CurrentState == IDLE && PastState == COMPUTING )
{
set_state(COMPUTING,IDLE);
}

GLOBAL_INT_STOP();
flip_main_scheduler(); // For communication with sensor , and data proccessing
GLOBAL_INT_START()

return;
}

Device:
MT_dialog
Offline
Last seen:1 month 6 days ago
Staff
加入:2015-06-08 11:34
Hi mohit3112,

Hi mohit3112,

Yes you can go into sleep mode between the two interrupt events, if the ble core doesn't have anything to do (connection interval, etc) the system will go to sleep.

Thanks MT_dialog

mohit3112
Offline
Last seen:8 months 1 week ago
Expert
加入:2014-08-04 13:45
That means that if my

That means that if my interrupts are 20ms and connection interval is 10ms , then core might be awake already when my interrupt fires( if ble interrupts fire first ) . if that clash happens which interrupt will be executed , Can i prioritize my interrupts over ble ? or will this trigger any disconnect or crash (hardfalt) in the system.

mohit3112
Offline
Last seen:8 months 1 week ago
Expert
加入:2014-08-04 13:45
actually my code is crashing

actually my code is crashing only when development debug is on !! ,when i am not in development mode that ie #define DEVELOPMENT_DEBUG 0 code seems to run fine , but won't this will destroy otp as i might be loading code in it not in system ram ?

MT_dialog
Offline
Last seen:1 month 6 days ago
Staff
加入:2015-06-08 11:34
Hi mohit3112,

Hi mohit3112,

Yes that surely might happen, and the BLE events have higher in priority from the external events, if that happens your system should not crash but just delay the interrupt from the sensor. Also you cannot put external interrupts in higher priority, if the kernel doesn't serve the BLE interrupt the system will fail and lose connection. About the OTP you can't burn the OTP just by setting the DEVELOPMENT_DEBUG to 0 is just a flag for GPIO reservations etc. The firmware is downloaded to the sysram.

Thanks MT_dialog