hi its not working as i want . y is that?
first step i try to toggle just with one cc that is the code below
with changing of NRF_TIMER2->CC[0] = 65536;
nothing happend there is no difrence in changing it
y is that?
nrf_gpio_cfg_output(PWM_OUTPUT_PIN_NUMBER);
// Configure GPIOTE channel 0 to toggle the PWM pin state
// @note Only one GPIOTE task can be connected to an output pin.
nrf_gpiote_task_config(0, PWM_OUTPUT_PIN_NUMBER, \
NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
// Configure PPI channel 0 to toggle PWM_OUTPUT_PIN on every TIMER2 COMPARE[0] match.
NRF_PPI->CH[0].EEP = (uint32_t)&NRF_TIMER2->EVENTS_COMPARE[0];
NRF_PPI->CH[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0];
// Enable PPI channels 0-2.
NRF_PPI->CHEN = (PPI_CHEN_CH0_Enabled << PPI_CHEN_CH0_Pos);
// Start 16 MHz crystal oscillator .
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK->TASKS_HFCLKSTART = 1;
// Wait for the external oscillator to start up.
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
{
//Do nothing.
}
NRF_TIMER2->MODE = TIMER_MODE_MODE_Timer;
NRF_TIMER2->BITMODE = TIMER_BITMODE_BITMODE_16Bit << TIMER_BITMODE_BITMODE_Pos;
NRF_TIMER2->PRESCALER = TIMER_PRESCALERS;
// Clears the timer, sets it to 0.
NRF_TIMER2->TASKS_CLEAR = 1;
// Load the initial values to TIMER2 CC registers.
NRF_TIMER2->CC[0] = 65536;
// Interrupt setup.
NRF_TIMER2->INTENSET = (TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos);
void TIMER2_IRQHandler(void)
{
static bool cc0_turn = false; /**< Keeps track of which CC register to be used. */
if ((NRF_TIMER2->EVENTS_COMPARE[0] != 0) &&
((NRF_TIMER2->INTENSET & TIMER_INTENSET_COMPARE0_Msk) != 0))
{
//NRF_TIMER2->TASKS_CLEAR = 1;
}
}