Hi,
i need to make pulse with one of my Timers. Timer0 is used by the softdevice, and Timer2 is used to make PWM. I need to make a Pulse wich is 100us long, every 250ms (4hz). If i use Timer0 in my configuration i only can make this Pulse every 50ms not longer but how can i change that? Do i overflow the CC-Register with a big value ? Maybe someone can have a look at my Code.
void Timer1Init (void)
{
uint32_t Pulsweite = 25000; //3s
uint32_t Periode = 80000; //5s
NRF_TIMER1->TASKS_STOP = 1;
// Create an Event-Task shortcut to clear TIMER0 on COMPARE[0] event
NRF_TIMER1->MODE = TIMER_MODE_MODE_Timer;
NRF_TIMER1->BITMODE = (TIMER_BITMODE_BITMODE_24Bit << TIMER_BITMODE_BITMODE_Pos);
NRF_TIMER1->PRESCALER = 4; // 1us resolution
NRF_TIMER1->TASKS_CLEAR = 1; // clear the task first to be usable for later
NRF_TIMER1->CC[0] = 100; //second timeout
NRF_TIMER1->CC[1] = 50000; //first timeout
NRF_TIMER1->INTENSET = TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos;
NRF_TIMER1->INTENSET = TIMER_INTENSET_COMPARE1_Enabled << TIMER_INTENSET_COMPARE1_Pos;
/* Create an Event-Task shortcut to clear TIMER1 on COMPARE[0] event. */
NRF_TIMER1->SHORTS = (TIMER_SHORTS_COMPARE1_CLEAR_Enabled << TIMER_SHORTS_COMPARE1_CLEAR_Pos);
sd_nvic_SetPriority (TIMER1_IRQn, APP_IRQ_PRIORITY_HIGH); // Setzt die Prioroität auf HIGH
sd_nvic_EnableIRQ (TIMER1_IRQn); // Aktiviert den Interrupt
NRF_TIMER1->TASKS_START = 1;
}
void TIMER1_IRQHandler(void)
{
if (NRF_TIMER1->EVENTS_COMPARE[0] != 0)
{
NRF_TIMER1->EVENTS_COMPARE[0] = 0;
switch_intensi(1);
}
if (NRF_TIMER1->EVENTS_COMPARE[1] != 0)
{
NRF_TIMER1->EVENTS_COMPARE[1] = 0;
switch_intensi(0);
}
}
Thank you for your help, Nils ;)