AM64x MCU+ SDK  08.02.00
PRU ADC (ADS85x8)

Introduction

This example uses ADC ICs from the below list to convert analog input signal on adc channels to samples and store the results in a shared memory which can be configured by the user (using PRU IPC module). The read samples are finally printed to the R5F console, or can also be visualized using CCS Graph plotter. GUI Composer app available on TI Gallery can also be used to evaluate the ADC using a GUI based interface.

The example does the below

  • PRU controls the ADC and reads the samples
  • PRU program implements ADC samples transfer interface
  • PRU then writes the samples to a shared memory and creates an interrupt after writing 1 block of data
  • On interrupt R5F then reads the data and prints it on console

Supported Combinations

Parameter Value
CPU + OS r5fss0-0 freertos
ICSSG ICSSG0 - PRU0
Toolchain ti-arm-clang, pru-cgt
Board am64x-evm
Example folder examples/pru_io/adc/ads85x8/

Steps to Run the Example

  • Setup: Connect the ADC EVM to adapter board and connect the adapter board to AM64x GP EVM. When using "T&M SEM Adapter Board", refer to Important Usage Guidelines for additional details.

  • When using CCS projects to build, import the CCS project from the above mentioned Example folder path for R5F (It will automatically import PRU project) for the required combination.
  • On importing the project, SysConfig will contain an ADC Config instance with default configurations which are compatible with the T&M SEM Adapter Board. Use SysConfig to configure the required settings for the ADC IC.

ADC SysConfig Options
You will need to edit linker file whenever changes are made to the configuration for PRU IPC module, refer Update linker command file
  • Build only the R5F project using the CCS project menu (see Using SDK with CCS Projects).

    • Build Flow: Once you click on build in R5F project, first, SysConfig files are generated, then the PRU project is compiled according to the configurations set in SysConfig. Finally the R5F project will be generated using both the generated SysConfig and PRU project binaries.
    • Note: The PRU project won't build independently as it is dependent on SysConfig files generated by the R5F project.
    Note
    Prerequisite: PRU-CGT-2-3 (ti-pru-cgt) should be installed at: C:/ti/
  • Launch a CCS debug session and run the executable, see CCS Launch, Load and Run

Features

Supported:

  • Parallel 8 Bit Interface
  • Parallel 16 Bit Interface
  • Interrupt on receiving a block of data
  • ADC, Pinmux and other configurations through SysConfig interface

Not Supported:

  • Serial Interface

Important Usage Guidelines

To evaluate ADS8598H use the ADS8588SEVM-PDK but solder the ADS8598H part in place of ADS8588S. To connect the boards use T&M SEM Adapter Board, and connect it with ADC EVM and AM64x GP EVM

  • When interfacing with T&M SEM Adapter Board, AM64x GP EVM requires some hardware changes as mentioned:

AM64x GP EVM Changes
  • Make sure the J9 jumper on the adapter board is in "Parallel" mode for ADS85xx adcs for all modes of interface (serial, parallel or byte-parallel).
  • From now on, T&M SEM Adapter Board won't be available for purchase, and Schematics and other details about this board can be found at: T&M SEM Adapter Board files
  • AM64x Adapter Board will be mainly supported in future as this will be replacing the T&M SEM Adapter Board once it becomes available in March 2022.

Important files and directory structure

Folder/Files Description
${SDK_INSTALL_PATH}/source/pru_io/
firmware/ PRU source files providing macros for interfaces, pru_ipc, etc.
driver/ PRU IPC source files for sending ADC samples from PRU to R5F

Sample Output

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

--------------------------------------------------
Initializing ADC
--------------------------------------------------
Powering up ADC
--------------------------------------------------
Resetting ADC
--------------------------------------------------
Starting ADC Conversion
Started
----- Channel: 1 -----
Sample 1: 50308
Sample 2: 50304
Sample 3: 50304
Sample 4: 50304
----- Channel: 2 -----
Sample 1: 50308
Sample 2: 50304
Sample 3: 50304
Sample 4: 50304

