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.

Launchpad SSI no CLK

Other Parts Discussed in Thread: TM4C123GH6PM

Hello,

i am trying to communicate with a SD card using the SSI0 interface on the launchpad. When trying to write data over the bus im am not seeing the CLK line using a logic analyzer.

i enable the SSI0 module the following way:

// GPIO used for UART and SSI
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
//SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);

// Set alternate function mux to SSI
// GPIOPinConfigure(GPIO_PCTL_PD0_SSI1CLK);
// GPIOPinConfigure(GPIO_PCTL_PD2_SSI1RX);
// GPIOPinConfigure(GPIO_PCTL_PD3_SSI1TX);

// CLK, MOSI, and MISO pins use alternate function (SSI)
GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_5);

// set chip select pin as output
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_3);

// set the SSI clock to the PIOSC clock
SSIClockSourceSet(SSI0_BASE, SSI_CLOCK_PIOSC);

SSIConfigSetExpClk(SSI0_BASE, 16000000, SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 100000, 8);
SSIEnable(SSI0_BASE);

uartWriteString(UART0_BASE, "SPI initialized\r\n", 17);

Below a screenshot of my analyzer software when writing a command to the sd card:

as you can see, the data is getting sent just fine, but there is no clock signal!

I have also tried using the SSI1 module with the same results...

What am i missing here?

Sisco

  • Hello Fransico,

    You need to call the GPIOPinConfigure function before calling the GPIOPinTypeSSI.

    Amit

  • Hello Amit,

    Thank you for your answer, but according to the datasheet on page 1325, PA[5:2] default to SSI state. Also, i have already tried doing that with no success:

    usign the following code gives me a hardfault on adress 0x4000652C (GPIOC????)

    GPIOPinConfigure(GPIO_PCTL_PA2_SSI0CLK);
    GPIOPinConfigure(GPIO_PCTL_PA4_SSI0RX);
    GPIOPinConfigure(GPIO_PCTL_PA5_SSI0TX);

    Thanks,

    Fransisco

  • Hello Fransisco,

    Where  are the defines GPIO_PCTL_PA2_SSI0CLK? I do not see them in the pin_map.h?

    Regards

    Amit

  • @ Amit,

    Those defines, "alive/well" - exactly as listed by poster - w/in the MCU.h file.  (i.e. lm4F231q5hr.h in our case)

  • Uncertain - but is PIOSC proper as poster employs here?  I find, "0 instances" when I search w/in files of our IDE!

    // set the SSI clock to the PIOSC clock SSIClockSourceSet(SSI0_BASE, SSI_CLOCK_PIOSC);

    [edit] 08:57, 17 Jan '13: now indeed find that param (resident w/in file ssi.c)

    As only the clock is "awol" - suggest this parameter temporarily be changed to more, "normal/customary" System Clock "SSI_CLOCK_SYSTEM" - and test repeated...   (always frustrating when poster is, "so close!")

    File ssi.c further reveals:

    //! Changing the baud clock source changes the data rate generated by the
    //! SSI.  Therefore, the data rate should be reconfigured after any change to
    //! the SSI clock source.
    //!
    //! \note The ability to specify the SSI baud clock source varies with the
    //! Stellaris part and SSI in use.  Please consult the data sheet for the part
    //! in use to determine whether this support is available.

    Both of the highlighted areas should be matched against poster's code - appears code sequence is critical here.   And - is PIOSC properly "up & enabled?"

    [edit] Find now that poster has complied w/the above.

    Suspect that it is also useful to delete this call to, "SSIClockSourceSet()" and test/observe... 

    And - poster's code "drops a 0 here": (from example, spi_master.c)  And - that dropped bit specifies "clock rate!"

    SSIConfigSetExpClk(SSI0_BASE, 16000000, SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 100000, 8);

    QED!  Green tick/Verify, s'il vous plait...

  • @cb1_mobile, Fransisco

    Thanks for the reminder on the presence of the define. But in the examples this is not how it is called. For example in the SPI Master Code example, the parameter to the GPIOPinConfigure API is different from the manner in which the poster is using it.

    It should be

    GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    GPIOPinConfigure(GPIO_PA3_SSI0FSS);
    GPIOPinConfigure(GPIO_PA4_SSI0RX);
    GPIOPinConfigure(GPIO_PA5_SSI0TX);

    instead of
    GPIOPinConfigure(GPIO_PCTL_PA2_SSI0CLK);
    GPIOPinConfigure(GPIO_PCTL_PA4_SSI0RX);
    GPIOPinConfigure(GPIO_PCTL_PA5_SSI0TX);
    This could be the cause which it is getting a Fault.
    Also on which Pin on the TM4C123 or TM4C129 Launch Pad is the signal being probed?
    Amit
  • You cannot use the GPIO_PCTL_ defines with GPIOPinConfigure().  The GPIO_Pxx_xxxx defines from pin_map.h must be used instead.

    GPIOPinConfigure(GPIO_PA2_SSI0CLK);

    GPIOPinConfigure(GPIO_PA4_SSI0RX);

    GPIOPinConfigure(GPIO_PA5_SSI0TX);

    This is certainly the cause of the fault.

  • Yes! Thank you verry much i figured this out already thanks to the post from Amit.


    i was indeed  using the wrong defines. These defines are made in the "tm4c123gh6pm.h" file. Using the defines from pin_map.h gets rid of the hardfault and also enables the SSI clock line!

  • PIOSC is an input clock option on the device on the Tiva LaunchPad  but remember the clock ratio rules still apply.   

    SSI Clock >= 2 * bit rate (master mode)
    SSI Clock >= 12 * bit rate (slave modes)