I have the EVM and I would like to know where or how to achieve the following function:
Pseudo-code:
1. Start timer T_1 = T_now (in microseconds resolution)
2. Acquire one sample from SAR ADC
3. Process the data
4. Wait (T - Elapsed(T_now - T_1)) (in microseconds resolution)
5. Go back to 1
Step 4 needs to be in real-time microseconds because of the need to sample at 500-1000 kHz for a multiplexed signal. I've been trying to get clock() and CLOCKS_PER_SECOND to work for this purpose but apparently it only ticks when the CPU is doing something in the program. I need something to tick at a constant rate no matter what. What should I look into?
I also need the clock ticks to be sent out as a clock signal with a duty cycle and clock divider that I can change, to synchronize the multiplexer. How to do this?