Implementation Details

The control of ADC pins is divided between PRU and R5F cores as shown:

PRU ADS85x8 Setup

R5F Function:

  • Initialize ADC and PRU
  • Send instructions to PRU core
  • Wait for interrupt from PRU indicating 1 block of adc samples has been received
  • On interrupt fetch the block id to read and read the samples
  • Process them as needed
ADC_init();
ADC_powerUp();
ADC_reset();
ADC_startConversion();
/* Get ADC data from PRU */
PRU_IPC_getData(gPruIpc0Handle, samples);

PRU Function:

  • Wait for commands from R5F and do accordingly While executing ADC interface section:
  • Wait for ADC Busy to go low indicating conversion has completed
  • Start reading samples from each ADC channel
  • Preprocess samples as required
  • Send samples to shared memory using ipc
  • Repeat above steps again
START:
; Wait for Busy to go low indicating conversion has completed
m_wait_high_pulse 4, 16
; Fetch and store channel 1-8 Sample
m_parallel_read_packet ADC_COMM_MODE, ADC_COMM_INTERFACE, ADC_COMM_DATAWIDTH, ADC_COMM_TRIG_PRD, ADC_DATA_REG_1
m_parallel_read_packet ADC_COMM_MODE, ADC_COMM_INTERFACE, ADC_COMM_DATAWIDTH, ADC_COMM_TRIG_PRD, ADC_DATA_REG_2
m_parallel_read_packet ADC_COMM_MODE, ADC_COMM_INTERFACE, ADC_COMM_DATAWIDTH, ADC_COMM_TRIG_PRD, ADC_DATA_REG_3
m_parallel_read_packet ADC_COMM_MODE, ADC_COMM_INTERFACE, ADC_COMM_DATAWIDTH, ADC_COMM_TRIG_PRD, ADC_DATA_REG_4
m_parallel_read_packet ADC_COMM_MODE, ADC_COMM_INTERFACE, ADC_COMM_DATAWIDTH, ADC_COMM_TRIG_PRD, ADC_DATA_REG_5
m_parallel_read_packet ADC_COMM_MODE, ADC_COMM_INTERFACE, ADC_COMM_DATAWIDTH, ADC_COMM_TRIG_PRD, ADC_DATA_REG_6
m_parallel_read_packet ADC_COMM_MODE, ADC_COMM_INTERFACE, ADC_COMM_DATAWIDTH, ADC_COMM_TRIG_PRD, ADC_DATA_REG_7
m_parallel_read_packet ADC_COMM_MODE, ADC_COMM_INTERFACE, ADC_COMM_DATAWIDTH, ADC_COMM_TRIG_PRD, ADC_DATA_REG_8
; Sign extend data to 32 bits
m_sign_ext_32bit ADC_DATA_REG_1
m_sign_ext_32bit ADC_DATA_REG_2
m_sign_ext_32bit ADC_DATA_REG_3
m_sign_ext_32bit ADC_DATA_REG_4
m_sign_ext_32bit ADC_DATA_REG_5
m_sign_ext_32bit ADC_DATA_REG_6
m_sign_ext_32bit ADC_DATA_REG_7
m_sign_ext_32bit ADC_DATA_REG_8
; Send samples to R5F
ldi R1.b0, &R2
m_pru_ipc_send R1.b0, R2, R0.b0, PRU_IPC_RX_INTR_ENABLE, PRU_IPC_RX_EVENT
; Check if there is some instruction from R5F
m_prgm_flow_jump_on_intr 0x16, 31, 5, TEMP_REG_1, IDLE, task_manager, sample_transfer, iep, main_loop
qba START ; loop
halt
The current firmware does sign extension of 18bits data to 32 bits data. For ADCs with resolution 16 bits, replace the macro m_sign_ext_32bit in examples/pru_io/adc/ads85x8/firmware/main.asm with m_sign_ext_16to32_bits.

Refer to PRU Source Macros Documentation for making changes to PRU firmware.