Hello Dialog,
I'd like to use adc at around 500~1k Hz sampling rate, which requires ~1us level time delay. The code snippet is kind of:
adc_init(GP_ADC_SE, 0, GP_ADC_ATTN3X);
adc_enable_channel(ADC_CHANNEL_P01);
for-loop:
int data = adc_get_sample();
排队(数据);
delay(1us);
Previously I use the software timer app_easy_timer but I found the minimum delay of the easy timer is 10ms which is too large. When I search for timer0 I found they are mainly for PWM, audio, etc. My question is 1) How can I generate ~1us delay? If using timer0, are there any code snippets? 2) Does timer0 work during extended sleep mode? Thanks!
Keywords:
Device:
Hi sentimental,
Timer0 has an interrupt functionallity and you will be able to sync the ADC read using that interrupt feature, regarding how to set up the timer0 interrupt function, you can use the timer0_general example. Regarding the 1us delay (500Hz to 1KHz is 2ms and 1ms period not 1us) you can configure the timer0 to generate an interrupt with that period. Regarding the sleep, all the peripherals are shut down including the timers and the adc.
Thanks MT_dialog