My requirement is as below:
- Sample ADC output for three different ports at a certain frequency
- Transmit a fixed number of samples from the three ports
I will also listen to incoming packets and take certain actions but my problem right now is sampling and tx
When I looked at the code, the wireless tilt mouse code, the ADC registers for P0_1 is read first and right away, ADC register for P0_2 is read. I did not see the initialization of ADCCON registers. Since the ADC registers are being read one after the other, question is since only the current position is of relevance, only the current data is read? It looks like the ADC registers do not retain converted data until read. If only current data is relevant, a fixed number of samples are gathered and sent.
If my assumption is true, how can one sample data from three ports at fixed intervals and get an accurate sense of how the input signal? Which one of the following would be better?
1. use dma, which will move a fixed block of data to memory after sampling thru specified number of input ports
2. use interrupt (which occurs at regular intervals) then in the interrupt read ADC registers for different ports
3. Is it possible at all to use the capture (leading/falling) mode and Read ADC registers for different ports at regular intervals? In this option, I'm thinking, after detecting a change, switch to (2) above to read ADC registers for a certain time period before switching to capture mode?
4. Any other option?
Basically, I guess the question is if DMA is not used, do we lose converted data if there is a delay in reading the ADC register? If so what would be the appropriate method to use to capture most data from all three ports?