SPRUII0F May 2019 – June 2024 TMS320F28384D , TMS320F28384D-Q1 , TMS320F28384S , TMS320F28384S-Q1 , TMS320F28386D , TMS320F28386D-Q1 , TMS320F28386S , TMS320F28386S-Q1 , TMS320F28388D , TMS320F28388S
FILE: adc_ex16_sw_interleaved_averaging.c
This example demonstrates software interleaved averaging of ADC input channels. ADCA/B channel 0 and 1 are sampled one after another in order to achieve interleaved averaging. SOC0-15 of ADCA and ADCB are configured to sample channel 0 and 1 alternatively with channel 0 being sampled by even SOCs namely SOC0, 2, 4, 6, 8, 10, 12 & 14 and channel 1 being sampled by odd SOCs namely SOC1, 3, 5, 7, 9, 11, 13 & 15.
Sampling is initially triggered through external GPIO signal through enabling ADCEXTSOC signal via input XBAR and thereafter through ADCINT1. GPIO33 is configured to trigger ADCA and B SOCs for the first time in order to ensure synchronous operation. GPIO33 needs to be connected to GPIO32 which in turn is driven by software to trigger the respective ADC SOCs.
ADCA Interrupt ISRs are used to read results of both ADCA and ADCB to demonstrate parallel operation of multiple ADCs. ADCINT2 is configured to be triggered after completion of SOC7 while ADCINT1 is configured to be triggered after completion of SOC15 conversion and respective SOC results of ADCA and ADCB are read in ADCAINT2 and ADCAINT1 ISRs. Read SOC0-SOC15 ADC results are then averaged in ADCINT1 ISR to get the filtered ADC output.
Early interrupt mode is configured to trigger the ADC interrupt just at the end of acquisition window in order to save cycles(~42 cycles) since ADCA result of SOC7 in ADCINT2 and SOC15 in ADCINT1 are read post around 60 and 65 cycles respectively. Also, Fast ISRs are configured in the example to save some cycles during compiler specific context save and restore.
Optimization level: This example is expected to be run with opt level = 2
Sampling rate related calculations:
To view results in graph window, add breakpoint inside while(1) loop in main() where bufferFull flag is cleared and plot the watch variables.
External Connections
Watch Variables