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

Disabling ADC and sending Some data taken from ADC to other function.

Hi, i am disabling ppi channel so that my adc should stop working(i am taking data from 3-axis accelerometer), this process i am doing by pressing button(bsp_event_handler) and after disabling i am sending some data to other function. Some time it stuck..(now i have to reset board to work again),uptil now what i have recovered is that before disabling ppi an adc_event is generated and it is not returning back.

i need continous Adc data so in adc_event_handler I am calling nrf_drv_adc_buffer_convert(adc_buffer,ADC_BUFFER_SIZE) so that adc will be ques: is this a safe way to do it.

code for adc event handler is below:

static void adc_event_handler(nrf_drv_adc_evt_t const * p_event)
{
	uint8_t adc_result[ADC_BUFFER_SIZE*2];
	float gvalue = 0.0;
	int16_t uartDecimal_result;
	if (p_event->type == NRF_DRV_ADC_EVT_DONE)
	{
		if(PRINT_DEBUG) {
			NRF_LOG_PRINTF("\n");
			NRF_LOG_PRINTF("{");
		}

		for (uint8_t i = 0; i < p_event->data.done.size; i++)
		{
			Decimal_result = p_event->data.done.p_buffer[i];
			if(PRINT_DEBUG){
				NRF_LOG_PRINTF("%d,",Decimal_value);
			}
		if(PRINT_DEBUG) {
			NRF_LOG_PRINTF("},");
		}
		adc_event_counter++;
		APP_ERROR_CHECK(nrf_drv_adc_buffer_convert(adc_buffer,ADC_BUFFER_SIZE));
		LEDS_INVERT(BSP_LED_3_MASK);

/** concerned part is nrf_drv_adc_convert**/ and this is how i assign adc to ppi

nrf_drv_ppi_channel_assign(m_ppi_channel, timer_compare_event_addr, adc_sample_event_addr); 

where sadc_sample_event_handler is nrf_drv_adc_start_task_get()

enabling and disabling of adc is handled by buttons,nrf_drv_ppi_channel_enable and disable....

Qusestion: i need button implementation, by pressing button adc should be disabled and i can send testdata to other function. how this can be implemented?.

Parents Reply Children
No Data
Related