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

the lib source err

while (button_count--)//botton_count = 4
{
    app_button_cfg_t * p_btn = &p_buttons[button_count];

    nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
    config.pull = p_btn->pull_cfg;
    
    err_code = nrf_drv_gpiote_in_init(p_btn->pin_no, &config, gpiote_event_handler);//return //NRF_ERROR_NO_MEM when it is called at the second time,,why ?how can i modify it 
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }
}
Parents
  • @Fanqh: Next time when you ask a question please put more description in. We need to know which SDK version you use. what you plan to do , and how the issue occurs.

    From the information you provide, most likely you wanted to use more than 4 GPIOTE IN channels so you will receive NRF_ERROR_NO_MEM. I know you mentioned botton_count = 4, but if you have allocated 4 channels before and then try to add more you will receive the error.

Reply
  • @Fanqh: Next time when you ask a question please put more description in. We need to know which SDK version you use. what you plan to do , and how the issue occurs.

    From the information you provide, most likely you wanted to use more than 4 GPIOTE IN channels so you will receive NRF_ERROR_NO_MEM. I know you mentioned botton_count = 4, but if you have allocated 4 channels before and then try to add more you will receive the error.

Children
  • static int8_t channel_port_alloc(uint32_t pin,nrf_drv_gpiote_evt_handler_t handler, bool channel) { int8_t channel_id = NO_CHANNELS; uint32_t i;

    uint32_t start_idx = channel ? 0 : NUMBER_OF_GPIO_TE;
    uint32_t end_idx = channel ? NUMBER_OF_GPIO_TE : (NUMBER_OF_GPIO_TE+GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS);
    //critical section
    
    for (i = start_idx; i < end_idx; i++)   //start= 4; end_id = 5   when button =2,the function  will  return 0xff, if somewherr is erro?
    {
        if (m_cb.handlers[i] == FORBIDDEN_HANDLER_ADDRESS)
        {
            pin_in_use_by_te_set(pin, i, handler, channel);
            channel_id = i;
            break;
        }
    }
    //critical section
    return channel_id;
    
    }
    

    i use s110 9.0.0

  • Hi Fanqh, Maximum number of GPIOTE hardware channel is 4. I'm seeing that you are trying to use 4 and 5 which is more than 4. This is not allowed. See the define of NUMBER_OF_GPIO_TE.

Related