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

simple PPI question

hi, i am going to make a simple PWM with SDK 6.0.0, nrf51822 and softdevice.

first, i use ble_app_uart example as a base code, because i need to BLE communication with high frequency.

here is my simple code

/**@brief Application main function. */ int main(void) {

// Initialize
leds_init();
timers_init();
buttons_init();

// uart_init(); ble_stack_init(); gap_params_init(); services_init(); advertising_init(); conn_params_init(); sec_params_init();

	nrf_gpio_cfg_output(22);
	nrf_gpio_cfg_output(21);

//NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
	NRF_CLOCK->TASKS_HFCLKSTART;

	//Wait for external oscillator to start up

	NRF_TIMER2->PRESCALER = 2;
	NRF_TIMER2->TASKS_CLEAR;
	NRF_TIMER2->BITMODE = TIMER_BITMODE_BITMODE_16Bit;
	NRF_TIMER2->MODE = TIMER_MODE_MODE_Timer;
	NRF_TIMER2->EVENTS_COMPARE[0] = 0;
	NRF_TIMER2->CC[0] = 500;
	NRF_TIMER2->CC[1] = 100;
	NRF_TIMER2->CC[2] = 600;
	NRF_TIMER2->CC[3] = 700;
	NRF_TIMER2->SHORTS = (TIMER_SHORTS_COMPARE0_CLEAR_Enabled <<TIMER_SHORTS_COMPARE0_CLEAR_Pos);
	NRF_TIMER2->INTENSET = (TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos);
	NVIC_EnableIRQ(TIMER2_IRQn);
	//NRF_POWER->TASKS_CONSTLAT = 1;
	NRF_TIMER2->TASKS_START = 1;
	
	nrf_gpiote_task_config(0, 21, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);//GPIOTASK 설정
NVIC_EnableIRQ(GPIOTE_IRQn);
	
	
	
	NRF_PPI->CH[0].EEP = (uint32_t)&NRF_TIMER2->EVENTS_COMPARE[1];//event end point: task 발생 조건
	NRF_PPI->CH[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0];//task end point, event에 의해 발생하는 task
	NRF_PPI->CHEN = PPI_CHEN_CH0_Enabled << PPI_CHEN_CH0_Pos;
	

// simple_uart_putstring(START_STRING);

advertising_start();

// Enter main loop
for (;;)
{

    //power_manage();
}

}

void TIMER2_IRQHandler(void) { if ((NRF_TIMER2->EVENTS_COMPARE[0] == 1) && (NRF_TIMER2->INTENSET & TIMER_INTENSET_COMPARE0_Msk)) { NRF_TIMER2->EVENTS_COMPARE[0] = 0; }

 //NRF_TIMER2->TASKS_CLEAR;
	nrf_gpio_pin_toggle(22);

}

/**

  • @} */

the BLE connection is operated well with BLE toolbox. and the timer2 compare interrupt is called well.

the problem is occurred in these sentences

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

with this two code lines, the chip do not operate anythings. if i delete this two code lines, the chip operates well.

is there any interference between the codes and other things???

Parents Reply Children
No Data
Related