This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ADC EVENTS_END failed

Hello,

I'm using: nRF51422-QFAA E00 and SDK - nRF51 5.2.0

My problem with ADC is that I stucked when waiting for event - end of conversion. I used the code from Nordic examples called "simultaneous-adc-sampling-from-two-inputs".

Firts strange thing in this code is configuration. Unlike the other examples here they are not using IRQ handler at all and config is:

NRF_ADC->INTENSET = (ADC_INTENSET_END_Disabled << ADC_INTENSET_END_Pos);

Later they force conversion and wait for event (even when it's disabled by config - or event will appear even if interupt for this is disabled?):

// enable ADC		
	NRF_ADC->ENABLE = ADC_ENABLE_ENABLE_Enabled;					  													/* Bit 0 : ADC enable. */		
	
	// start ADC conversion
	NRF_ADC->TASKS_START = 1;
	
	// wait for conversion to end
	while (!NRF_ADC->EVENTS_END)
	{}
	NRF_ADC->EVENTS_END	= 0; 

I always stucked waiting for EVENTS_END. I changed the config to use IRQ and defined IRQ handler but that doesn't help. Finally I found a trick: put 1ms delay between NRF_ADC->ENABLE and TASK_START. But it's not described in Ref. manual or PAN so I don't know if this will help always (I'm working on critical app).

Parents
  • I made some experiments and here is a result:

    If I'm enabling IRQ and handling event inside IRQ handler all works good even without any delay between CONFIG and TASK_START.

    If I'm not using IRQ (ADC_INTENSET_END_Disabled) , events are generated anyway so it's OK to use it as in my first post. BUT delay between CONFIG and TASK START is necessary! As i tried now, 1ms is too much, a few clocks should be enough.

    Since app is critical I'll use IRQ solution coz that seems it's prefered(and tested) by Nordic.

Reply
  • I made some experiments and here is a result:

    If I'm enabling IRQ and handling event inside IRQ handler all works good even without any delay between CONFIG and TASK_START.

    If I'm not using IRQ (ADC_INTENSET_END_Disabled) , events are generated anyway so it's OK to use it as in my first post. BUT delay between CONFIG and TASK START is necessary! As i tried now, 1ms is too much, a few clocks should be enough.

    Since app is critical I'll use IRQ solution coz that seems it's prefered(and tested) by Nordic.

Children
No Data
Related