I am not understanding that what should be event pointer and task pointer address. Can you please explain it with some example in detail.
I am not understanding that what should be event pointer and task pointer address. Can you please explain it with some example in detail.
Since you've quoted from the PPI chapter in the reference manual, you're asking about how the PPI event endpoints (NRF_PPI->CH[x].EEP) and task endpoints (NRF_PPI->CH[x].TEP) works. The Programmable Peripheral Interconnect (short: PPI) is a peripheral that takes in a event and then starts a task, without involving the MCU (other than the initial configuration)
A PPI event endpoint register must hold the address of an valid event given by the nRF51x22. This can be any event generated by any of the peripherals. For instance:
NRF_PPI->CH[0].EEP = (uint32_t)&NRF_TIMER0->EVENTS_COMPARE[0];
In order for the above event (in this case, timer0's compare[0]) to actually have an effect through the PPI, you must also configure the Task End Point (TEP). The address that you give into the TEP must be a valid TASKS_* address, for instance:
NRF_PPI->CH[0].TEP = (uint32_t)&NRF_ADC->TASKS_START;
Now, given that the two peripherals that you've connected through the PPI are configured correctly, and the specific PPI channel is enabled (NRF_PPI->CHENSET = PPI_CHENSET_CH0_Enabled << PPI_CHENSET_CH0_Pos;), the ADC will do a conversion each time the NRF_TIMER->EVENTS_COMPARE[0] occurs.
I would recommend that you look at the PPI-example in the SDK, as well as the gpiote_example, as it also uses the PPI. If you look at this example on github, which will create a 8 MHz pulse on a GPIO, it also uses the PPI to make this happen: github.com/.../main.c
Thank you very much for your answer. But in this below code what will be *event_ptr and *task_ptr?
void ppi_enable_channel(uint32_t ch_num, volatile uint32_t *event_ptr, volatile uint32_t *task_ptr)
{
if(ch_num >= 16)
{
return;
}
else
{
#if(USE_WITH_SOFTDEVICE == 1)
sd_ppi_channel_assign(ch_num, event_ptr, task_ptr);
sd_ppi_channel_enable_set(1 << ch_num);
#else
// Otherwise we configure the channel and return the channel number
NRF_PPI->CH[ch_num].EEP = (uint32_t)event_ptr;
NRF_PPI->CH[ch_num].TEP = (uint32_t)task_ptr;
NRF_PPI->CHENSET = (1 << ch_num);
#endif
moderator edit: use of code tags
This is a function that handles configuration of PPI channels when the softdevice is enabled and disabled. Since the softdevice uses the PPI, it is a restricted peripheral and should be accessed via the nrf_soc library when it's enabled.
You can call this function similar to this: "ppi_enable_channel(MY_PPI_CHANNEL, &NRF_TIMER0->EVENTS_COMPARE[0], &NRF_ADC->TASKS_START);"