1. Configuration

1.1. System Example Configuration

If you wish to change the default configuration of the system example, edit the example’s header file.

Listing 1.1 /solutions/boostxl_posmgr/shared/include/tformat.h
//
// Indicate which commands should be run.  This can be helpful
// for debug or benchmarking
// 1 == run command
// 0 == skip command
//
//*****************************************************************************
#define TFORMAT_RUN_ID0     1
#define TFORMAT_RUN_ID1     1
#define TFORMAT_RUN_ID2     1
#define TFORMAT_RUN_ID3     1
#define TFORMAT_RUN_IDD_ID6 1  // EEPROM read and write
#define TFORMAT_RUN_ID7     1
#define TFORMAT_RUN_ID8     1
#define TFORMAT_RUN_IDC     1

//*****************************************************************************
//
// The duration of a single bit is 2.5 MHz (400ns)
// First determine the number of CLB clocks within
// a 400 ns period. Then divide this by 2, in order
// to create a clock within the CLB with a 400ns period.
//
// Define the number of CLB clocks required to generate for the bus clock
// Define the number of CLB clocks within a bit-width
//
//*****************************************************************************
#if defined(_F2837X)
#define TFORMAT_CLB_CLOCK       100ul // MHz

#elif defined(_F2838X)
#define TFORMAT_CLB_CLOCK       100ul // MHz

#elif defined(_F28004X)
#define TFORMAT_CLB_CLOCK       100ul // MHz

#elif defined(_F28003X)
#define TFORMAT_CLB_CLOCK       120ul // MHz

#elif defined(_F28002X)
#define TFORMAT_CLB_CLOCK       100ul // MHz

#elif defined(_F28P65X)
#define TFORMAT_CLB_CLOCK       100ul // MHz

#else
#error Specify the CLB clock rate for the specific device
#endif
#define TFORMAT_BUS_CLOCK       2.5f // MHz
#define TFORMAT_FREQ_DIVIDER    (TFORMAT_CLB_CLOCK /                           \
                                    (uint16_t) (2.0f * TFORMAT_BUS_CLOCK) )
#define TFORMAT_BIT_WIDTH       (TFORMAT_CLB_CLOCK /                           \
                                    (uint16_t) (TFORMAT_BUS_CLOCK) )

//*****************************************************************************
//
// For EEPROM read/write testing, specify the range of addresses to be used
//
// Note: Select addresses between 0 and 126 (0x7E).
//       Address 127 (0x7F) is the EEPROM page control.
//
//*****************************************************************************
#define TFORMAT_EEPROM_TEST_ADDR_START  0x73u
#define TFORMAT_EEPROM_TEST_ADDR_END    0x7Eu

//*****************************************************************************
//
// Delay time, in micro-seconds, between each command sent
// The increment is used to vary the time between commands for testing
//
//*****************************************************************************
#define TFORMAT_IDLE_DELAY_US_START       10ul
#define TFORMAT_IDLE_DELAY_US_INCREMENT   15ul

//*****************************************************************************
//
// Time to wait after a write to the EEPROM before another write/read
//
//*****************************************************************************
#define TFORMAT_EEPROM_BUSY_US 18000ul

//*****************************************************************************
//
// Power-on to normal operation delay 1.5 seconds. Refer to the data manual
// for a specific encoder.
//
//*****************************************************************************
#define TFORMAT_POWER_ON_DELAY_US 1500000ul

//

1.2. Library Configuration

If you wish to change the default configuration of the library, edit the library’s public header file.

Note

  • If you change the library configuration then recompile both the library and the system example.

  • CRC generation by the CLB requires CLB type 2 or later. This will use additional CLB resources, but frees C28x bandwidth.

Listing 1.2 /libraries/position_sensing/tformat/include/pm_tformat_include.h
//
// #define PM_TFORMAT_SPI  SPIA_BASE, SPIB_BASE, SPIC_BASE, SPID_BASE
//      Define which SPI peripheral is used.  This must match which instance
//      the CLB is clocking and connected to the RS485 bus.
//      Note: The CLB output configuration may need to be modified if this
//      selection is changed.  Refer to the design guide for more information.
//
// #define PM_TFORMAT_CLB_INPUTXBAR
//      Define this identifier if the CLB has an INPUTXBAR and OUTPUTXBAR
//      The system initialization routine will call the appropriate functions
//      based on this define.
//
// [doc-library-crc-config-start]
//
// Define how the CRC is generated. Supported options are:
//
// #define PM_TFORMAT_RX_CRC_BY_C28X
// #define PM_TFORMAT_TX_CRC_BY_C28X
//     The CRC for the data (TX or RX) is generated by the C28x using a
//     lookup table. This method takes the most C28x bandwidth and
//     memory.
//
// #define PM_TFORMAT_RX_CRC_BY_CLB
//     The received data CRC is generated on-the-fly by the CLB as the
//     data is received.
//     This requires 1 CLB tile.
//     This option requires CLB type 2 or later.
//
// #define PM_TFORMAT_TX_CRC_BY_VCRC
//     The transmit data CRC is generated by the VCRC extension to the C28x.
//     This option requires that the device has the VCRC extension.
//
// [doc-library-crc-config-end]
//
//*****************************************************************************

