Hello,
please help to grasp the problem,
when using the timer to control gpio pin with constant period as shown below, if trying to do advertising for BLE communication,
the gpio can't be stable, when checking the behavior of gpio pins in oscilloscope, can see shaking,
if turning off the advertising, the problem is not happened,
if you know the solution, please help to let me know it with detailed information or example code,
I already considered the usage of PPI or GPIOTE, but in my opinion , the cases is not matched with what I want to do (in order to control gpio pin in diverse period).
thankful for your support in advance,
ref) my email is, [email protected]
Timer Handler ex :
void tcs_waveform_timer_event_handler_us(nrf_timer_event_t event_type, void* p_context)//love_1212 1 khz(1ms) t1/t2/t3 : 25 us
{
switch(event_type)
{
case NRF_TIMER_EVENT_COMPARE0:
if(tcs_on_count == 3333)
tcs_on_count = 1;
else
tcs_on_count++;
if(tcs_on_count == 1)
NRF_P0->OUTSET = (1 << TCS_ON2); ==> GPIO 1 PIN SET
else if(tcs_on_count == 51)
NRF_P0->OUTCLR = (1 << TCS_ON2); ==> GPIO 1 PIN RESET
else if(tcs_on_count == 52)
NRF_P0->OUTSET = (1 << TCS_ON1); ==> GPIO 2 PIN SET
else if(tcs_on_count == 102)
NRF_P0->OUTCLR = (1 << TCS_ON1); ==> GPIO 2 PIN RESET
break;
default:
//Do nothing.
break;
}
}
I set the timer as below,
void Hal_Tcs_1Khz_Timer_Init(void)
{
uint32_t time_in_us = 5;//love_1212 for 1 khz 25;//16666; //Time(in miliseconds) between consecutive compare events.
uint32_t time_ticks;
uint32_t err_code = NRF_SUCCESS;
nrf_gpio_cfg_output(TCS_ON1);
nrf_gpio_cfg_output(TCS_ON2);
tcs_on_count = 0;//love_1120
//Configure all leds on board.
err_code = nrf_drv_timer_init(&TIMER_1, NULL, tcs_waveform_timer_event_handler_us);
APP_ERROR_CHECK(err_code);
time_ticks = nrf_drv_timer_us_to_ticks(&TIMER_1, time_in_us);//love_1115
nrf_drv_timer_extended_compare(
&TIMER_1, NRF_TIMER_CC_CHANNEL0, time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
NVIC_SetPriority(TIMER2_IRQn, 2);
}
thanks.