Forum: Mikrocontroller und Digitale Elektronik STM32 CanBus cannot get out of interrupt handler


von mehmet karakaya (Gast)


Lesenswert?

hello dear forum,

I try to make CANBUS of STM32F103RC work
I managed to make CANBUS send message in loopback mode
however when I turn on receive interrupt
the processor hangs at first message and watchdog resets the micro
---------------------------------------------
 CAN_ITConfig(CAN1, CAN_IT_FMP0, ENABLE);
---------------------------------------------
I suspect the code enters the interrupt handler and cannot leave it
I want to ask how do I fill following lines to reset interupt flag and 
pending bit
---------------------------------------------
void USB_LP_CAN1_RX0_IRQHandler(void)
{
CAN_ClearFlag(CAN1, ??????????);
CAN_ClearITPendingBit(CAN1,??????????);

  CanRxMsg RxMessage;

  CAN_Receive(CAN1, CAN_FIFO0, &RxMessage);
---------------------------------------------
thank you

von Lars F. (flemmy)


Lesenswert?

Hey mehmet,

You use neither CAN_ClearFlag nor CAN_ClearITPendingBit. According to 
the reference manual (p. 683) CAN_IT_FMP0 is set and reset by hardware. 
As soon as you call CAN_Receive one message from the RX FIFO is read. 
The interrupt won't be called again, as soon as the FIFO message count 
has reached 0.

Greetings

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.