Skip to main content
Amrello
Visitor II
Sep 2, 2018 8:12 AM UTC
Question

extern "C"

Hello everyone, maybe it's a stupid question but in the interrupt handling function I can't rewrite a variable. I'm sure that the interrupt is triggered and assigns a value to rx_counter, read_msg is executed in a loop, but when the value of a variable is checked, it is always equal zero.

​

    This topic has been closed for replies.

    2 replies

    LMI2
    Senior III
    Sep 2, 2018 2:59 PM UTC

    Why are you using a screen capture and not code snippet.

    Have you tried making your variable volatile like this: volatile uint8_t       nbr;

    volatile uint8_t nbr;

    Pavel A.
    Sep 2, 2018 5:55 PM UTC

    > maybe it's a stupid question

    Maybe ...

    Do you see that rx1_counter is defined locally in the IRQ handler, and used in function read_msg?

    This means that another variable named rx1_counter is defined outside, and this is what read_msg() uses. IRQhandler modifies its local variable,

    -- pa