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

How could I get the address of COMP event and use it for PPI?

Hi all,

 My project will use PPI to control COMP of nRF52832, connect Event of COPM and Task of GPIOTE.

Question 1,  

How could I get the address of COMP event and use it for PPI?

Address1 = * nrf_comp_event_address_get(NRF_COMP_EVENT_UP);  // The function is always wrong! 

Question 2,

nrfx_gpiote_out_task_addr_get(COM_out)+0x30 ;     

Is it right address for clearing GPIO by PPI?  Or we have other better way.  

Code  attached:

static void ppi_init(void) 
{     
 uint32_t err_code = NRF_SUCCESS;    
 uint32_t Address1;     
 uint32_t Address2;      
 err_code = nrf_drv_ppi_init();     
 APP_ERROR_CHECK(err_code);
 err_code = nrf_drv_ppi_channel_alloc(&m_ppi_channel1);     
 APP_ERROR_CHECK(err_code);    
 Address1 = * nrf_comp_event_address_get(NRF_COMP_EVENT_UP);     
 err_code = nrf_drv_ppi_channel_assign(m_ppi_channel1, Address1, nrfx_gpiote_out_task_addr_get(COM_out)+0x30);  //clear     
 APP_ERROR_CHECK(err_code);          
 err_code = nrf_drv_ppi_channel_alloc(&m_ppi_channel2);     
 APP_ERROR_CHECK(err_code);     
 = nrf_drv_ppi_channel_assign(m_ppi_channel2, *nrf_comp_event_address_get(NRF_COMP_EVENT_DOWN), nrfx_gpiote_out_task_addr_get(COM_out)+0x60);      //set     
 APP_ERROR_CHECK(err_code);         // Enable both configured PPI channels     
 err_code = nrf_drv_ppi_channel_enable(m_ppi_channel1);     
 APP_ERROR_CHECK(err_code);    
 err_code = nrf_drv_ppi_channel_enable(m_ppi_channel2);     
 APP_ERROR_CHECK(err_code);
 }

  • How could I get the address of COMP event and use it for PPI?

    Address1 = * nrf_comp_event_address_get(NRF_COMP_EVENT_UP);  // The function is always wrong! 

    I think the proper way to get the address is this

    Address1 = (NRF_COMP + NRF_COMP_EVENT_UP)

     

    nrfx_gpiote_out_task_addr_get(COM_out)+0x30 ;     

    Is it right address for clearing GPIO by PPI?  Or we have other better way.  

     I cannot really answer this question as I do not know what COM_out is

  • Thanks for your reply.

    __STATIC_INLINE uint32_t * nrf_comp_event_address_get(nrf_comp_event_t comp_event)
    {
    return (uint32_t *)((uint8_t *)NRF_COMP + (uint32_t)comp_event);
    }

    It's function from SDK.  How to use the function?

    COM_OUT is a private define from myself, for comparator out sim by GPIO.

    My question is, how to clear or set COM_OUT by PPI ?

  • Kevin Hu said:
    It's function from SDK.  How to use the function?

     You call it by calling nrfx_comp_event_address_get(NRF_COMP_EVENT_UP);

     

    Kevin Hu said:

    COM_OUT is a private define from myself, for comparator out sim by GPIO.

    My question is, how to clear or set COM_OUT by PPI ?

     You cannot drive a pin by just using PPI, you need a combination of PPI and GPIOTE to drive a pin based on internal events.

    Please look at the SDK\examples\peripheral\gpiote example to see how the template for this. You seems to have initialized the PPI correctly, but you also need to initialize GPIOTE channel along with it.

  • I called  nrfx_comp_event_address_get(NRF_COMP_EVENT_UP);  in the source code, but error. Why is wrong? That's my question.

    For  GPIOTE channel, I also haved initialized it but not updated here. My question is, task of clearing or setting COM_OUT, how to correctly get it? Or how to correctly describe it by C code? 

  • Kevin Hu said:
    I called  nrfx_comp_event_address_get(NRF_COMP_EVENT_UP);  in the source code, but error. Why is wrong? That's my question.

     Please read my answer properly first. I had already given you a suggestion for this one in my earlier suggstions like below

     

    Susheel Nuguru said:

    I think the proper way to get the address is this

    Address1 = (NRF_COMP + NRF_COMP_EVENT_UP)

Related