AM243x Motor Control SDK  2025.00.00
EnDat Diagnostic

The EnDat diagnostic application described here demonstrates the EnDat receiver operation.

The EnDat driver provides a well-defined set of APIs to expose the EnDat receiver interface.

Note
EnDat firmware is tested with ICSS Core Clock running at 200 MHz/300 MHz frequency or ICSS UART Clock running at 192 MHz only.

The diagnostic invokes these APIs to:

  • initialize EnDat,
  • select one configuration among concurrent multi channel with encoders of same make, multi channel with encoders of different make, and single channel configuration based on SysConfig,
  • select the channel (channels in the case of concurrent multi channel with encoders of same make or multi channel with encoders of different make),
  • configure the host trigger mode,
  • and run the firmware.
  • If "Multi-Channel with encoders of different make" configuration is selected:
    • enable load share mode,
    • select primary core for global configuration,
    • configure synchronization bits.

Once these steps are executed:

  • the driver waits for the EnDat to be initialized.
  • It then sets clock frequency to 200KHz (as propagation delay is not yet compensated)
  • and obtains the encoder details including serial number, position resolution etc., and displays them on the console/UART.
  • Based on whether the encoder is 2.2 or 2.1 type, it sets the clock to either 8MHz or 1MHz respectively.
  • While configuring the clock, propagation delay is taken care of using the automatically estimated propagation delay (user can override it too).
  • In the case of concurrent Multi-Channel with encoders of same make or Multi-Channel with encoders of different make, if propagation delays between various channels are different, that too is automatically taken care of.

Once the initial setup is over:

  • the diagnostic provides the user with a self-explanatory menu.
  • Two types of menu options are presented. One type (1-14) will send an EnDat command as per EnDat 2.2 specification.
  • The other type (100-108) allows the user to configure clock frequency, various timing parameters, simulate motor control loop using 2.1 command as well as 2.2 command with safety (redundant position information), switch to continuous clock mode, and monitor raw data.
  • Concurrent multi channel with encoder of same make configuration can work simultaneously for up to three encoders with identical part numbers. All variants of 2.2 position commands as well as the 2.1 position command are supported, and an additional option (109) to configure wire delay (useful when propagation delay in each channel is different) is available.
  • Single PRU core handles enabled channels in single channel and Multi-Channel with encoders of same make configuration.
  • Application by default handles wire delay as required. The menu option provides a way to override it.

After the user selects an EnDat command:

  • the diagnostic asks for more details to frame the command and performs a basic sanity check on the user-entered values.
  • Then the EnDat APIs are invoked to process the command set, set the host trigger bit, and wait until the host trigger bit is cleared. If multi channel with encoders of different make is used, these operations are done for each channel.- The received EnDat data is processed & validated using the defined APIs. The result is then presented to the user.

Channel Selection In SysConfig

Channel Selection In SysConfig
Mode selection based on number of channels and encoder type

Periodic Trigger Modes

The EnDat diagnostic application supports two types of periodic trigger modes for continuous position sampling as described in Periodic Trigger Modes.

CMP Mode (Compare Event Mode)

  • Implementation: Command 200 demonstrates this mode, user can select any position command
  • Configuration: Uses a user-defined compare value to trigger sampling events
  • IEP Counter Reset: Uses CMP0 by default (skip if reset is handled differently)
  • Notification: Firmware triggers an Arm® Cortex®-R5F interrupt after receiving encoder response

CAP Mode (Capture Event Mode)

  • Implementation: Command 201 demonstrates this mode, user can select any position command
  • Router Configuration for CAP6/CAP7 (LATCH_IN0/LATCH_IN1) via TIMESYNC router and CAP0 via GPIOMUX router (requires external GPIO connection)
    • This example configures the TIMESYNC/GPIOMUX router to use IEP SYNC OUT0 as an input signal for the CAP6/CAP7/CAP0 events. This configuration includes:
      • CMP1: Generates SYNC OUT0 signal (skip if not using SYNC OUT0)
    • NOTE: All router configuration is optional if this signal path isn't needed
  • NOTE: When using different CAP events instead of the ones used in SDK example, ensure all related configurations (source selection, signal routing, etc.) are properly done.
  • Notification: Firmware triggers an R5F interrupt after receiving encoder response

Important Notes for Periodic Mode

  1. Initialization: Call endat_command_process() once in host trigger mode before switching to periodic mode
  2. Automatic Behavior: In periodic mode, endat_command_process() skips sending operations (PRU firmware handles triggering via IEP events)
  3. CMP Resource Allocation
    • Avoid using CMP0 if it's already used to IEP counter reset
    • Avoid using CMP1/CMP2 if they're used to SYNC OUT generation
    • Avoid sharing CMP events across different channels or instances of EnDat or other encoders. Each CMP event must be assigned exclusively to a single encoder channel.

