AM263x MCU+ SDK  09.02.00
ADC Software Interleaved Averaging

Introduction

This example showcases the software interleaved averaging of samples on channel 0,1 on ADC 1 and 2.

Software Interleaved Averaging

Example Description :

  • This Example Demonstrates Software Interleaved Averaging of ADC input channles. Channels 0 and 1 of ADC 1 and ADC 2 are sampled one after ther other in order to achieve he interleaved averaging.
  • Initially, a GPIO-->InputXbar[5] trigger is provided for the ADCs. thereafter, the SOC/EOC15 will trigger ADCxINT1, hence triggering all SOCs.
  • ISRs configured for ADC1_INT1 and ADC1_INT2, read results for SOCs completed so far in the conversion cycle and average them.

SOC Configurations :

  • "Even" SOCs (0,2,4,6,8,10,12,14) sample Channel 0
  • "Odd" SOCs (1,3,5,7,9,11,13,15) sample Channel 1
  • All SOC are triggered by INPUTXbar[5] and are also configured to be triggered by ADCxINT1 (generated by respective SOC/EOC15)
  • ADCx_INT1 triggers all the SOC in given ADCx

Interrupt configurations :

  • ADC2_INT1 interrupt source is ADC2_EOC/SOC15
  • ADC1_INT1 interrupt source is ADC1_EOC/SOC15
  • ADC1_INT2 interrupt source is ADC1_EOC/SOC7
  • ADCxINTy are configured as Early interrupts (end of acquisition period)

ISR details

  • ISR (App_adcISR_EOC7) is triggered by ADC1_INT2 (interrupt source is ADC1_EOC/SOC7) is used to read the SOC results of SOC 0-7
  • ISR (App_adcISR_EOC15) is triggered by ADC1_INT1 (interrupt source is ADC1_EOC/SOC15) and is used to read the SOC results of SOC 8-15

NOTE:

  • The ISRs are supposed to complete and clear the INT flags before triggering of next flag to ensure the ISRs are serviced again, as well as the SOCs are triggered.

External Connections :

AM263PX-CC E2

  • input trigger pulse on GPIO 69 (configured as input) - HSEC connecter pin - 153 or connect it to GPIO 70 (Configured as output) - HSEC Connecter pin - 154
  • feed analog input on ADC 1 Channel 0 - HSEC connecter pin - 12
  • feed analog input on ADC 1 Channel 1 - HSEC connecter pin - 14
  • feed analog input on ADC 2 Channel 0 - HSEC connecter pin - 31
  • feed analog input on ADC 2 Channel 1 - HSEC connecter pin - 33

AM263PX-LP

  • input trigger pulse on GPIO 16 (configured as input) - J6/J8 pin - 79 or connect it to GPIO 15 (Configured as output) - J6/J8 Jpin - 80
  • feed analog input on ADC 1 Channel 0 - J1/J3 Pin - 24
  • feed analog input on ADC 1 Channel 1 - J1/J3 Pin - 29
  • feed analog input on ADC 2 Channel 0 - J1/J3 Pin - 25
  • feed analog input on ADC 2 Channel 1 - J5/J7 Pin - 63

AM263X-CC E2

  • input trigger pulse on GPIO 7 (configured as input) - HSEC connecter pin - 80 or connect it to GPIO 8 (Configured as output) - HSEC Connecter pin - 82
  • feed analog input on ADC 1 Channel 0 - HSEC connecter pin - 12
  • feed analog input on ADC 1 Channel 1 - HSEC connecter pin - 14
  • feed analog input on ADC 2 Channel 0 - HSEC connecter pin - 31
  • feed analog input on ADC 2 Channel 1 - HSEC connecter pin - 33

AM263X-CC E1

  • input trigger pulse on GPIO 7 (configured as input) - HSEC connecter pin - 80 or connect it to GPIO 8 (Configured as output) - HSEC Connecter pin - 82
  • feed analog input on ADC 1 Channel 0 - HSEC connecter pin - 18
  • feed analog input on ADC 1 Channel 1 - HSEC connecter pin - 20
  • feed analog input on ADC 2 Channel 0 - HSEC connecter pin - 24
  • feed analog input on ADC 2 Channel 1 - HSEC connecter pin - 26

AM263X-LP

  • input trigger pulse on GPIO 16 (configured as input) - J5/J7 pin - 47 or connect it to GPIO 15 (Configured as output) - J6/J8 Jpin - 58
  • feed analog input on ADC 1 Channel 0 - J1/J3 Pin - 24
  • feed analog input on ADC 1 Channel 1 - J1/J3 Pin - 29
  • feed analog input on ADC 2 Channel 0 - J1/J3 Pin - 25
  • feed analog input on ADC 2 Channel 1 - J5/J7 Pin - 63

Watch variables:

  • gAdc1Channel0Results - array of averaged Analog to Digital Converted samples on channel 0 of ADC 1
  • gAdc1Channel1Results - array of averaged Analog to Digital Converted samples on channel 1 of ADC 1
  • gAdc2Channel0Results - array of averaged Analog to Digital Converted samples on channel 0 of ADC 2
  • gAdc2Channel1Results - array of averaged Analog to Digital Converted samples on channel 1 of ADC 2

Supported Combinations

Parameter Value
CPU + OS r5fss0-0 nortos
Toolchain ti-arm-clang
Board am263x-cc, am263x-lp
Example folder examples/drivers/adc/adc_sw_interleaved_averaging/

Steps to Run the Example

  • When using CCS projects to build, import the CCS project for the required combination and build it using the CCS project menu (see Using SDK with CCS Projects).
  • When using makefiles to build, note the required combination and build using make command (see Using SDK with Makefiles)
  • Establish connections as mentioned in External Connections section.
  • Launch a CCS debug session and run the executable, see CCS Launch, Load and Run
  • Using the watch variables, view the ADC conversion results.
  • View the ADC conversion results in UART console logs

See Also

ADC

Sample Output

Shown below is a sample output when the application is run,

ADC Software Interleaved Averaging Test Started ...
ADC-1-Channel-0 ADC-1-Channel-1 ADC-2-Channel-0 ADC-2-Channel-1
4095 0 0 4095
4095 0 0 4095
4095 0 0 4095
4095 0 0 4095
4095 0 0 4095
4095 0 0 4095
4095 0 0 4095
4095 0 0 4095
ADC Software Interleaved Averaging Test Passed
All tests have passed!!