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.

cannot execute SSIConfigSetExpClk

Dear TIVA Users,

i'm trying to configure the SSI2 port for using SPI.
the weird thing is, when execute SSIConfigSetExpClk he hangs.

He wont reach my puts("test");


this is the code i'm using:

#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_memmap.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/ssi.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/rom.h"


int main(void)
{
	uint32_t data;

    //config clock
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_25MHZ);


    //enable peripherals
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);

    GPIOPinConfigure(GPIO_PG7_SSI2CLK);
    GPIOPinConfigure(GPIO_PG4_SSI2XDAT1);
    GPIOPinConfigure(GPIO_PG5_SSI2XDAT0);


    SSIConfigSetExpClk(SSI2_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_1,
                       SSI_MODE_MASTER, 100000, 8);

    puts("test\n");
    //
    // Enable the SSI0 module.
    //
    SSIEnable(SSI2_BASE);

    //configure ss pin
    GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0);


    //set SS low
    GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0);

    uint8_t i;

    puts("start loop..\n");

    for(i = 0; i < 100; i++) {

		SSIDataPut(SSI2_BASE, 0x03);

		while(SSIBusy(SSI2_BASE));


		SSIDataGet(SSI2_BASE, &data);

		while(SSIBusy(SSI2_BASE));

		puts(data);
    }

    GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0xFF);

    return(0);
}

  • Hi Reint,

    1. What TM4C are you using. I would need this information to first know what the System Clock is being set?

    2. I hope there is no Fault being generated when the SSIConfigSetExpClk is called!!!

    3. When it hangs in the function, can you send me the value of the SSI2 registers from the debugger and the CPU register value. This will help understand what it is doing in the while loop in the function

    Amit

  • Hi,

    First you do not specify the processor used - is it TM4C129x?

    Second - does this program compiles/link  OK for you? Did you provided a separate file/routine for puts()? since this a C++ function ...

    Did you used the debugger to note/observe specific debugger messages?

    Petrei

  • HI Amit,

    i'm using the tm4c129x development kit.

    SSI2 registers when running the code:

    R SSI2_SSI_CR0 0x0000000B 0x00000000
    R SSI2_SSI_CR1 0x0000000B 0x00000000
    R SSI2_SSI_DR 0x0000000B 0x00000000
    R SSI2_SSI_SR 0x0000000B 0x00000003
    R SSI2_SSI_CPSR 0x0000000B 0x00000000
    R SSI2_SSI_IM 0x0000000B 0x00000000
    R SSI2_SSI_RIS 0x0000000B 0x00000008
    R SSI2_SSI_MIS 0x0000000B 0x00000000
    R SSI2_SSI_ICR 0x0000000B 0x00000000
    R SSI2_SSI_DMACTL 0x0000000B 0x00000000
    R SSI2_SSI_PP 0x0000000B 0x0000000D
    R SSI2_SSI_CC 0x0000000B 0x00000000

    the core registers are unable to read..


    the weird thing is, he doesn' t even reach the while loop.

  • Hi Reint

    The issue seems to be in the use of the function SysCtlClockSet

    On TM4C129 please use the function SysCtlClockFreqSet to set the clock. If you open the driverlib/sysctl.c file it mentions that TM4C129 should use SysCtlClockFreqSet and TM4C123 should use SysCtlClockSet

    An example of using SysCtlClockFreqSet is also given in the driverlib/sysctl.c and also in the example codes

    That should solve the issue.

    Amit

  • i dont receive any error messages when compiling/linking.
    I dont get any debugger messages either..

    i found this topic about using puts(). http://e2e.ti.com/support/development_tools/code_composer_studio/f/81/t/286275.aspx

  • Thanks Amit, that did the job.