This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

use ppi and set usb sof as rtc1 source

To the kind attention of Nordic support team,

I have got a freertos project and usb is enabled (usb enumeration is done and usb interrupts are correctly working before even starting the scheduler).

In FreeRTOSConfig.h other than having:

#define FREERTOS_USE_RTC 0 and #define FREERTOS_USE_SYSTICK 1 

I'd like to add a third custom option:

#define FREERTOS_USE_USB_SOF 2

and change vPortSetupTimerInterrupt initialization (in case FREERTOS_USE_USB_SOF is set), so that usb sof event is triggering rtc1 overflow interrupt

(RTC1_IRQHandler == xPortSysTickHandler).

I was trying to modify like this, but something is missing it seems doesn't work. Could you please give me a hand if is not too much trouble, at least in how should theoretically be? (I'll update

if I have any news):

void vPortSetupTimerInterrupt( void )
{

nrf_drv_clock_lfclk_request(NULL); // assume that usb sof is triggering 0x00FFFFF0, then lfck is needed to do the actual overflow?

nrf_rtc_prescaler_set(portNRF_RTC_REG, portNRF_RTC_PRESCALER);

nrf_rtc_int_enable (portNRF_RTC_REG, RTC_INTENSET_OVRFLW_Msk); // enable overflow interrupt

nrf_rtc_task_trigger (portNRF_RTC_REG, NRF_RTC_TASK_CLEAR); //

// ppi re routing events_sof ---> tasks_trigovrflw

NRF_PPI->CH[0].EEP = (uint32_t)&NRF_USBD->EVENTS_SOF;
NRF_PPI->CH[0].TEP = (uint32_t)&NRF_RTC1->TASKS_TRIGOVRFLW;
NRF_PPI->CHENSET = (1 << 0);

NRF_RTC1->EVTEN = 2;

NRF_RTC1->TASKS_START = 1; // to enable counting

NVIC_SetPriority(portNRF_RTC_IRQn, configKERNEL_INTERRUPT_PRIORITY);
NVIC_EnableIRQ(portNRF_RTC_IRQn);

/*

working code

nrf_drv_clock_lfclk_request(NULL);

nrf_rtc_prescaler_set(portNRF_RTC_REG, portNRF_RTC_PRESCALER);
nrf_rtc_int_enable (portNRF_RTC_REG, RTC_INTENSET_TICK_Msk);
nrf_rtc_task_trigger (portNRF_RTC_REG, NRF_RTC_TASK_CLEAR);
nrf_rtc_task_trigger (portNRF_RTC_REG, NRF_RTC_TASK_START);
nrf_rtc_event_enable(portNRF_RTC_REG, RTC_EVTEN_OVRFLW_Msk);

NVIC_SetPriority(portNRF_RTC_IRQn, configKERNEL_INTERRUPT_PRIORITY);
NVIC_EnableIRQ(portNRF_RTC_IRQn);*/
}

Parents
  • Maybe the theoretical problem here is that overflow is writing 0x00FFFFF0, not actually forcing an immediate overflow interrupt in rtc1. so if rtc1 frequency is not higher than usb one, this doesn't work. I'd rather use a mechanism that is forcing an immediate rtc1 interrupt if possible. How would be a cool way using PPI to have a timer and usb in sync in your opinion? Thank you

Reply
  • Maybe the theoretical problem here is that overflow is writing 0x00FFFFF0, not actually forcing an immediate overflow interrupt in rtc1. so if rtc1 frequency is not higher than usb one, this doesn't work. I'd rather use a mechanism that is forcing an immediate rtc1 interrupt if possible. How would be a cool way using PPI to have a timer and usb in sync in your opinion? Thank you

Children
No Data
Related