Endat Example Implementation

The following section describes the Example implementation of EnDat on Arm®-based core.

Endat Example

Important files and directory structure

Folder/Files Description
${SDK_INSTALL_PATH}/examples/position_sense/endat_diagnostic
endat_diagnostic.c EnDat diagnostic application
${SDK_INSTALL_PATH}/source/position_sense/endat
firmware/ Folder containing EnDat firmware sources
driver/ EnDat diagnostic driver

Supported Combinations

Parameter Value
CPU + OS r5fss0-0 freertos
ICSSG ICSSG0
PRU PRU1 (single channel, multi channel using single PRU)
PRU1, RTU-PRU1, TXPRU1 (multi channel using three PRUs - load share mode)
Toolchain ti-arm-clang
Board am243x-evm, am243x-lp
Example folder examples/position_sense/endat_diagnostic/single_channel
examples/position_sense/endat_diagnostic/multi_channel_single_pru
examples/position_sense/endat_diagnostic/multi_channel_load_share

Single Channel with Single PRU Example

This example supports one EnDat channel using one PRU. In this example:

  • 1 EnDat driver instance and corresponding SysConfig EnDat module instance is used.

Multi Channel with Single PRU Example

This example supports up to three EnDat channels using one PRU. In this example:

  • Encoders of the same frequency must be connected to all configured channels.
  • Data reception must happen simultaneously on all channels.
  • The encoder configuration and cable length should be the same on all channels.
  • If encoders across channels don't respond at the same time, this example will not work. Load share configuration should be used instead.
  • 1 EnDat driver instance and corresponding SysConfig EnDat module instance is used for all channels.

Multi Channel with Multiple PRUs (Load Share) Example

This example supports up to three EnDat channels using three PRUs from same PRU-ICSSG slice. In this example:

  • Load share mode is used. Refer Load Share Mode for more details.
  • Encoders of different make can be connected across channels.
  • Encoders of the same frequency must be connected to all configured channels.
  • Data reception can start independently on all channels.
  • Each channel can have different memory areas, MRS codes, or parameters (command type remains the same).
  • After a command is sent, all channels wait for a response and process the response independently. However, all channels must finish processing before the next command can be triggered.
  • 1 EnDat driver instance and corresponding SysConfig EnDat module instance is used for all channels.

Steps to Run the Example

Other than the basic EVM setup mentioned in EVM Setup , the following additional hardware is required to run this demo:

Hardware Prerequisites with TMDS243EVM

Note
For more design details of the TIDEP-01015 3 Axis Board, or Interface card connecting EVM and TIDEP-01015 3 Axis, please contact TI via E2E/FAE.

Hardware Prerequisites with LP-AM243

Hardware Setup (Using TMDS243EVM, TIDA-00179, TIDEP-01015 and Interface board)

Hardware Setup using TMDS243EVM, TIDA-00179, TIDEP-01015 and Interface board for EnDat

Hardware Setup (Using BP-AM2BLDCSERVO Booster Pack and LP-AM243)

Hardware Setup of BP-AM2BLDCSERVO Booster Pack + LP for EnDat
Note
  • The PROC109A version of LP-AM243 with BP-AM2BLDCSERVO Booster Pack supports two channels
  • To enable the second channel on LP, SW6 needs to be turned OFF
  • To enable VSENSOR1/VSENSOR2, BoosterPack pins J8.73/J8.74 must be set high (In this example, this pin is configured in GPIO mode and pulled high)

BP-AM2BLDCSERVO Booster Pack Jumper Configuration

Designator ON/OFF Description
J11 OFF VSENSE/ISENSE select
J13 OFF VSENSE/ISENSE select
J17 Pin 1-2 Connected SDFM Clock Feedback Select
J18/J19 J19 installed: sets VSENSOR1 to 5.0V Axis 1: Encoder/Resolver Voltage Select
J20/J21 J21 installed: sets VSENSOR2 to 5.0V Axis 2: Encoder/Resolver Voltage Select
J22 OFF Axis 1: Manchester Encoding Select
J23 OFF Axis 2: Manchester Encoding Select
J24 OFF Axis 1: RS485/DSL MUX
J25 OFF Axis 2: RS485/DSL MUX
J26 OFF VSENSE/ISENSE Select
J27 ON Encoder and SDFM Paths Select
J28 OFF AM243/AM263 Mode

