This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

About timing in mesh processing

Hello team,

I'm working on system development using Mesh SDK and I have some questions so please let me know.

###############
Development environment
IDE : Segger Embedded Stuido
SoC : nRF52840
SDK : Mesh v2.2.0
          normal SDK v15.0.0
Base project : light switch example (modifying for our system)
###############

1. If a node belonging to a group receives a message for that group address, which of the following will be performed first?
    ・Processing for messages, such as replies
    ・Transfer message to another node
    ・Anything else.


2. There is possiblity to rewrite the same variable in the receive callback of Mesh message and the timer interrupt handler, in main.c.
    As such, I do not want to generate other interrupts during this process, includes receiving mesh messages.
    How can I realize this?
    Are the following functions and macros useful?
    ・CRITICAL_REGION_ENTER () / CRITICAL_REGION_EXIT ()
    ・nrf_mesh_disable () / nrf_mesh_enable ()


3. About interrupt
    As far as the document is referred to, when the Mesh message is received during execution of the application interrupt process,
    the application interrupt is interrupted and the Mesh reception interrupt is processed.
    I think that system will return to the interrupted application interrupt after the processing of the reception interrupt is finished.
    Is this recognition correct?

    I will assume that it is correct and ask a question.
    Is there a way to see this series of processes?
    
    I put a loop processing with an end condition to make the waiting time in the timer interrupt handler.
    I tried sending Mesh messages during looping, but the timer interrupt handler was not interrupted by the receipt of Mesh messages.
    On the contrary, mesh message reception interrupt did not occur even after loop termination.
    Does that mean that the system has not received a message?
    Or did the system receive it but did not put the interrupt on hold?

    The code in the timer interrupt handler is described below for reference.

void timer_handler(void * p_context)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "%s called.\n", __func__);
    
    for (uint8_t i = 100; i > 0; i--)
    {
        printf("loop %d\n", i);
    }
}



Thanks in advance.

Wataru

  • Hi, Torbjørn

    Thank you for your reply.
    I feel that knowledge about Nordic products is being accumulated little by little. :)

    I prepared a debugging environment to check the register information a little.
    It seems there are peripherals that can and cannot be referenced the INTEN register directory from SDK.
    Is this right?

    I referenced the NRF_TWI0-> ENABLE and NRF_TWI0-> INTENSET register for TWI.
    Before enabling TWI, both registers were "0", and after enabling TWI, ENABLE was "6" and INTENSET was "0".

    The TWI interrupt (NACK event) is generated intentionally, but looking at the register, I do not think that the interrupt is enabled.

    Is something wrong with the operation or understanding?

    Best regards
    Wataru

  • Hi Wataru

    You are correct, the INTEN register can not be accessed directly, only indirectly through the INTENSET and INTENCLR registers. 

    To read INTEN you just need to read INTENSET or INTENCLR, they will return the same thing. 

    To write to INTEN you have to either set or clear bits independently by writing to INTENSET/INTENCLR. 

    How do you enable TWI in your example?

    Do you use one of the standard drivers?

    Best regards
    Torbjørn

  • Hi, Torbjørn

    I learned how to get information about interrupts. Thank you very much.

    /**
     * @brief UART initialization.
     */
    void twi_init (void)
    {
        ret_code_t err_code;
    
        const nrf_drv_twi_config_t twi_tof_config = {
    //       .scl                = 3,
    //       .sda                = 2,
           .scl                = ARDUINO_SCL_PIN,
           .sda                = ARDUINO_SDA_PIN,
           .frequency          = NRF_DRV_TWI_FREQ_400K,
           .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
           .clear_bus_init     = false
        };
    
        err_code = nrf_drv_twi_init(&m_twi, &twi_tof_config, twi_handler, NULL);
        APP_ERROR_CHECK(err_code);
    
        nrf_drv_twi_enable(&m_twi);
    }
    


    I initialize and enable TWI in this way.
    I think this is the same as the peripheral example. not right?

    Best regards, 
    Wataru

  • Hi Wataru

    If you look at the driver implementation in nrf_drv_twi.c you will see that interrupts are not enabled until you start a TWI transfer, so after init the INTEN register will still be 0. 

    You can search for the nrf_twi_int_enable function in nrf_drv_twi.c to see where INTENSET is written. 

    Best regards
    Torbjørn

  • Hi Torbjørn

    Thank you for your advice.
    Actually, I thought the same thing after asking a question.
    When I checked on the device now, I could see that the value was set in the INTENSET register immediately after the TWI communication.

    Now I know where to look for information about interrupts, thank you.

    Best regards
    Wataru

Related