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.

SPI1 on TM4c123G PortF not working

Other Parts Discussed in Thread: EK-TM4C123GXL

Hi, so I have a RTC on SPI1 and on Port F.  I am using an EK-tm4c123gxl. However I was only recieving 0x00 back. I looked on an oscilloscope and found that some of the pins weren't even firing.

I have already tried unlocking F0. 

How I initialise the SPI

void initTivaForRTC()
{
	UARTprintf("Setup RTC");
	SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1); // LCD
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //LCD
	// unlock
	HWREG(GPIO_PORTF_BASE+GPIO_O_LOCK) = GPIO_LOCK_KEY;
	HWREG(GPIO_PORTF_BASE+GPIO_O_CR) |= GPIO_PIN_0;
	GPIOPinTypeGPIOOutput (GPIO_PORTE_BASE,  | GPIO_PORTE_BASE);
	GPIOPinConfigure(GPIO_PF2_SSI1CLK);
	GPIOPinConfigure(GPIO_PF0_SSI1RX);
	GPIOPinConfigure(GPIO_PF1_SSI1TX);
	GPIOPinTypeSSI(GPIO_PORT_F_BASE,
	               RTC_SCLK_PIN | RTC_MOSI_PIN | RTC_MISO_PIN);
	ROM_SSIConfigSetExpClk (SSI1_BASE, ROM_SysCtlClockGet (),
	                        SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 4000000, 8);
	ROM_SSIEnable (SSI1_BASE);
	while(SSIDataGetNonBlocking(SSI1_BASE, &ui32RcvDat))
					{
					}
	UARTprintf(".\n");
}

And then I toggle CS

#define RTC_SELECT 					GPIO_PORTE_DATA_R = ~RTC_CS_PIN
#define RTC_DESELECT 				GPIO_PORTE_DATA_R |= RTC_CS_PIN

And then I communicate to it using:

void rtc_setup(void) // This function to setup
{
    RTC_SELECT;
    rtc_spi(0x04);
    RTC_DESELECT;
}

static uint32_t rtc_spi(u_char data)
{
	uint8_t j = rtcIndex;
	UARTprintf("0x%02x ", data);
	SSIDataPut(SSI1_BASE, data);

	while(SSIBusy(SSI1_BASE))
		{
		}

	SSIDataGet(SSI1_BASE, &rtcRecBuf[j]);
	rtcIndex++;
	return rtcRecBuf[j];
}

Any ideas why this could not be working? Thanks in advance.

  • Hello Jordi

    The base address GPIO_PORT_F_BASE is not a valid define. Could you please check that.

    Also not sure with what you are doing here
    GPIOPinTypeGPIOOutput (GPIO_PORTE_BASE, | GPIO_PORTE_BASE);
    Could you please elaborate?

    Finally when executing the code, if you halt the debugger does it show that it is in a FaultISR?

    Regards
    Amit
  • My Bad ,  I am using this and it still does not work.

    void initTivaForRTC()
    {
        UARTprintf("Setup RTC");
        SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1); // LCD
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //LCD
        // unlock
        HWREG(GPIO_PORTF_BASE+GPIO_O_LOCK) = GPIO_LOCK_KEY;
        HWREG(GPIO_PORTF_BASE+GPIO_O_CR) |= GPIO_PIN_0;
        GPIOPinTypeGPIOOutput (GPIO_PORTE_BASE,  GPIO_PIN_2); // This is ok
        GPIOPinConfigure(GPIO_PF2_SSI1CLK);
        GPIOPinConfigure(GPIO_PF0_SSI1RX);
        GPIOPinConfigure(GPIO_PF1_SSI1TX);
        GPIOPinTypeSSI(GPIO_PORTF_BASE,
                       RTC_SCLK_PIN | RTC_MOSI_PIN | RTC_MISO_PIN); // This is ok
        ROM_SSIConfigSetExpClk (SSI1_BASE, ROM_SysCtlClockGet (),
                                SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 4000000, 8);
        ROM_SSIEnable (SSI1_BASE);
        while(SSIDataGetNonBlocking(SSI1_BASE, &ui32RcvDat))
                        {
                        }
        UARTprintf(".\n");
    }

    I look on the logic analyser and it seems like nothing is happening..

  • Hello Jordi

    Does the final printf of "." come?

    I can try running the same code on my side if you can specify the value of the defines being used. Or better still, zip the CCS project and attach it to the forum post.

    Regards
    Amit
  • Yes the full stop does print. I moved the code to another project to try it. And it still doesn't seem to work correctly.project1.zip

  • Hello Jordi,

    I noticed that you are using a very old version of TivaWare. Can you please change it to the latest version?

    c:/ti/TivaWare_C_Series-1.1

    Regards
    Amit
  • Hello Jordi,

    I checked your code with TivaWare 2.1.0 and the 2 sets of SSI1CLK does come every 10 sec. The Delay statement computes to almost 10 seconds of delay. Also I do see the value 0x4 and 0x5 on the SSI1TX.

    Regards
    Amit
  • May we note (as interested forum observers) that thread is (already) checked as, "Verified" - and the "verifying" post was almost completely, "Questing for needed details" thus bore (little) semblance to an "answer" - let alone hallowed, "Verified" one!
    Might posters require guidance (too) in "when/how" to properly Verify?