1.3 AFEC User Sequence

This example uses AFEC peripheral library to sample three analog inputs using the user sequencer in triggered conversion mode and send the converted data to the console.

Description

Conversion of the three analog inputs is triggered from the TC peripheral every 250 ms. The user sequencer is used to define the order of conversion: AD5, AD6 and AD0. The DAC output is fed to the ADC input AD0. The DAC output is changed by 0.1 V when switch is pressed. The AD5 is connected to VCC and the AD6 is connected to GND. Converted digital values are displayed on the console.

Downloading and Building the Application

To clone or download this application from Github, go to the main page of this repository and then click Clone button to clone this repository or download as zip file. This content can also be downloaded using content manager by following these instructions.

Path of the application within the repository is apps/afec/afec_jser_sequence/firmware.

To build the application, refer to the following table and open the project using its IDE.

Project NameDescription
pic32cz_ca70_curiosity_ultra.XMPLABX project for PIC32CZ CA70 Curiosity Ultra Development Kit

Setting Up the Hardware

The following table shows the target hardware for the application projects.

Project NameDescription
pic32cz_ca70_curiosity_ultra.XPIC32CZ CA70 Curiosity Ultra Development Kit

Setting Up PIC32CZ CA70 Ultra Curiosity Development Kit

  • Analog input (AD0) is fed from DAC output. Sine wave output is generated on the DAC output using 100 point lookup table.
    • Analog input "AD0" is mapped to Port Pin "PB1" that is routed to "Pin 14 of the EXT1 header"
    • DAC output "DAC0" is mapped to Port Pin "PB13" that is routed to "Pin 8 of the EXT2 header"
    • Use jumper wire to Connect "Pin 14 of the EXT1" to "Pin 8 of the EXT2"
  • Analog input (AD5) is connected to Vcc, or the user can supply input from an external source
    • Analog input "AD5" is mapped to Port Pin "PC30" that is routed to "Pin 6 of J403 header"
    • Use a jumper wire to connect "Pin 6 of J403" to Vcc or an external voltage source
  • Analog input (AD6) is connected to GND, or the user can supply input from an external source
    • Analog input (AD6) is mapped to Port Pin "PC31" that is routed to "Pin 2 of J403 header"
    • Use a jumper wire to connect "Pin 2 of J403" to GND or an external voltage source
  • Connect 3.3V from pin 4 of J401 to VREFIN pin on J302. This generates 2.048V reference voltage (VREFP) for the DAC.
  • Connect GND from pin 6 of J401 to GND pin on J302.
  • Connect the Debug USB port on the board to the computer using a micro USB cable

Running the Application

  1. Open the Terminal application (Ex.:Tera term) on the computer
  2. Connect to the PICkit4 On Board Virtual COM port and configure the serial settings as follows:
    • Baud : 115200
    • Data : 8 Bits
    • Parity : None
    • Stop : 1 Bit
    • Flow Control : None
  3. Build and Program the application using its respective IDE
  4. Console displays the ADC count and the respective input voltages for all three channels
  5. Press the switch to change the DAC output by 0.1 V from 0 V to 2.048 V
  6. DAC output is connected to CH0. Observe the ADC count and the respective input voltage.
  7. Note that the VREFP for both DAC and AFEC modules is 2.048V. As a result, the DAC and AFEC output will saturate at 2.048V.
Refer to the following table for Switch name: