This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LP-AM243: Develop driver for TPS274 on AM243xEVM module

Expert 4090 points
Part Number: LP-AM243
Other Parts Discussed in Thread: TPS274C65, SYSCONFIG

Tool/software:

Hi team,

My customer has written code that drives to enable and disable channels and turn on/off Led 1_4 and 5_8 on AM243xEVM platform over SPI that does not work. 

They first developed the code on Arduino Uno R4 just to quickly verify the hardware connection and setup and explore the features of the TPS274C65 EVM-USB board. That works fine. They can turn on/off the channels, see that proper current drives the channels, turn on/off LEDs, and configure the current. They can read back the registers.

However, the same code doesn't work on AM243xEVM. Understood that the SPI driver is different—on AM243xEVM, they are using our SPI driver. To confirm if their driver works, they have connected the SPI motor driver chip to AM243xEVM on the same bus and even with the same CS, clock frequency, and other settings. They can drive the with the third-party SPI motor driver. However, TPS274 does not do anything. 

They are currently using a 2MHz clock frequency over SPI and have checked and reviewed the setup and implementation. The same setup works with Arduino but not AM243. We are looking for anything or ideas to debug.

Thanks,

Luke 

  • Hi Luke,

    Lets understand the setup here first.

    Currently you are having AM243, as a Controller, and TPS274C65, as a slave/peripheral.

    Now you want to send some commands via the SPI protocol more specifically MCSPI to the peripheral.

    You are able to do so, when you use Arduino Uno R4 as the controller but not able to do so when you use the AM243 EVM as the controller.

    If my understanding is correct, then read my comments below.

    To debug this, I would encourage you follow the generic SPI/MCSPI setup before initiating the MCSPI_transfer() call.

    Also, the SysConfig settings need to be studied in order to know if things are setup correctly. 

    Action Item for you:
    Can you please attach the SysConfig file for your application here and let me know if  you are on the latest MCU PLUS SDK installer.

    Looking forward to your response.

    Regards,

    Vaibhav

  • Additionally, I would like you to go through this MCSPI Integration Guide I created a while ago: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1414084/faq-sk-am64b-mcspi-integration-guide

    Please also go through an example like MCSPI Loopback and look at how the transaction parameters are being set before the call to MCSPI_transfer is made. You can find this example at the following directory inside MCU PLUS SDK: examples/drivers/mcspi/mcspi_loopback

  • Here are the MCSPI and GPIO setups:

    Here are the settings for SPI and CS. Let me know if you need any further information. If you provide I can send you the screenshots of the configuration.

    I am also including a piece of code that tries to communicate with TPS274C65

    Here are the settings for SPI and CS. Let me know if you need any further information. If you provide I can send you the screen shots of configuration.
    
    const mcspi = scripting.addModule("/drivers/mcspi/mcspi", {}, false);
    
    const mcspi2 = mcspi.addInstance();
    
    mcspi2.$name = "CONFIG_MCSPI1";
    mcspi2.initDelay = "8";
    mcspi2.SPI.$assign = "SPI1";
    mcspi2.child.$name = "drivers_mcspi_v0_mcspi_v0_template1";
    mcspi2.mcspiChannel[0].$name = "CONFIG_MCSPI_CH1";
    mcspi2.mcspiChannel[0].bitRate = 2000000;
    mcspi2.mcspiChannel[0].CSn.pu_pd = "pu";
    mcspi2.mcspiChannel[0].CSn.$used = false;
    
    mcspi2.udmaDriver = udma1;
    
    mcspi2.SPI.CLK.$suggestSolution = "SPI1_CLK";
    mcspi2.SPI.D0.$suggestSolution = "SPI1_D0";
    mcspi2.SPI.D1.$suggestSolution = "SPI1_D1";
    
    Chip select
    
    gpio2.pinDir = "OUTPUT";
    gpio2.$name = "SPI1_CS1";
    gpio2.trigType = "BOTH_EDGE";
    gpio2.defaultValue = "1";
    gpio2.GPIO.gpioPin.pu_pd = "pu";
    gpio2.GPIO.gpioPin.$assign = "SPI1_CS1";
    
    gpio2.GPIO.$suggestSolution = "GPIO1";

  • **
     * These arguments were used when this file was generated. They will be automatically applied on subsequent loads
     * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
     * @cliArgs --device "AM243x_ALV_beta" --package "ALV" --part "ALV" --context "r5fss0-0" --product "MCU_PLUS_SDK@07.03.01"
     * @versions {"tool":"1.19.0+3426"}
     */
    
    /**
     * Import the modules used in this configuration.
     */
    const gpio            = scripting.addModule("/drivers/gpio/gpio", {}, false);
    const gpio1           = gpio.addInstance();
    const gpio2           = gpio.addInstance();
    const gpio3           = gpio.addInstance();
    const gpio4           = gpio.addInstance();
    const mcspi           = scripting.addModule("/drivers/mcspi/mcspi", {}, false);
    const mcspi1          = mcspi.addInstance();
    const mcspi2          = mcspi.addInstance();
    const mcspi3          = mcspi.addInstance();
    const debug_log       = scripting.addModule("/kernel/dpl/debug_log");
    const mpu_armv7       = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false);
    const mpu_armv71      = mpu_armv7.addInstance();
    const mpu_armv72      = mpu_armv7.addInstance();
    const mpu_armv73      = mpu_armv7.addInstance();
    const mpu_armv74      = mpu_armv7.addInstance();
    const mpu_armv75      = mpu_armv7.addInstance();
    const mpu_armv76      = mpu_armv7.addInstance();
    const timer           = scripting.addModule("/kernel/dpl/timer", {}, false);
    const timer1          = timer.addInstance();
    const timer2          = timer.addInstance();
    const timer3          = timer.addInstance();
    const default_linker  = scripting.addModule("/memory_configurator/default_linker", {}, false);
    const default_linker1 = default_linker.addInstance();
    const general         = scripting.addModule("/memory_configurator/general", {}, false);
    const general1        = general.addInstance();
    const region          = scripting.addModule("/memory_configurator/region", {}, false);
    const region1         = region.addInstance();
    const section         = scripting.addModule("/memory_configurator/section", {}, false);
    const section1        = section.addInstance();
    const section2        = section.addInstance();
    const section3        = section.addInstance();
    const section4        = section.addInstance();
    const section5        = section.addInstance();
    const section6        = section.addInstance();
    const section7        = section.addInstance();
    const section8        = section.addInstance();
    const section9        = section.addInstance();
    const section10       = section.addInstance();
    const section11       = section.addInstance();
    
    /**
     * Write custom configuration values to the imported modules.
     */
    gpio1.pinDir               = "OUTPUT";
    gpio1.$name                = "GPIO_HISIDE_EN";
    gpio1.GPIO.gpioPin.pu_pd   = "pu";
    gpio1.GPIO.gpioPin.$assign = "GPMC0_AD7";
    
    gpio2.pinDir               = "OUTPUT";
    gpio2.$name                = "SPI1_CS1";
    gpio2.defaultValue         = "1";
    gpio2.GPIO.gpioPin.pu_pd   = "pu";
    gpio2.GPIO.gpioPin.$assign = "SPI1_CS1";
    
    gpio3.pinDir               = "OUTPUT";
    gpio3.$name                = "SPI1_CS0";
    gpio3.GPIO.gpioPin.pu_pd   = "pu";
    gpio3.GPIO.gpioPin.$assign = "SPI1_CS0";
    
    gpio4.pinDir               = "OUTPUT";
    gpio4.$name                = "CTRGINSERT_CS_GPIO";
    gpio4.GPIO.gpioPin.pu_pd   = "pu";
    gpio4.GPIO.gpioPin.$assign = "PRG0_PRU0_GPO1";
    
    mcspi1.$name                       = "CONFIG_MCSPI0";
    mcspi1.inputSelect                 = "0";
    mcspi1.SPI.$assign                 = "SPI0";
    mcspi1.mcspiChannel[0].$name       = "CONFIG_MCSPI_CH0";
    mcspi1.mcspiChannel[0].bitRate     = 2000000;
    mcspi1.mcspiChannel[0].CSn.pu_pd   = "pu";
    mcspi1.mcspiChannel[0].CSn.$assign = "SPI0_CS0";
    mcspi1.child.$name                 = "drivers_mcspi_v0_mcspi_v0_template0";
    
    mcspi2.$name                     = "CONFIG_MCSPI1";
    mcspi2.initDelay                 = "8";
    mcspi2.SPI.$assign               = "SPI1";
    mcspi2.mcspiChannel[0].$name     = "CONFIG_MCSPI_CH1";
    mcspi2.mcspiChannel[0].bitRate   = 2000000;
    mcspi2.mcspiChannel[0].advanced  = true;
    mcspi2.mcspiChannel[0].CSn.pu_pd = "pu";
    mcspi2.mcspiChannel[0].CSn.$used = false;
    mcspi2.child.$name               = "drivers_mcspi_v0_mcspi_v0_template1";
    
    mcspi3.$name                       = "CONFIG_MCSPI3";
    mcspi3.SPI.$assign                 = "SPI3";
    mcspi3.mcspiChannel[0].$name       = "CONFIG_MCSPI_CH2";
    mcspi3.mcspiChannel[0].CSn.$assign = "PRG0_PRU0_GPO15";
    mcspi3.child.$name                 = "drivers_mcspi_v0_mcspi_v0_template1_COPY";
    
    const udma        = scripting.addModule("/drivers/udma/udma", {}, false);
    const udma1       = udma.addInstance({}, false);
    udma1.$name       = "CONFIG_UDMA0";
    mcspi1.udmaDriver = udma1;
    mcspi2.udmaDriver = udma1;
    mcspi3.udmaDriver = udma1;
    
    debug_log.enableUartLog            = true;
    debug_log.uartLog.$name            = "CONFIG_UART_CONSOLE";
    debug_log.uartLog.UART.$assign     = "USART0";
    debug_log.uartLog.UART.RXD.$assign = "UART0_RXD";
    debug_log.uartLog.UART.TXD.$assign = "UART0_TXD";
    
    const uart_v0_template  = scripting.addModule("/drivers/uart/v0/uart_v0_template", {}, false);
    const uart_v0_template1 = uart_v0_template.addInstance({}, false);
    uart_v0_template1.$name = "drivers_uart_v0_uart_v0_template0";
    debug_log.uartLog.child = uart_v0_template1;
    
    mpu_armv71.$name             = "CONFIG_MPU_REGION0";
    mpu_armv71.size              = 31;
    mpu_armv71.attributes        = "Device";
    mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD";
    mpu_armv71.allowExecute      = false;
    
    mpu_armv72.$name             = "CONFIG_MPU_REGION1";
    mpu_armv72.size              = 15;
    mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD";
    
    mpu_armv73.$name             = "CONFIG_MPU_REGION2";
    mpu_armv73.baseAddr          = 0x41010000;
    mpu_armv73.size              = 15;
    mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD";
    
    mpu_armv74.$name             = "CONFIG_MPU_REGION3";
    mpu_armv74.baseAddr          = 0x70000000;
    mpu_armv74.size              = 21;
    mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD";
    
    mpu_armv75.$name             = "CONFIG_MPU_REGION4";
    mpu_armv75.baseAddr          = 0x60000000;
    mpu_armv75.size              = 28;
    mpu_armv75.accessPermissions = "Supervisor RD, User RD";
    
    mpu_armv76.$name    = "CONFIG_MPU_REGION5";
    mpu_armv76.baseAddr = 0x80000000;
    mpu_armv76.size     = 31;
    
    timer1.$name         = "OPTICS_TIMER";
    timer1.timerCallback = "OpticsTimerCallback";
    timer1.startTimer    = true;
    timer1.usecPerTick   = 250000;
    timer1.intrPriority  = 2;
    timer1.TIMER.$assign = "DMTIMER0";
    
    timer2.timerCallback = "OpticsTimerCallback";
    timer2.usecPerTick   = 250000;
    timer2.intrPriority  = 2;
    timer2.$name         = "mtimer";
    timer2.TIMER.$assign = "DMTIMER1";
    
    timer3.timerCallback = "OpticsTimerCallback";
    timer3.usecPerTick   = 250000;
    timer3.intrPriority  = 2;
    timer3.$name         = "ptimer";
    timer3.TIMER.$assign = "DMTIMER2";
    
    default_linker1.$name = "memory_configurator_default_linker0";
    
    general1.$name        = "CONFIG_GENERAL0";
    general1.linker.$name = "TIARMCLANG0";
    
    region1.$name                               = "MEMORY_REGION_CONFIGURATION0";
    region1.memory_region.create(9);
    region1.memory_region[0].type               = "TCMA_R5F";
    region1.memory_region[0].$name              = "R5F_VECS";
    region1.memory_region[0].size               = 0x40;
    region1.memory_region[0].auto               = false;
    region1.memory_region[1].type               = "TCMA_R5F";
    region1.memory_region[1].$name              = "R5F_TCMA";
    region1.memory_region[1].size               = 0x7FC0;
    region1.memory_region[2].type               = "TCMB_R5F";
    region1.memory_region[2].$name              = "R5F_TCMB0";
    region1.memory_region[2].size               = 0x8000;
    region1.memory_region[3].$name              = "NON_CACHE_MEM";
    region1.memory_region[3].auto               = false;
    region1.memory_region[3].manualStartAddress = 0x70060000;
    region1.memory_region[3].size               = 0x8000;
    region1.memory_region[4].$name              = "MSRAM";
    region1.memory_region[4].auto               = false;
    region1.memory_region[4].manualStartAddress = 0x70080000;
    region1.memory_region[4].size               = 0x40000;
    region1.memory_region[5].type               = "FLASH";
    region1.memory_region[5].$name              = "FLASH";
    region1.memory_region[5].auto               = false;
    region1.memory_region[5].manualStartAddress = 0x60100000;
    region1.memory_region[5].size               = 0x80000;
    region1.memory_region[6].$name              = "USER_SHM_MEM";
    region1.memory_region[6].auto               = false;
    region1.memory_region[6].manualStartAddress = 0x701D0000;
    region1.memory_region[6].size               = 0x180;
    region1.memory_region[7].auto               = false;
    region1.memory_region[7].manualStartAddress = 0x701D0180;
    region1.memory_region[7].size               = 0x3E80;
    region1.memory_region[7].$name              = "LOG_SHM_MEM";
    region1.memory_region[8].auto               = false;
    region1.memory_region[8].manualStartAddress = 0x701D4000;
    region1.memory_region[8].size               = 0xC000;
    region1.memory_region[8].$name              = "RTOS_NORTOS_IPC_SHM_MEM";
    
    section1.$name                        = "Vector Table";
    section1.load_memory                  = "R5F_VECS";
    section1.group                        = false;
    section1.output_section.create(1);
    section1.output_section[0].$name      = ".vectors";
    section1.output_section[0].palignment = true;
    
    section2.$name                        = "Text Segments";
    section2.load_memory                  = "MSRAM";
    section2.output_section.create(5);
    section2.output_section[0].$name      = ".text.hwi";
    section2.output_section[0].palignment = true;
    section2.output_section[1].$name      = ".text.cache";
    section2.output_section[1].palignment = true;
    section2.output_section[2].$name      = ".text.mpu";
    section2.output_section[2].palignment = true;
    section2.output_section[3].$name      = ".text.boot";
    section2.output_section[3].palignment = true;
    section2.output_section[4].$name      = ".text:abort";
    section2.output_section[4].palignment = true;
    
    section3.$name                        = "Code and Read-Only Data";
    section3.load_memory                  = "MSRAM";
    section3.output_section.create(2);
    section3.output_section[0].$name      = ".text";
    section3.output_section[0].palignment = true;
    section3.output_section[1].$name      = ".rodata";
    section3.output_section[1].palignment = true;
    
    section4.$name                        = "Data Segment";
    section4.load_memory                  = "MSRAM";
    section4.output_section.create(1);
    section4.output_section[0].$name      = ".data";
    section4.output_section[0].palignment = true;
    
    section5.$name                                   = "Memory Segments";
    section5.load_memory                             = "MSRAM";
    section5.output_section.create(3);
    section5.output_section[0].$name                 = ".bss";
    section5.output_section[0].palignment            = true;
    section5.output_section[0].output_sections_start = "__BSS_START";
    section5.output_section[0].output_sections_end   = "__BSS_END";
    section5.output_section[1].$name                 = ".sysmem";
    section5.output_section[1].palignment            = true;
    section5.output_section[2].$name                 = ".stack";
    section5.output_section[2].palignment            = true;
    
    section6.$name                                    = "Stack Segments";
    section6.load_memory                              = "MSRAM";
    section6.output_section.create(5);
    section6.output_section[0].$name                  = ".irqstack";
    section6.output_section[0].output_sections_start  = "__IRQ_STACK_START";
    section6.output_section[0].output_sections_end    = "__IRQ_STACK_END";
    section6.output_section[0].input_section.create(1);
    section6.output_section[0].input_section[0].$name = ". = . + __IRQ_STACK_SIZE;";
    section6.output_section[1].$name                  = ".fiqstack";
    section6.output_section[1].output_sections_start  = "__FIQ_STACK_START";
    section6.output_section[1].output_sections_end    = "__FIQ_STACK_END";
    section6.output_section[1].input_section.create(1);
    section6.output_section[1].input_section[0].$name = ". = . + __FIQ_STACK_SIZE;";
    section6.output_section[2].$name                  = ".svcstack";
    section6.output_section[2].output_sections_start  = "__SVC_STACK_START";
    section6.output_section[2].output_sections_end    = "__SVC_STACK_END";
    section6.output_section[2].input_section.create(1);
    section6.output_section[2].input_section[0].$name = ". = . + __SVC_STACK_SIZE;";
    section6.output_section[3].$name                  = ".abortstack";
    section6.output_section[3].output_sections_start  = "__ABORT_STACK_START";
    section6.output_section[3].output_sections_end    = "__ABORT_STACK_END";
    section6.output_section[3].input_section.create(1);
    section6.output_section[3].input_section[0].$name = ". = . + __ABORT_STACK_SIZE;";
    section6.output_section[4].$name                  = ".undefinedstack";
    section6.output_section[4].output_sections_start  = "__UNDEFINED_STACK_START";
    section6.output_section[4].output_sections_end    = "__UNDEFINED_STACK_END";
    section6.output_section[4].input_section.create(1);
    section6.output_section[4].input_section[0].$name = ". = . + __UNDEFINED_STACK_SIZE;";
    
    section7.$name                        = "Initialization and Exception Handling";
    section7.load_memory                  = "MSRAM";
    section7.output_section.create(3);
    section7.output_section[0].$name      = ".ARM.exidx";
    section7.output_section[0].palignment = true;
    section7.output_section[1].$name      = ".init_array";
    section7.output_section[1].palignment = true;
    section7.output_section[2].$name      = ".fini_array";
    section7.output_section[2].palignment = true;
    
    section8.$name                       = "User Shared Memory";
    section8.type                        = "NOLOAD";
    section8.load_memory                 = "USER_SHM_MEM";
    section8.group                       = false;
    section8.output_section.create(1);
    section8.output_section[0].$name     = ".bss.user_shared_mem";
    section8.output_section[0].alignment = 0;
    
    section9.$name                       = "Log Shared Memory";
    section9.load_memory                 = "LOG_SHM_MEM";
    section9.type                        = "NOLOAD";
    section9.group                       = false;
    section9.output_section.create(1);
    section9.output_section[0].$name     = ".bss.log_shared_mem";
    section9.output_section[0].alignment = 0;
    
    section10.$name                       = "IPC Shared Memory";
    section10.type                        = "NOLOAD";
    section10.load_memory                 = "RTOS_NORTOS_IPC_SHM_MEM";
    section10.group                       = false;
    section10.output_section.create(1);
    section10.output_section[0].$name     = ".bss.ipc_vring_mem";
    section10.output_section[0].alignment = 0;
    
    section11.$name                       = "Non Cacheable Memory";
    section11.load_memory                 = "NON_CACHE_MEM";
    section11.group                       = false;
    section11.type                        = "NOLOAD";
    section11.output_section.create(1);
    section11.output_section[0].$name     = ".bss.nocache";
    section11.output_section[0].alignment = 0;
    
    /**
     * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
     * version of the tool will not impact the pinmux you originally saw.  These lines can be completely deleted in order to
     * re-solve from scratch.
     */
    gpio1.GPIO.$suggestSolution     = "GPIO0";
    gpio2.GPIO.$suggestSolution     = "GPIO1";
    gpio3.GPIO.$suggestSolution     = "GPIO1";
    gpio4.GPIO.$suggestSolution     = "GPIO1";
    mcspi1.SPI.CLK.$suggestSolution = "SPI0_CLK";
    mcspi1.SPI.D0.$suggestSolution  = "SPI0_D0";
    mcspi1.SPI.D1.$suggestSolution  = "SPI0_D1";
    mcspi2.SPI.CLK.$suggestSolution = "SPI1_CLK";
    mcspi2.SPI.D0.$suggestSolution  = "SPI1_D0";
    mcspi2.SPI.D1.$suggestSolution  = "SPI1_D1";
    mcspi3.SPI.CLK.$suggestSolution = "PRG0_PRU0_GPO16";
    mcspi3.SPI.D0.$suggestSolution  = "PRG0_PRU0_GPO13";
    mcspi3.SPI.D1.$suggestSolution  = "PRG0_PRU0_GPO14";
    
    uint32_t xferh (uint8_t a, uint8_t b, uint8_t c)
    {
        int32_t     transferOK = 1;
        uint32_t    gpioBaseAddr, pinNum;
        gpioBaseAddr = (uint32_t) AddrTranslateP_getLocalAddr(SPI1_CS1_BASE_ADDR);
        pinNum       = SPI1_CS1_PIN;
    	
        uint64_t            startTimeInUSec, elapsedTimeInUsecs;
        hMcspiTxBuffer[0] = a; //device address
        hMcspiTxBuffer[1] = b;  //Dev_config register: bit 0-3 sets current limit
        hMcspiTxBuffer[2] = c;  //data
    
        /* Initiate transfer */
    
        //done in Motor_control
        hSpiTransaction.txBuf    = (void *)hMcspiTxBuffer;
        hSpiTransaction.rxBuf    = (void *)hMcspiRxBuffer;
    
        startTimeInUSec = ClockP_getTimeUsec();
    
        gpio_set(LOW, gpioBaseAddr, pinNum);
        ClockP_usleep(100); 
        transferOK = MCSPI_transfer(gMcspiHandle[CONFIG_MCSPI1], &hSpiTransaction);
        transferOK = MCSPI_transfer(gMcspiHandle[CONFIG_MCSPI1], &hSpiTransaction);
        ClockP_usleep(100);
        gpio_set(HIGH, gpioBaseAddr, pinNum);
        elapsedTimeInUsecs = ClockP_getTimeUsec() - startTimeInUSec;
    
    
        if(SystemP_SUCCESS == transferOK)
        {
            DebugP_log("\r\n transferOK %d - elapsedTimeInUsecs %d  rxBuf1 %x, rxBuf2: %x \r\n", transferOK, elapsedTimeInUsecs, transferOK, hMcspiRxBuffer[1], hMcspiRxBuffer[2] );
    
            transferOK = *(uint32_t*) (&hMcspiRxBuffer[1]); //(&mMcspiRxBuffer[0]);
        }
        return transferOK;
    }
    
    int32_t heater_control()
    {
        int32_t			 transferOK, read_data ;
    	uint64_t			 startTimeInUSec, elapsedTimeInUsecs;
    	uint8_t i, heater_pos;	
    	float heater_temp = 0;
    	static uint8_t heater_out = 0xF0;  //off
    	static uint8_t redled_out = 0xFF;  //off
    
    	UpperLimit1 = setpoint1 + 1; // here you can adjust tolerance +/- 1 degree from setpoint
    	LowerLimit1 = setpoint1 - 1;
    	UpperLimit2 = setpoint2 + 1;
    	LowerLimit2 = setpoint2 - 1;
    	UpperLimit3 = setpoint3 + 1;
    	LowerLimit3 = setpoint3 - 1;
    	UpperLimit4 = setpoint4 + 1;
    	LowerLimit4 = setpoint4 - 1;
    
    	xferh(DEVADR, TPS274C65_DEV_CONFIG1_REG, 0x06); // data to config register, ranges from 0x00 - 0x0F, 250mA to 2.5A
    	transferOK = xferh(DEVADR,TPS274C65_LED_1_4_CTL_REG, 0xFA); //	todo: TEMP DELETE.
    
    	for (i = 1; i < NUM_HEATERS+1; i++)
    	{
    
    	    heater_pos = i-1;
        	heater_temp = 255;
    		int heater_temp = readTemp(i);
    	  	DebugP_log("\r\n Heater 1 temp %d", heater_temp);
    
    		if (heater_temp >= UpperLimit1)
    		{
    			  //output_state ^= (1 << 1);  // remove toggle bit.
    		  heater_out &= ~(1 << heater_pos);  //reset
    		  redled_out |= (1 << heater_pos);	//set bit 
    		}
    		else if(heater_temp <= LowerLimit1)
    		{
    			heater_out |= (1 << heater_pos);  //set bit 
    			redled_out &= ~(1 << heater_pos);  //reset
    		}
    
    		xferh(DEVADR, TPS274C65_LED_1_4_CTL_REG, heater_out); // turn on red LED's to indicate overtemperature
    		xferh(DEVADR, TPS274C65_LED_5_8_CTL_REG, redled_out); // turn OFF red LED's to indicate overtemperature
    		xferh(DEVADR, HEATER1, heater_out); // turn oN Heater 1
    		delay(HEATER_ON_DELAY);    // heater need small delay to turn on 
    	}
    		
    	ClockP_usleep(CYCLE);    // refresh rate of 50 ms
    	return transferOK;		
    }
    
    
    oid TPS_SPISet()
    {
    	int32_t 			transferOK = 0;
    	static configure = 0;
    
    /**************************** SETUP ******************************************/
    
        /* Initiate transfer */
        MCSPI_Transaction_init(&hSpiTransaction);
        hSpiTransaction.channel  = gConfigMcspi1ChCfg[0].chNum;
        hSpiTransaction.dataSize = 8;
        hSpiTransaction.csDisable = TRUE; // sending each transfer in single ChipSelect low/high  FALSE;
        hSpiTransaction.count    = MCSPI_MSGSIZE / (hSpiTransaction.dataSize/8);
        hSpiTransaction.args     = NULL;
        hSpiTransaction.txBuf    = (void *)hMcspiTxBuffer;
        hSpiTransaction.rxBuf    = (void *)hMcspiTxBuffer;
    
    	if (configure == 0)
    	{
    	    configure = 1;
    	    HiSideDriverConfig(0x08);
    	}
    	if(SystemP_SUCCESS == transferOK)
    	{
    		transferOK = heater_control();
    	}
    
    	if(SystemP_SUCCESS != transferOK)
        {
            DebugP_log("\r\n MCSPI transfer failed!! \r\n");
    //       DebugP_assert(FALSE); /* MCSPI transfer failed!! */
        }
        else
        {
            DebugP_log("\r\n HiSide control completed \r\n");
        }
    }
    
    

  • FYI,

    To confirm if our SPI communication works, we connected the SPI motor driver board to AM243xEVM on the same bus and with the same CS, clock frequency, and other settings. We can drive the with the third-party SPI motor driver. However, TPS274 does not do anything. 

  • Hi Mr. Kumar,

    I have reviewed your guide and example. Just want to clarify, we have been using MCSPI to drive a number of devices successfully on AM243x. But have an issue with TPS274C65 only. As I explained in the TPS274C65 post https://e2e.ti.com/support/power-management-group/power-management/f/power-management-forum/1461789/tps274c65evm-develop-driver-for-tps274-on-am243xevm-module

    We have done multiple steps to validate the setup.

    1. Our hardware setup is verified that it works, but using Arduino Uno R4 to drive TPS274C65. 

    2. With the same AM243xEVM setup we connected the Trinamic SPI motor driver and we are successfully driving that chip. 

    3. when we use TPS274C65  with the above setup, it does not operate. 

  • Hello Jamil,

    I have reviewed your attached SysConfig file and read through all your comments from the post/E2E referenced above as well.

    Here are my thoughts.

    I am assuming you are driving TPS with SPI1 at the moment, but apart from that I see that the SPI0 settings are incorrect.

    Please see the attached screenshot.

    You see that if you have set D0 as input select, then you cannot have D0 TX Enable field set to TX Enabled, as it should be set to TX Dsiabled.

    Moreover I have seen that you have been able to send certain values to the 0x4D register based on your last E2E reference.

    Can you please answer few of the following questions from my end:


    1. Please go ahead and correct the MCSPI SPI0 settings as per my request and explanation above.
    2. Please tell me the values in order which you have to write to TPS274:
      1. If you can specify a table/list of values you need to send for example: Values to be sent/written to TPS274 at register 0xreg1 are 10, 11, 12. And so on. If you can specify in detail I can write a piece of code for you to try at your setup.
    3. Moreover, I do not understand why we need GPIO to set CS line low/high, as this will be taken care by the MCSPI drivers internally. So when the MCSPI_transfer() API is called, it takes care of the CS line being set to low or high pre/post transaction. 

    Regards,

    Vaibhav

  • We are not using MCSPI SPI0 at the movement so it is not relevant. We have it there for exploration purposes. But I will correct it as suggested. 

    We are using SPI1 only to take to TPS274.

    MCSPI driver CS line never worked for us. We have configured it but had no luck it drives any peripheral. Maybe we can open this discussion separately. To drive e TPS274, we had configured the MCSPI driver to CS line initially.. Another reason is we may be driving more peripherals on the same SPI instance so better to stick with setting GPIO.

    we are writing to register:  0x1E   0x1F and 0x1D;  

    ox4D does turn on and off led's on TPS274, but that register address doesn't exist on TPS274.

    IN the following  code: 

    xferh(DEVADR, TPS274C65_LED_1_4_CTL_REG, heater_out); // turn on red LED's to indicate overtemperature
    xferh(DEVADR, TPS274C65_LED_5_8_CTL_REG, redled_out); // turn OFF red LED's to indicate overtemperature
    xferh(DEVADR, HEATER1, heater_out); // turn oN Heater 1

    TPS274C65_LED_1_4_CTL_REG   is 0x1E

    TPS274C65_LED_5_8_CTL_REG  is 0x1F

    and HEATER1  is 0x21

    It may be better if we have an MS team call. If you provide your email I can schedule a call. 

  • Hi,

    We are using SPI1 only to take to TPS274.

    I think you meant to write: "to talk to TPS274"

    I understand that you are using SPI1(Main Domain) here.

    I have read the datasheet for TPS274 and came across the following.

    Are you trying to turn on all the LEDs as mentioned below for the register 0x1E?

    The simple operation would be sending the value 15 to register 0x1E, and it should do the job.

    But then I came across the following:

    Which combination are you using out of the above table for writes and reads?

    Regards,

    Vaibhav

  • I am writing to 1E (green led) and 1F (red led) register and 1D register (output port current to turn on heater) to turn on LED's and output current. Yes, to write you have to set write pit, which is part of device address byte. My address is B0 ( 1011  -> 101 device address 5 and 1 for write) . That piece of code is proven. We are running it on Arduino UNO 4 hardware and it works, but not with AM243.

  • Please coordinate with  and  in TI Power Management group to help resolve the issue. 

  • Hi,

    The subject matter expert is currently out of office. Please expect delayed responses.

    Regards,

    Tushar