Currently I'm doing the following loop in firmware. I'd like to offload the processor and do this directly in the hardware:
1. Drive GPIOx1 high and drive GPIOx2 low
2. Initiate a read on the ADC and wait for the conversion to complete
3. Add result of ADC to a running total
4. Drive GPIOx1 low and drive GPIOx2 high
5. Initiate a read on the ADC and wait for the conversion to complete
6. Subtract result of ADC from a running total
To move this into hardware, my thoughts are as follows, but I'm looking for guidance and/or gotchas:
Some questions:
Hi Robert
See appendix A/section E of http://www.utasker.com/docs/uTasker/uTaskerADC.pdf
This shows how a TPM module can be used to trigger inputs A and B of ADC modules. If you set up DMA transfer to a buffer on each output conversion (reference in chapter 3 of the same document) and a defined length you can automate the operation to stop after a certain number of samples with an interrupt - the samples can then be summed and negated in SW after it has completed (or while a following sequence of samples is taking place).
Since you have 6 PWM channels on TPM0 in the KL27 you can use two for the ADC triggering (controlled points in the cycle) and two for the output square waves that you require (which are fully synchronised). See chapter 5 of http://www.utasker.com/docs/uTasker/uTaskerHWTimers.PDF whereby you can control anti-phased outputs using ELSA (low true pulses)/ELSB (high true pulses) settings
Regards
Mark
uTasker developer and supporter (+5'000 hours experience on +60 Kinetis derivatives in +80 product developments)
Kinetis: http://www.utasker.com/kinetis.html
Kinetis KL25, KL26, KL27, KL28, KL82, KL43, KL46
- http://http://www.utasker.com/kinetis/FRDM-KL25Z.html
- http://www.utasker.com/kinetis/TWR-KL25Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL26Z.html
- http://www.utasker.com/kinetis/TEENSY_LC.html
- http://www.utasker.com/kinetis/FRDM-KL27Z.html
- http://www.utasker.com/kinetis/Capuccino-KL27.html
- http://www.utasker.com/kinetis/FRDM-KL28Z.html
- http://www.utasker.com/kinetis/FRDM-KL82Z.html
- http://www.utasker.com/kinetis/FRDM-KL43Z.html
- http://www.utasker.com/kinetis/TWR-KL43Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL46Z.html
- http://www.utasker.com/kinetis/TWR-KL46Z48M.html