Build, load and run

  • When using CCS projects to build, import the CCS project 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 the make command (see Using SDK with Makefiles )
  • Launch a CCS debug session and run the executable, see CCS Launch, Load and Run
  • Refer to the UART terminal for user interface menu options.

Sample Output

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

EnDat Usage

EnDat Debug Guide

This section describes how to debug the EnDat application, including a guide to debugging the EnDat example and firmware. Several common debugging steps on verifying the configuration of key registers, hardware details for probing pins, debugging firmware, common issues with multi channel or continuous mode, etc. are described in Encoder Examples Debug Guide.

If the EnDat interface is not initializing correctly, the steps mentioned below can help identify the root cause. Additionally, ensure that the hardware connections and software configurations are properly set up before proceeding with debugging.

Initialization Failures

In case of initialization failure, perform the following steps to identify the root cause:

  1. Probe the four pins of the connected channel
  2. Load the example and capture signals during the initialization sequence
  3. Compare with the expected initialization communication shown below:
    EnDat Initialization Responses

Verify that the clock frequency is set to 200KHz. The TX and RX signals should show meaningful data exchanges for all initialization commands.

If the initialization communication is incorrect, possible causes include:

  1. Firmware not loaded into the correct PRU core
  2. Firmware stuck due to:
    • No response or incorrect response from encoder
    • Incorrect channel selection or incorrect clock configuration

Troubleshooting steps:

  1. Verify hardware connections
  2. Confirm the pin settings and the clock configuration
  3. If the above are correct, debug the PRU firmware by connecting to the appropriate core as described in the Encoder Examples Debug Guide

Note: For issues occurring after encoder initialization, debug by examining register values and capturing TX, RX, and clock signals.

Test Case Description

S.No Test Details Steps Pass/Fail Criteria
1. To check position value 1. Enter 1 to select "Encoder send position values" CRC success
2. To receive encoder's operating parameters (Error Message) 1. Enter 2 to select "Selection of memory area"
2. Enter "B9" in MRS code to select "Operating parameters" CRC success
3. Enter 4 to select "Encoder to send parameter"
4. Enter 00 in "parameter address" for selecting "Error message" CRC success
3. To receive encoder's operating parameters (Warning message) 1. Enter 2 to select "Selection of memory area"
2. Enter "B9" in MRS code to select "Operating parameters" CRC success
3. Enter 4 to select "Encoder to send parameter"
4. Enter 01 in "parameter address" for selecting "Error message" CRC success
4. To receive encoder's manufacture parameters for Endat 2.2 1. Enter 2 to select "Selection of memory area"
2. Enter "BD" in MRS code to select "Parameters of encoder manufacturer for Endat 2.2" CRC success
3. Enter 4 to select "Encoder to send parameter" CRC success
4. Enter 0 in "parameter address" for selecting "Status of additional info 1" CRC success
5. To set values to encoder's operating parameters (Clear error message) 1. Enter 2 to select "Selection of memory area"
2. Enter "B9" in MRS code to select "Operating parameters" CRC success
3. Enter 3 to select "Encoder to receive parameter"
4. Enter 0 in "parameter address" for selecting "Error message"
5. Enter 0 in "parameter value" for setting value in "Error message" CRC success
6. To set values to encoder's operating parameters (Clear warning message) 1. Enter 2 to select "Selection of memory area"
2. Enter "B9" in MRS code to select "Operating parameters" CRC success
3. Enter 3 to select "Encoder to receive parameter"
4. Enter 01 in "parameter address" for selecting "Error message"
5. Enter 0 in "parameter value" for setting value in "Error message" CRC success
7. To set values to encoder's manufacturing parameters for Endat 2.2 (Status of additional info) 1. Enter 9 to select "Encoder send position values + Additional Information(s) and Selection of memory area"
2. Enter "45" in MRS code to select "Parameters of encoder manufacturer for Endat 2.2" CRC success
3. Enter 9 to select "Encoder send position values + Additional Information(s) and Selection of memory area" CRC success
4. Enter "BD" in MRS code to select "Memory parameter (LSB)" of Additional Information 1 CRC success
5. Enter 10 to select "Encoder send position values + Additional Information(s) and receive parameter"
6. Enter 0 in "parameter address" for selecting "Status of additional info"
7. Enter 1235 (or any 2 byte value) in "parameter value" for setting value in "Status of additional info" CRC success
8. Enter 8 to select "Encoder send position values + Additional Information(s)"
Note: Write is not permanent. When read again using Command 11, encoder will return the default value
Values followed by 0x45 represent the last byte of the data received by encoder
CRC success
8. To reset encoder 1. Enter 5 to select "Encoder receive reset" CRC success
9. To receive test values from encoder with port address "0" 1. Enter 7 to select "Encoder receive test command"
2. Enter 0 in "enter port address"
3. Enter 6 to select "Encoder send test values" CRC success
10. To receive test values from encoder with port address "E" 1. Enter 7 to select "Encoder receive test command"
2. Enter "E" in "enter port address"
3. Enter 6 to select "Encoder send test values" CRC success
11. To check position value with additional info. 1. Enter 9 to select "Encoder send position values + Additional Information(s) and Selection of memory area" CRC success
2. Enter "47" in MRS code to select "Acknowledge MRS code" of Additional Information 1 CRC success
3. Enter 9 to select "Encoder send position values + Additional Information(s) and Selection of memory area"
4. Enter "56" in MRS code to select "Asynchronous Position value word 1 LSB" of Additional Information 2 CRC success
5. Enter 8 to select "Encoder send position values + Additional Information(s)" CRC success
12. To receive encoder's operating parameters (error message)
  • receive position value with additional info
