cancel
Showing results for 
Search instead for 
Did you mean: 

Problems using NVIC_SystemReset () and CAN bus

dsanchez
Associate
Posted on June 27, 2016 at 13:05

Hi all,

I'm developing an application with the stm32f103r8t6 where I've to reset the micro by CAN Bus and sometimes by pressing an external switch.

To do that, I've written the following code: 

RST_st = GPIO_ReadInputDataBit (GPIOA, PI_RST);

...

if ((!RST_st) || CAN_Reset ())

{

Delay_ms (1000); // Delay of 1s

if (!RST_st)

{

CAN_Tx_Reset_Cond ();

}

NVIC_SystemReset ();

}

...

int CAN_Reset (void)

{

CAN_Receive (CAN1, CAN_FIFO0, &RxMessage);

if (RxMessage.ExtId == CAN_ID_EXT_RST)

  {

return 1;

  }

else

{

return 0;

}

}

The code works fine when I reset the micro using the switch, but when the instruction arrives via CAN this only works the first time.

After this, the condition

RxMessage.ExtId == CAN_ID_EXT_RST

 always appears to be true when it isn't. 

Do you have any idea about how to solve this porblem??

Thanks and regards,

David

#nvic_systemreset #can-bus #stm32
0 REPLIES 0