52832 PPI and GPIOTE, TIMER

hi, I want to use PPI function for timer trigger GPIOTE,

when timer interrupt comes, my output pin will toggle, but I find my code doesn't work, I think it is GPIOTE mistake, because I use timer for triggering other timer task, its ok.

could you check my code?

thanks 

void GPIOTE_PPI_init(void)
{

    ret_code_t err_code;
	
    nrf_drv_gpiote_out_config_t m_gpiote;
    err_code = nrf_drv_gpiote_out_init(GPIO_OUTPUT_PIN_NUMBER, &m_gpiote);
    APP_ERROR_CHECK(err_code);
 
		/*ppi_channel1*/
		err_code = nrf_drv_ppi_channel_alloc(&ppi_channel1);
    APP_ERROR_CHECK(err_code);

    compare_evt_addr_down = nrf_drv_comp_event_address_get(NRF_COMP_EVENT_DOWN);
	
    gpiote_task_addr_down = nrf_drv_gpiote_clr_task_addr_get(GPIO_OUTPUT_PIN_NUMBER);
		
	
		err_code = nrf_drv_ppi_channel_assign(ppi_channel1,
                                          nrf_drv_timer_event_address_get(&m_timer0,
                                                                          NRF_TIMER_EVENT_COMPARE0),
                                          gpiote_task_addr_down);
		APP_ERROR_CHECK(err_code);


		
    err_code = nrf_drv_ppi_channel_enable(ppi_channel1);
    APP_ERROR_CHECK(err_code);
		
		
		/*ppi_channel2*/
		err_code = nrf_drv_ppi_channel_alloc(&ppi_channel2);
    APP_ERROR_CHECK(err_code);

    compare_evt_addr_up	=	nrf_drv_comp_event_address_get(NRF_COMP_EVENT_UP);
    gpiote_task_addr_up = nrf_drv_gpiote_set_task_addr_get(GPIO_OUTPUT_PIN_NUMBER);



		err_code = nrf_drv_ppi_channel_assign(ppi_channel2,
                                          nrf_drv_timer_event_address_get(&m_timer1,
                                                                          NRF_TIMER_EVENT_COMPARE0),
                                          gpiote_task_addr_up);
		APP_ERROR_CHECK(err_code);



    err_code = nrf_drv_ppi_channel_enable(ppi_channel2);
    APP_ERROR_CHECK(err_code);
		
    nrf_drv_gpiote_out_task_enable(GPIO_OUTPUT_PIN_NUMBER);
		

Parents Reply Children
No Data
Related