1. Enter 9 to select "Encoder send position values + Additional Information(s) and Selection of memory area"
2. Enter "45" in MRS code to select "Memory parameter (LSB)" of Additional Information 1 CRC success
3. Enter 9 to select "Encoder send position values + Additional Information(s) and Selection of memory area"
4. Enter "B9" in MRS code to select "Operating parameters" CRC success
5. Enter 11 to select "Encoder send position values + Additional Information(s) and send parameter"
6. Enter 0 in "parameter address" for selecting "Error message" CRC success
7. Enter 8 to select "Encoder send position values + Additional Information(s)" CRC success
13. To receive encoder's manufacture parameters for Endat 2.2 + receive position value with additional info 1. Enter 9 to select "Encoder send position values + Additional Information(s) and Selection of memory area"
2. Enter "45" in MRS code to select "Memory parameter (LSB)" of Additional Information 1 CRC success
3. Enter 9 to select "Encoder send position values + Additional Information(s) and Selection of memory area"
4. Enter "BD" in MRS code to select "Parameters of encoder manufacturer for Endat 2.2" CRC success
5. Enter 11 to select "Encoder send position values + Additional Information(s) and send parameter"
6. Enter 0 in "parameter address" for selecting "Status of additional info 1"
7. Enter 8 to select "Encoder send position values + Additional Information(s)" CRC success
14. To acknowledge MRS code for Endat 2.2 1. Enter 9 to select "Encoder send position values + Additional Information(s) and Selection of memory area"
2. Enter "47" in MRS code to select "Acknowledge MRS code" of Additional Information 1 CRC success
3. Enter 9 to select "Encoder send position values + Additional Information(s) and Selection of memory area"
4. Enter "BD" or any other valid MRS code CRC success
5. Enter 8 to select "Encoder send position values + Additional Information(s)" Additional Information 1:0x47bd00
    (for MRS code = BD)
15. To set values to encoder's operating parameters (error message)
  • receive position value with additional info
1. Enter 9 to select "Encoder send position values + Additional Information(s) and Selection of memory area"
2. Enter "B9" in MRS code to select "Operating parameters" CRC success
3. Enter 10 to select "Encoder send position values + Additional Information(s) and receive parameter"
4. Enter 0 in "parameter address" for selecting "Error message"
5. Enter 0 in "parameter value" for setting value in "Error message" CRC success
16. To set values to encoder's manufacturing parameters for Endat 2.2 (Status of additional info)
  • receive position value with additional info
