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

52832 can't enter the interrupt

Hello engineers, Recently I test the ADC function,I think the library function is so difficulty for me. So I want to use the ADC by register,but I found that ,after I start the ADC,I can't enter the interrupt. It takes me much time. I want get a hand .Thinks so much! My code is :

void NRF_ADC_Init(void)
{
	//CH[Channel].CONFIG parameter
       nrf_saadc_channel_config_t channel_config;
	channel_config.resistor_p = NRF_SAADC_RESISTOR_DISABLED;
	channel_config.resistor_n = NRF_SAADC_RESISTOR_DISABLED;
	channel_config.gain       = NRF_SAADC_GAIN1_6;
	channel_config.reference  = NRF_SAADC_REFERENCE_INTERNAL;
	channel_config.acq_time   = NRF_SAADC_ACQTIME_10US;
	channel_config.mode       = NRF_SAADC_MODE_SINGLE_ENDED;
	channel_config.burst      = NRF_SAADC_BURST_DISABLED;
	channel_config.pin_p      = NRF_SAADC_INPUT_AIN0;
	channel_config.pin_n      = NRF_SAADC_INPUT_DISABLED;
        
       NRF_SAADC->RESOLUTION = SAADC_CONFIG_RESOLUTION;
	NRF_SAADC->OVERSAMPLE = SAADC_CONFIG_OVERSAMPLE;
	
	NRF_SAADC->INTENCLR = NRF_SAADC_INT_ALL;	
	NVIC_SetPriority(SAADC_IRQn, SAADC_CONFIG_IRQ_PRIORITY); 
	NRF_SAADC->INTENSET = NRF_SAADC_INT_END;                 
	NRF_SAADC->ENABLE = (SAADC_ENABLE_ENABLE_Enabled <<        SAADC_ENABLE_ENABLE_Pos);
	
	
	
	NRF_SAADC->CH[0].CONFIG = 
	                       ( (channel_config.resistor_p << SAADC_CH_CONFIG_RESP_Pos) & SAADC_CH_CONFIG_RESP_Msk )
                          |( (channel_config.resistor_n << SAADC_CH_CONFIG_RESN_Pos) & SAADC_CH_CONFIG_RESN_Msk )
                          |( (channel_config.gain  << SAADC_CH_CONFIG_GAIN_Pos) & SAADC_CH_CONFIG_GAIN_Msk ) 
                          |( (channel_config.reference << SAADC_CH_CONFIG_REFSEL_Pos) & SAADC_CH_CONFIG_REFSEL_Msk )
                          |( (channel_config.acq_time << SAADC_CH_CONFIG_TACQ_Pos) & SAADC_CH_CONFIG_TACQ_Msk )
                          |( (channel_config.mode << SAADC_CH_CONFIG_MODE_Pos) & SAADC_CH_CONFIG_MODE_Msk )
                          |( (channel_config.burst << SAADC_CH_CONFIG_BURST_Pos) & SAADC_CH_CONFIG_BURST_Msk);
	
	
	NRF_SAADC->CH[0].PSELP = channel_config.pin_p;
	NRF_SAADC->CH[0].PSELN = channel_config.pin_n;
	
	
	NRF_SAADC->INTENSET = NRF_SAADC_INT_END;
	
	NRF_SAADC->RESULT.PTR = (uint32_t)m_buffer_pool[0];
	NRF_SAADC->RESULT.MAXCNT = SAMPLES_IN_BUFFER;
	
	
	
	
}

void NRF_ADC_Start(void)
{
	NRF_SAADC->TASKS_START = 0x01;
}


//interrupt function
void ADC_IRQHandler(void)
{
	//nrf_gpio_pin_toggle(LED_3);
	printf("test my adc function\r\n");
}
Parents Reply Children
Related