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.

AM57x RTOS no spi clock

Other Parts Discussed in Thread: SYSCONFIG

I'm trying to get spi working on a 5728, but when I try a transaction, the chip select drops low (active) for a short period of time and then goes high with no clock pulses at all.

If I use spi->SYST to bit bang the bits out, individually setting bits and pausing with wait statements, it works fine.

My initialization code looks like this:

spi->SYSCONF = 0x30a; // clocks maintained; ignore idle mode request; turn off wakeup mode; reset spi
while (spi->SYSSTAUS & 0x1 != 1);
// clk div pwr of 2; no fifo; cs 3.5 cycle buffer; xmit (mosi) on d0 and not d1; xfer 8 bits; 1.5MHz clk; cpha=1 dat chg on rise clked on fall
spi->CSREG[1].CHxCONF = 0x060603d5;
spi->SYSCONF = 0x308; // clocks maintained; ignore idle mode request; turn off wakeup mode; don't reset spi this time
spi->HL_SYSCONFIG = 0x4; // no idle mode; sensitive to emulation suspend; don't reset
spi->MODULCTRL = 0x1; // single channel master

The code to transmit looks like this:

spi->CSREG[1].CHxCONF |= 0x00100000;  // CSHOLD;
for (i = 0; i < in_length; i++)
{
      // clear cs hold if we were told to set it and this is the last byte.
      if ((SPI_HOLD_CLR == in_cs_hold) && (i == (in_length - 1)))
         spi->CSREG[1].CHxCONF &= ~0x00100000;  // CSHOLD;

       spi->CSREG[1].TXx = *src_buffer;
      // increment src pointer, if the caller is not using the same
      // memory for src and dest.
         src_buffer++;

      // start the channel
      spi->CSREG[1].CHxCTRL = 1;

      while (!(spi->CSREG[1].CHxSTAT & 2));
      // stop the channel
      spi->CSREG[1].CHxCTRL = 0;

      // copy the received data.
         *dest_buffer = (uint8_t) (spi->CSREG[1].RXx);
         dest_buffer++;
   }

When I examine the contents of CM_L4PER_CLKSTCTRL I see 0x01f7ff02 which I believe indicates the 48 MHz spi functional clock is up and running.

If you're wondering why I'm directly accessing registers instead of using the drivers as in C:\ti\pdk_am57xx_1_0_3, it's because those examples are absolutely worthless. For example, what exactly does Board_init(boardCfg) do and how do I modify it for my custom board? When using SPI_init(), the comments say the SPI_config structure must exist and be persistent before this function can be called. The configuration structure is a large structure filled out with #defines like MCSPI_DATA_LINE_COMM_MODE_7 which expands to

((MCSPI_CH0CONF_IS_LINE1 <<  MCSPI_CH0CONF_IS_SHIFT) | (MCSPI_CH0CONF_DPE1_DISABLED << MCSPI_CH0CONF_DPE1_SHIFT) |    \
                                       (MCSPI_CH0CONF_DPE0_DISABLED << MCSPI_CH0CONF_DPE0_SHIFT))

with absolutely no comments whatsoever to explain how to modify this for my custom hardware. These aren't examples for someone to write their own code, they're test code for an EVM board with little to no thought about making it easy for someone to modify for their own board. Besides, when I tried to go down this path, I got compile errors that my field engineer couldn't tell me how to fix.

  • The RTOS team have been notified. They will respond here.
  • Rich,

    Sorry to know that you are having issues using the SPI driver examples with the SDK. Let me try to understand your issues and see if I can help you with this request. From SDK perspective, I would highly recommend that you look at the Processor SDK RTOS: Port to custom platform section(Section 9) in the training presentation below:
    software-dl.ti.com/.../index.html

    The board init function is designed initialize device clocks, power and control modules, pinmux configuration, DDR and UARTs etc. Of the above if you are using the GEL files then you don`t need the clock and DDR initialization but you will need the pinmux/IO delay settings, power and control configuration to bring out clock, CS, data lines.

    If you are running into build issues, please provide us the logs and we can help you build the driver and the example which is out recommended way to development with these parts.

    A simpler SPI example is provided in the pdk_x_xx_xx_x\packages\ti\board\diag folder.Could you specify if you are using the IDK or the GP EVM for your development. Also can you provide the SDK version which you are using so that we can provide guidance. I will review the code that you have provided and see if I can find anything that you are missing.

    Regards,
    Rahul
  • Also, dataLineCommMode is the field in the SPI_v1_HWAttrs_s structure that is populated with the MCSPI_DATA_LINE_COMM_MODE_7, this refers to the McSPI_CHxCONF[18:16] bits that configure Data line 0/1 pin as input and output.

    The default after reset is mode 6 as you can see here:

    Regards,

    Rahul

  • You mention that I should use the pdk drivers and follow the procedure in section 9 of Processor SDC RTOS: Port to custom platform. Those slides are terrible. They mention code that needs to be modified, but make no mention whatsoever about how to create the library file. I tried modifying the makefiles but when I run gmake all I get are errors, with or without my new files.
  • Rich,

    The slides only intend to provide guidance to port the board library created for TI EVM platform to custom platform and it is meant to be used along side the Processor SDK RTOS Software developer documentation. the board library can be built by following these steps:
    processors.wiki.ti.com/.../Rebuilding_The_PDK

    Board library can be built by invoking "make board" from pdk_1_x_xx\packages after setting up the pdksetupenv.sh or pdksetupenv.bat.

    Regards,
    Rahul