1. Enter 9 to select "Encoder send position values + Additional Information(s) and Selection of memory area"
2. Enter "BD" in MRS code to select "Parameters of encoder manufacturer for Endat 2.2" CRC success
3. Enter 10 to select "Encoder send position values + Additional Information(s) and receive parameter"
4. Enter 0 in "parameter address" for selecting "Status of additional info"
5. Enter 0 in "parameter value" for setting value in "Status of additional info" CRC success
17. To receive encoder's OEM (Original Equipment Manufacturer) data 1. Enter 9 to select "Encoder send position values + Additional Information(s) and Selection of memory area"
2. Enter "45" in MRS code to select "Memory parameter (LSB)" of Additional Information 1 CRC success
3. Enter 9 to select "Encoder send position values + Additional Information(s) and Selection of memory area"
4. Enter A9 (or AB or AD) in MRS code to select the OEM memory CRC success
5. Enter 11 to select "Encoder send position values + Additional Information(s) and send parameter"
6. Enter 40 in "parameter address"
7. Enter 8 to select "Encoder send position values + Additional Information(s)" CRC success
18. To set values in OEM memory area 1. Enter 9 to select "Encoder send position values + Additional Information(s) and Selection of memory area"
2. Enter "A9" in MRS code to select "Operating parameters" CRC success
3. Enter 10 to select "Encoder send position values + Additional Information(s) and receive parameter"
4. Enter 40 in "parameter address"
5. Enter E9 in "parameter value" CRC success
19. To reset encoder + receive position value with additional info 1. Enter 12 to select "Encoder send position values + Additional Information(s) and receive error reset" CRC success
1. Enter 14 to select "Encoder receive communication command" CRC success
2. Enter ______ in "enter encoder address" CRC success
3. Enter _____ in "instruction hex value" CRC success
1. Enter 14 to select "Encoder receive communication command" CRC success
2. Enter ______ in "enter encoder address" CRC success
3. Enter _____ in "instruction hex value" CRC success
20. Configure Clock 1. Enter 100 to select "configure clock"
2. Enter ___ for clock frequency (in Hz) CRC success (Tested up to 8MHz)
21. Simulate motor control 2.1 position loop 1. Enter 101 to select "Simulate motor control 2.1 position loop"
2. Enter 1000 to select "clock frequency"
3. Rotate the rotor of motor and see the changes in Position value on UART Position Values are changing when rotor moves
22. Toggle raw data display 1. Enter 102 to select "Toggle raw data display"
2. Enter 1 to select "Encoder send position value" raw data can be displayed
23. Configure TST delay
24. Start continuous mode 1. Enter 104 to select "Start continuous mode"
2. Rotate the rotor of motor and see the changes in Position value on UART Position Values are changing when rotor moves
25. Configure rx arm counter 1. Enter 105 to select "Configure rx arm counter"
2. Enter 0 to select channel 0
3. Enter ___ to "select time in ns"
26. Configure rx clock disable time 1. Enter 106 to select "configure rx clock disable time"
2. Enter 0 to select channel 0
3. Enter ___ to "select time in ns"
27. Simulate motor control 2.2 position loop (safety) 1. Enter 107 to select "Simulate motor control 2.2 position loop"
2. Enter 1000 to select "clock frequency"
3. Rotate the rotor of motor and see the changes in Position value on UART Position Values are changing when rotor moves
28. Configure propagation delay (td) 1. Enter 108 to select configure propagation delay
2. Enter 0 to select channel 0
29. Configure Recovery time (tr) using EnDat 2.2 mode transmission 1. Enter 9 to select "Encoder send position values + Additional Information(s) and Selection of memory area"
2. Enter "B9" in MRS code to select "Operating parameters"
3. Enter 10 to select "Encoder send position values + Additional Information(s) and receive parameter"
4. Enter 03 in "parameter address" for selecting "Initializing the functions"
5. Enter 01 in "parameter value" for selecting low recovery time
               or
   Enter 02 in "parameter value" for selecting high recovery time
CRC success
30. To read Recovery Time 1. Enter 8 to select "Encoder send position values + Additional Information(s)" CRC Success
2. Enter 110 for read recovery time information Recovery Time is set to 1.25 us <= RT <= 3.75us or 10 us <= RT <= 30 us
31. To test periodic CMP mode 1. Enter 200 to enable periodic CMP mode
2. Enter IEP reset count (in IEP timer count) - the periodic cycle time
3. Enter channel trigger count (in IEP timer count) - when to trigger position read within the cycle
4. Select position command (Valid commands: 1, 8, 9, 10, 11, 13) Position Values are changing when rotor moves
Note: If the selected command requires supplements (e.g., command 9 needs MRS code), the system will prompt for those parameters before the periodic mode starts.
32. To test periodic CAP mode 1. Enter 201 to enable periodic CAP mode
2. Enter IEP SYNC0 period (in IEP time count) - the CAP event generation period
Note: Step 2. valid for AM243x examples, For AM26x it is configured in SysConfig
3. Select position command (Valid commands: 1, 8, 9, 10, 11, 13) Position Values are changing when rotor moves
Note: If the selected command requires supplements (e.g., command 9 needs MRS code), the system will prompt for those parameters before the periodic mode starts.
33. Long term test 1. Enter 111 to enable Long time continuous mode
2. Press enter to stop the long term test The result shows the number of position commands sent and the number of CRC failures received
Note
Arm is a registered trademark of Arm Limited (or its subsidiaries or affiliates) in the US and/or elsewhere.