Hello,
Implementing a LED led driver was pretty simple and below code works well:
nrf_gpio_cfg_output(LED_PIN);
nrf_gpio_pin_clear(LED_PIN);
NRF_GPIOTE->POWER = 1;
nrf_gpiote_task_configure(0, LED_PIN, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_HIGH);
nrf_gpiote_task_enable(0);
NRF_PPI->CH[0].EEP = (uint32_t)&NRF_TIMER2->EVENTS_COMPARE[0];
NRF_PPI->CH[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0];
NRF_PPI->CH[1].EEP = (uint32_t)&NRF_TIMER2->EVENTS_COMPARE[1];
NRF_PPI->CH[1].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0];
NRF_PPI->CHENSET = 3; // bits 0 and 1 for channels 0 and 1
NRF_TIMER2->POWER = 1;
NRF_TIMER2->MODE = TIMER_MODE_MODE_Timer << TIMER_MODE_MODE_Pos;
NRF_TIMER2->BITMODE = TIMER_BITMODE_BITMODE_16Bit << TIMER_BITMODE_BITMODE_Pos;
NRF_TIMER2->PRESCALER = 0;
NRF_TIMER2->CC[0] = 64;
NRF_TIMER2->CC[1] = 16259;
NRF_TIMER2->SHORTS = TIMER_SHORTS_COMPARE1_CLEAR_Msk;
NRF_TIMER2->TASKS_START = 1;
but the code, utilizing two separate GPIOTE channels (for ON and OFF) doesn't behave as expected:
nrf_gpio_cfg_output(LED_PIN);
nrf_gpio_pin_clear(LED_PIN);
NRF_GPIOTE->POWER = 1;
nrf_gpiote_task_configure(0, LED_PIN, NRF_GPIOTE_POLARITY_HITOLO, NRF_GPIOTE_INITIAL_VALUE_HIGH);
nrf_gpiote_task_configure(1, LED_PIN, NRF_GPIOTE_POLARITY_LOTOHI, NRF_GPIOTE_INITIAL_VALUE_LOW);
nrf_gpiote_task_enable(0);
nrf_gpiote_task_enable(1);
NRF_PPI->CH[0].EEP = (uint32_t)&NRF_TIMER2->EVENTS_COMPARE[0];
NRF_PPI->CH[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0];
NRF_PPI->CH[1].EEP = (uint32_t)&NRF_TIMER2->EVENTS_COMPARE[1];
NRF_PPI->CH[1].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[1];
NRF_PPI->CHENSET = 3; // bits 0 and 1 for channels 0 and 1
NRF_TIMER2->POWER = 1;
NRF_TIMER2->MODE = TIMER_MODE_MODE_Timer << TIMER_MODE_MODE_Pos;
NRF_TIMER2->BITMODE = TIMER_BITMODE_BITMODE_16Bit << TIMER_BITMODE_BITMODE_Pos;
NRF_TIMER2->PRESCALER = 0;
NRF_TIMER2->CC[0] = 64;
NRF_TIMER2->CC[1] = 16259;
NRF_TIMER2->SHORTS = TIMER_SHORTS_COMPARE1_CLEAR_Msk;
NRF_TIMER2->TASKS_START = 1;
What do I misunderstand in the concept of GPIOTE usage?