Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

Configuring HALCoGen for using TPS Driver

From Texas Instruments Wiki
Jump to: navigation, search


The TPS65381-Q1 device is a multi-rail power supply designed to supply microcontrollers in safety-critical applications, such as those found in automotive applications. The device supports Texas Instruments HerculesTM family of 16/32-bit RISC flash Safety MCU and other microcontrollers with dual-core lockstep (LS) or loosely-coupled architectures (LC). The TPS6538x driver library is a software library for the Hercules Safety MCU which provides driver level API to interface the Hercules MCU with TPS6538x power supply chip and make use of the various TPS6538x device features such as voltage monitoring, watchdog monitoring, error monitoring etc.

The TPS65381-Q1 device integrates multiple supply rails to power the MCU, CAN, or FlexRay, and an external sensor. An asynchronous-buck switch-mode power-supply converter with an internal FET converts the input battery voltage to a 6-V pre-regulator output. This 6 V supplies the other regulators. Furthermore, the device supports wake-up from IGNITION or wake-up from the CAN transceiver

The Safety Diagnostic Library version 2.1.0 provides TPS Driver for the TPS65381-Q1.The Driver can be used with all the members of the Hercules Device Family.This wiki page provides and example Halcogen configuration created for the TMS570LS31x Hitex Safety Kit so as to use the TPS driver.

TPS Driver Usage in end application

The TPS library provides driver level API to interface the Hercules device with TPS and make use of the various TPS device features such as voltage monitoring, watchdog monitoring, error monitoring etc.Below block diagram shows the usage of the TPS driver (library) in the end application.

TPS Driver usage in end application

TPS65381 and TMS570LS31 interfacing in HiTex Kit

Below figure shows the interfacing of the TPS65381 to TMS570LS31 in the TMS570LS31x HiTex Safety Kit.

TPS65381 and TMS570LS31 interfacing in the TMS570LS31x HiTex Safety Kit

As Shown in the figure.The peripherals of the TMS570LS31x device needs to be configured are

Peripherals which are mandatory

  • MibSPI5 - for communication
  • ADC1 - for reading the DIAG_OUT pin from the TPS

Optional peripherals to be configured

  • GPIOA - for reading the status of the ENDRV pin.If application needs to check the status of the ENDRV then this peripheral has to be enabled and configured.
  • SCI2 - The TPS Driver provides debug support API.If this debug support API are to be used then SCI2 needs to be configured for serial communication.
  • RTI - The RTI module in case of the demo application provided in the Diagnostic Library package is used for getting the timer interrupts to service the watchdog module in the TPS device.

The following sections describe in detail the HALCoGen configuration for usage of the TPS Driver.

HALCoGen Configuration

The following sections detail the HALCoGen Configuration considering the HALCoGen ver 4.0.0.

Driver Enable Tab

In the driver enable tab enable RTI,GIO,MIBSPI3,SCI2,ADC1.Below figure shows the configuration of the driver enable tab.

Driver enable tab configuration


Please enable the pinmux for GIOA,MibSPI3 and SCI.Resolve the pinmux conflict on ball W9 by deselecting MIBSPI3NCS_5. Below figure shows the configuration of the pinmux tab.

PINMUX configuration

MibSPI configuration

The HiTex KIT interfaces the Hercules MCU to the TPS65381 PMIC using the MibSPI3 port. NOTE: Some custom boards may also use a SPI port for interfacing to TPS device, e.g, the RM46 Motor Control card uses SPI interface with the TPS device. While most settings are common to a SPI and MibSPI peripheral port interface to the TPS65381 for SPI port interface there will be no transfer group configuration.The configuration of delay,data formats will still be valid. As part of the TPS driver initialization user should pass a pointer to a function of protoype boolean SendandRecieveDataTPS(const uint16* const u16TransmitData,const uint32 u32TransmitSize,volatile uint16* u16RecieveData,uint32 *u32RecieveSize); (this function does send command and recieve response from TPS device) this application implemented function internally uses the MibSPI driver provided API to implement the required functionality.Do have a look at the TPS Driver user guide provided as part of the Diagnostic Library Package for more information

MibSPI Data formats

The figure below shows the MibSPI data formatting needed for effectively communicating to TPS Device. As noted above, the same will be valid even if interfacing over an SPI port.

MibSPI data format configuration

MibSPI delays

The figure below shows the MibSPI delay configuration needed for effectively communicating to TPS Device. Again, as noted above, the same will be valid even for an SPI port.

MibSPI delays configuration

MibSPI Transfer group configuarion

The figure below shows the MibSPI Transfer group configuration needed for effectively communicating to TPS Device. This configuration is not available when an SPI port is used for interfacing the TPS Device.

MibSPI Transfer group configuration

SCI Configuration

The TPS Driver provides debug support API.If user needs to use the debug features of the driver he needs to provide a pointer to the function which handles debug text transmission as part of the TPS Driver initialization(a function of prototype boolean SendDebugTextTPS(const uint8 * const u8textbuf,const uint32 u32textlength)).One of the ways to implement this function is to use the SCI2 (UART) and pass the debug text to the serial terminal.The user can configure SCI for UART communication as necessary.

RTI Configuration

The RTI module in the TMS570LS31x device can be used to generate the required timer interrupts so as to service the watchdog(if enabled).In the demo application provided along with the Diagnostic library package the TPS external watchdog is configured as Q&A(Question and Answer) watchdog and the RTI module is used to generate the timer interrupts in the closed and open windows of the TPS external watchdog.These interrupts are used to send the open window and close window answers to the watchdog.similarly RTI can be also used to generate timer interrupts to service the watchdog in WDTI mode.

The RTI compare 0 is used in the demo application provided.So the interrupts are enabled for the RTI compare 0.The RTI configuration is done so as to get counter 0 clk of 1 MHz.

ADC Configuration

The Diagnostic out pin of the TPS Device is connected to AD1IN[0].So as to read the sample (either it may be analog or digital) the ADC1 has to be configured so as to sample the diagnostic pin on the TPS device and provide the ADC converted value.This ADC configuration is a mandatory configuration and is needed by the TPS driver. below figure shows the ADC1 configuration.

ADC1 General tab Configuration

The configuration is done such that the cycle time is 100 ns.

ADC1 Group1 Configuration

The ADC1 Group1 is configured as below

Parameter Value comments
Fifo Size 1 the fifo size is set to 1,We are using the ADC in polling mode.
Data Resolution 12 bit we are using data resolution of 12bit.
Sample Time 1000 ns the sample time necessary for sampling the DIAG OUT pin of TPS device
Enable Pin 0 enabled the Diag out pin is connected to the pin 0

The figure below shows the ADC Group 1 configuration

ADC Group 1 configuration

Please do check the HALCoGen configuration provided along with the demo application in the Diagnostic library for more information.


Halcogen configuration for the TPS driver is a straight forward one.The initialization sequence needed to initialize the various peripherals and the TPS device can be found in the example application provided with the Diagnostic Library package.


  1. TPS65381-Q1
  2. Hercules Microcontrollers