Other Parts Discussed in Thread: TM4C123GH6PGE
Below is the setup of my LM4F232H5QD on custom board.
- 5 ADC channels : AIN3, AIN8, AIN9, AIN20 and AIN21.
- 5 PWM channels: M0PWM0, M0PWM1, M1PWM0, M1PWM1, and M1PWM2.
Therefore:
- 2 PWM Modules: PWM0 and PWM1
- 3 PWM Generators:
Generator 0 (drives channels 0 and 1) on Module 0
Generator 0 (drives channels 0 and 1) on Module 1
Generator 1 (drives channels 2 and 3) on Module 1
Three of the ADC channels 20, 21 and 8 are event driven from PWM channels 0 - 2 on PWM Module 1 respectively. Two sequences are set up for reading.
Sequence A: Reads AIN20 and AIN21; connected to PWM1, PWM Generator 0, Interrupt Enabled
Sequence B: Reads AIN8, AIN3 and AIN9; connected to PWM1, PWM Generator 1, Interrupt Enabled
I want to use both ADC Modules to capture the three ADC channel data as close to a point in the PWM pulse as possible. I have sync'd the two PWM generator clocks for this testing but plan to undo the coupling later since PWM Generator 0 needs to run at a different frequency than Generator 1.
I set up ADC0 with a single sequence Sequence A (as sequence 0) and ADC1 with single Sequence B (as sequence 0) expecting to capture the data. However, it doesn't work. I am only able to capture ADC0-Sequence A and the interrupt never trips for Sequence B. After many different experiments I was able to put the table together below. If there is only one listed configured sequence, it is sequence 0. If there are two listed, it is sequence 0 and 1.
|
Configuration |
ADC0 |
ADC1 |
Interrupt Events Results |
|
1 |
PWM1Gen0-Sequence A |
PWM1Gen1-Sequence B |
ADC0 (Seq 0) |
|
2 |
PWM1Gen0-Sequence A |
PWM1Gen0-Sequence A |
ADC0 (Seq 0) and ADC1 (Seq 0) |
|
3 |
PWM1Gen0-Sequence A |
PWM1Gen0-Sequence B |
ADC0 (Seq 0) and ADC1 (Seq 0) |
|
4 |
PWM1Gen0-Sequence A PWM1Gen1-Sequence B |
x |
ADC0 (Seq 0 & 1) |
|
5 |
x |
PWM1Gen0-Sequence A PWM1Gen1-Sequence B |
ADC1 (Seq 0 & 1) |
|
6 |
PWM1Gen1-Sequence A |
PWM1Gen1-Sequence B |
no (Seq 0) events |
|
7 |
PWM1Gen1-Sequence A |
x |
no (Seq 0) events |
|
8 |
x |
PWM1Gen1-Sequence B |
no (Seq 0) events |
|
9 |
PWM1Gen0-Sequence (A or B) |
x |
ADC0 (Seq 0) |
|
10 |
x |
PWM1Gen0-Sequence (A or B) |
ADC1 (Seq 0) |
|
11 |
PWM1Gen1-Sequence A PWM1Gen2-Sequence C* |
PWM1Gen1-Sequence B PWM1Gen2-Sequence C* |
random behavior (reset related?) |
|
12 |
PWM1Gen0-Sequence A PWM1Gen2-Sequence C* |
PWM1Gen1-Sequence B PWM1Gen2-Sequence C* |
ADC0 (Seq 0) and ADC1 (Seq 0) No PWM Gen 2 is used. |
*Sequence C: Reads AIN3 again; connected to PWM1, PWM Generator 2, Interrupt Enabled; Dummy sequence mostly.
I conclude from the data gathered that the ADC sequences only work when there is at least one sequence tied to PWM Generator 0 in PWM Module 0 or 1 AND there is at least two sequences in the other ADC Module. I didn't get crazy with four sequence tests. I am unable to find anything in the datasheet that mentions Generator 0 must be used in order or use the ADC Sequence functionality. Only configuration 12 works allowing two “single” sequences to be run on the independent PWM Generator’s with the proper ADC channels connected. Configuration 1 should have been the solution I believe. Though not captured in the table above, I did play with different numbers of ADC channels in the sequence, switched the orders, etc. and none of that had any impact on the results. I also switched the order of the sequences within the same ADC which also had no effect on the results.
Is this a bug in the micro hardware?
TI FYI: It would nice to have a TivaWare function for setting which PWM module is used for ADC trigger(access to the HWREG(ui32Base + ADC_O_TSSEL)).