This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

GPIOTE event is not triggered sometimes

Hello,

I need two signals with a phase shift to control my motor. For some reason, completely randomly, sometimes my GPIOTE event is not triggered and i get the inversion of the signals. I am spinning the motor for approximately 8-10 seconds, and sometimes this happens after a second, sometimes after two seconds, sometimes after 8 seconds and so on...This is a totally disaster because of that my motor changes the direction to which it is rotating. I attach the photo of what is happening and the code how i am doing this. I remember reading some time ago that sometimes you get inverted signals by using PWM library, but i am not using one and doing it via registers. Is there a workaround for this? Im using nrf51422 with S110, SDK V8.

image description

NRF_GPIOTE->CONFIG[0] = GPIOTE_CONFIG_MODE_Task << GPIOTE_CONFIG_MODE_Pos |
						GPIOTE_CONFIG_POLARITY_Toggle << GPIOTE_CONFIG_POLARITY_Pos |
						23 << GPIOTE_CONFIG_PSEL_Pos | 
						GPIOTE_CONFIG_OUTINIT_Low << GPIOTE_CONFIG_OUTINIT_Pos;
					
NRF_GPIOTE->CONFIG[1] = GPIOTE_CONFIG_MODE_Task << GPIOTE_CONFIG_MODE_Pos |
						GPIOTE_CONFIG_POLARITY_Toggle << GPIOTE_CONFIG_POLARITY_Pos |
						24 << GPIOTE_CONFIG_PSEL_Pos | 
						GPIOTE_CONFIG_OUTINIT_Low << GPIOTE_CONFIG_OUTINIT_Pos;          
						
NRF_TIMER1->PRESCALER = 4;
NRF_TIMER1->CC[1] = 2000;
NRF_TIMER1->CC[2] = 6000;
NRF_TIMER1->SHORTS = TIMER_SHORTS_COMPARE2_CLEAR_Enabled << TIMER_SHORTS_COMPARE2_CLEAR_Pos;

NRF_PPI->CH[0].EEP = (uint32_t) &NRF_TIMER1->EVENTS_COMPARE[1];
NRF_PPI->CH[0].TEP = (uint32_t) &NRF_GPIOTE->TASKS_OUT[0];

NRF_PPI->CH[1].EEP = (uint32_t) &NRF_TIMER1->EVENTS_COMPARE[2];
NRF_PPI->CH[1].TEP = (uint32_t) &NRF_GPIOTE->TASKS_OUT[1];

NRF_PPI->CHENSET = (PPI_CHENSET_CH0_Enabled << PPI_CHENSET_CH0_Pos) | (PPI_CHENSET_CH1_Enabled << PPI_CHENSET_CH1_Pos);

NRF_TIMER1->TASKS_START = 1; // Start timer
Related