Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Using RTC in nrf5_SDK_for_Mesh_v5.0.0, I am trying to use RTC

Hello , I am working on a project, Which which currently working fine , but my job is to add some feature to it. So it is a Mesh application  i need some kind of custom sleep mode , so I need an RTC_Event that will be triggered after some time, I try to achieve this using Compare event . The build very well but when I try to debug and run. It jumps to Disassemble section and throws me an error.  I am currently using RTC Instance 0, I don't know why this is happening, Also I am little new to this , Any help regarding this?.
Thanks

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#define COMPARE_COUNTERTIME (5UL)
#define COMPARE_COUNTERTIME_1 (10UL) /**< Get Compare event COMPARE_TIME seconds after the counter starts from 0. */
extern volatile uint8_t onoffflage;
const nrf_drv_rtc_t rtc = NRF_DRV_RTC_INSTANCE(0); /**< Declaring an instance of nrf_drv_rtc for RTC0. */
/** @brief: Function for handling the RTC0 interrupts.
* Triggered on TICK and COMPARE0 match.
*/
void rtc_handler(nrf_drv_rtc_int_type_t int_type)
{
if (int_type == NRF_DRV_RTC_INT_COMPARE0)
{
nrf_drv_rtc_int_enable(&rtc, NRF_RTC_INT_COMPARE0_MASK);
onoffflage = 1;
}
if (int_type == NRF_DRV_RTC_INT_COMPARE1)
{
onoffflage = 0;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

This is my RTC Event Handler Function.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/** @brief Function initialization and configuration of RTC driver instance.
*/
static void rtc_config(void)
{
uint32_t err_code;
nrf_drv_clock_lfclk_request(NULL);
//Initialize RTC instance
nrf_drv_rtc_config_t config = NRF_DRV_RTC_DEFAULT_CONFIG;
config.prescaler = 4095;
err_code = nrf_drv_rtc_init(&rtc, &config, rtc_handler);
APP_ERROR_CHECK(err_code);
//Set compare channel to trigger interrupt after COMPARE_COUNTERTIME seconds
err_code = nrf_drv_rtc_cc_set(&rtc,0,COMPARE_COUNTERTIME * 8,true);
err_code = nrf_drv_rtc_cc_set(&rtc,1,COMPARE_COUNTERTIME_1 * 8,true);
APP_ERROR_CHECK(err_code);
//Power on RTC instance
nrf_drv_rtc_enable(&rtc);
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

RTC Configuration function

Disassembly Section

Traceback to Error



Thanks

Parents
  • Hi,

    Can you give more details about what you are trying to do? You mention a "custom sleep mode", maybe you are looking for something like the LPN example? It is a low power solution for mesh, you can read more about it here, Low Power node feature.

  • Hi,

    I would suggest you look more into the LPN feature, because it does exactly what you are describing. It is a low power solution in a mesh network. 

  • Hello , Some how I don't know, what was the problem but this problem is solved, Now for power optimization I did to disable Mesh Using this piece of Code 

    Fullscreen
    1
    2
    3
    4
    5
    ret_code_t retval = proxy_stop();
    while (retval == NRF_SUCCESS)
    {
    retval = nrf_mesh_disable();
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    and Re- Enable using this code

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    ret_code_t retval = proxy_enable();
    if (retval == NRF_SUCCESS)
    {
    retval = proxy_start();
    }
    if (retval == NRF_SUCCESS)
    {
    retval = nrf_mesh_enable();
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    So the Real Question is that , After disabling Mesh for some time and then re-enable Mesh I should see Publish Messages after Re-enabling Mesh , but actually I see old publish messages (messages before disabling Mesh) and then new publish messages.. Why I am seeing these pending publish messages, Thanks 
    By the I am using Sensor example.

Reply
  • Hello , Some how I don't know, what was the problem but this problem is solved, Now for power optimization I did to disable Mesh Using this piece of Code 

    Fullscreen
    1
    2
    3
    4
    5
    ret_code_t retval = proxy_stop();
    while (retval == NRF_SUCCESS)
    {
    retval = nrf_mesh_disable();
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    and Re- Enable using this code

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    ret_code_t retval = proxy_enable();
    if (retval == NRF_SUCCESS)
    {
    retval = proxy_start();
    }
    if (retval == NRF_SUCCESS)
    {
    retval = nrf_mesh_enable();
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    So the Real Question is that , After disabling Mesh for some time and then re-enable Mesh I should see Publish Messages after Re-enabling Mesh , but actually I see old publish messages (messages before disabling Mesh) and then new publish messages.. Why I am seeing these pending publish messages, Thanks 
    By the I am using Sensor example.

Children
No Data