Hello,
I am using the PCA10040 DK, and I want to get a 8 MHz OR 4 MHz clock output from one of the GPIOs.
I've followed the instructions from here
and it works.. however I do not understand what is going on because I am new to this, and such low level stuff is not very helpful, especially when you don't know what is goingon.. so I tried implementing the same thing using the GPIOTE, TIMER and PPI drivers to get the following code:
/* create GPIOTE task */ nrf_drv_gpiote_pin_t XCLK_PIN = 28; nrf_drv_gpiote_out_config_t XCLK_GPIO_CONFIG = GPIOTE_CONFIG_OUT_TASK_TOGGLE(true); err_code = nrf_drv_gpiote_init(); APP_ERROR_CHECK(err_code); err_code = nrf_drv_gpiote_out_init(XCLK_PIN,&XCLK_GPIO_CONFIG); APP_ERROR_CHECK(err_code); nrf_drv_gpiote_out_task_enable(XCLK_PIN); uint32_t XCLK_task_add = nrf_drv_gpiote_out_task_addr_get(XCLK_PIN); /* create timer event */ nrf_drv_timer_t XCLK_TIMER = NRF_DRV_TIMER_INSTANCE(0); nrf_drv_timer_config_t XCLK_TIMER_CONFIG = NRF_DRV_TIMER_DEFAULT_CONFIG; err_code = nrf_drv_timer_init(&XCLK_TIMER,&XCLK_TIMER_CONFIG,XCLK_TIMER_HANDLER); APP_ERROR_CHECK(err_code); nrf_drv_timer_enable(&XCLK_TIMER); uint32_t XCLK_event_add = nrf_drv_timer_event_address_get(&XCLK_TIMER,NRF_TIMER_EVENT_COMPARE0); /*create ppi between gpiote and timer*/ err_code = nrf_drv_ppi_init(); APP_ERROR_CHECK(err_code); nrf_ppi_channel_t XCLK_CHANNEL; err_code = nrf_drv_ppi_channel_alloc(&XCLK_CHANNEL); APP_ERROR_CHECK(err_code); err_code = nrf_drv_ppi_channel_assign(XCLK_CHANNEL,XCLK_event_add, XCLK_task_add); APP_ERROR_CHECK(err_code); err_code = nrf_drv_ppi_channel_enable(XCLK_CHANNEL); APP_ERROR_CHECK(err_code);
But I am not getting anything close to 4MHz. I tried playing around with the nrf_drv_timer_config_t values through the CMSIS wizard, but was only able to bring it up to approximately 33 KHz.
I would appreciate some help in udnerstanding what I did wrong
Thank you!