#if defined(_F2837X) || defined(F2837x_DEVICE)
    #define PM_TFORMAT_SPI              SPIB_BASE
    #define PM_TFORMAT_RX_CRC_BY_C28X
    #define PM_TFORMAT_TX_CRC_BY_C28X
    #define PM_TFORMAT_USE_LEGACY_TERMINOLOGY

#elif defined(_F28002X) || defined(F28002x_DEVICE)
    #define PM_TFORMAT_SPI              SPIB_BASE
    #define PM_TFORMAT_RX_CRC_BY_CLB
    #define PM_TFORMAT_TX_CRC_BY_VCRC
    #define PM_TFORMAT_USE_CLB_INPUTXBAR
    #define PM_TFORMAT_USE_LEGACY_TERMINOLOGY

#elif defined(_F28004X) || defined(F28004x_DEVICE)
    #define PM_TFORMAT_SPI              SPIB_BASE
    #define PM_TFORMAT_RX_CRC_BY_CLB
    #define PM_TFORMAT_TX_CRC_BY_C28X
    #define PM_TFORMAT_USE_LEGACY_TERMINOLOGY

#elif defined(_F28003X) || defined(F28003x_DEVICE)
    #define PM_TFORMAT_SPI              SPIB_BASE
    #define PM_TFORMAT_RX_CRC_BY_CLB
    #define PM_TFORMAT_TX_CRC_BY_VCRC
    #define PM_TFORMAT_USE_CLB_INPUTXBAR
    #define PM_TFORMAT_USE_LEGACY_TERMINOLOGY

#elif defined(_F2838X) || defined(F2838x_DEVICE)
    #define PM_TFORMAT_SPI              SPIB_BASE
    #define PM_TFORMAT_RX_CRC_BY_CLB
    #define PM_TFORMAT_TX_CRC_BY_VCRC
    #define PM_TFORMAT_USE_CLB_INPUTXBAR
    #define PM_TFORMAT_USE_LEGACY_TERMINOLOGY

#elif defined(_F28P65X) || defined(F28P65x_DEVICE)
    #define PM_TFORMAT_SPI              SPID_BASE
    #define PM_TFORMAT_RX_CRC_BY_CLB
    #define PM_TFORMAT_TX_CRC_BY_VCRC
    #define PM_TFORMAT_USE_CLB_INPUTXBAR
    #define PM_TFORMAT_USE_INCLUSIVE_TERMINOLOGY

#else
    #error Device should match a predefined symbol in the build options.
#endif


#if(PM_TFORMAT_SPI == SPIB_BASE)
    #define PM_TFORMAT_INT_SPI_RX       INT_SPIB_RX
#elif(PM_TFORMAT_SPI == SPIA_BASE)
    #define PM_TFORMAT_INT_SPI_RX       INT_SPIA_RX
#elif(PM_TFORMAT_SPI == SPID_BASE)
    #define PM_TFORMAT_INT_SPI_RX       INT_SPID_RX
#else
#error Update SPI code for the correct instance.
#endif

//
// Do we need to build the C28X CRC lookup table?
// Indicates C28x lookup table for a CRC calculation is being used.
//
#if(defined(PM_TFORMAT_RX_CRC_BY_C28X) || defined(PM_TFORMAT_TX_CRC_BY_C28X) )
    #define PM_TFORMAT_CRC_TABLE
#endif

//
// Do some checking of the defined configuration
//
#if(defined(_F28379D) &&                                                       \
            ( defined(TFORMAT_RX_BY_CLB) || defined(TFORMAT_TX_BY_CLB) ) )
{
    #error CRC by CLB is not supported on this device.  Use C28x lookup table.
}
#endif
#if(defined(_F28379D) && defined(TFORMAT_TX_BY_VCRC))
{
    #error VCRC is not supported on this device.  Use C28x lookup table.
}
#endif
#if(defined(_F28004X) && defined(TFORMAT_TX_BY_VCRC))
{
    #error VCRC is not supported on this device.  Use C28x lookup table.
}
#endif

//