I am using SDK version 15, SES IDE.
I am working on Dust sensor, for that i am using SAAADC example code, I want to read the ADC value from the pin, like this:
ADC_read_pin from channel1 within this delay(below)(which means i want to read ADC in a particular delay)
Can anyone suggest me, how to write this, by using SAADC example code.
Thanks in advance
The SAADC example, which I assume you have seen, uses a timer to trigger the samples.
If you want to trigger a sample after 320µs, you can change the line in the saadc_sampling_event_init():
uint32_t ticks = nrf_drv_timer_ms_to_ticks(&m_timer, 400);
uint32_t ticks = nrf_drv_timer_us_to_ticks(&m_timer, 320);
Then it will do one sample every 320µs.
Is the pin toggle needed in your application, or is it only to see that it is happening?
The reason I ask is because there is not application interrupt when the example trigger a sample. It uses the PPI to link the task_sample() function call to the timeout event. If you want the timeout event, you must call nrf_drv_timer_extended_compare() with "true" as the last parameter.
You will get the saadc_callback every time the sample call has been called (and finished) N times, where N is the size of your SAADC buffer (=SAMPLES_IN_BUFFER).
Thank you for your suggestion.Here i am attaching the application code for Dust sensor, actually i have to do like this:dustSensor.ino
Kindly suggest me for this, till then i will also try with your suggestion.
I didn't know you were using Arduino. What kind of board do you have? Do you have a site where you find your projects? I am not sure whether you can use the regular SDK. That depends on what programming chip that is on the board (if any).
I am not using any Arduino board, just i am referring this code, so i want to write code according to attached file, so just keep it for reference, so suggest for the same.I have to write the same code for Nordic nrf52810, in SAADC example SDKv15
Things are a bit different when you use the SDK. I suggest that you take a look at the SAADC example in SDK15 (which you can find here).