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.

SPI read is not working in tm4c1230h6pm

Other Parts Discussed in Thread: TM4C1230H6PM

Hi Team,

            I am using TM4C1230h6pm. I am interfacing SPI with SSt25vf016b The SPI Read is not working. The SSt25vf016b has 8 bit communication.   When i try read JeDEC_ID from serial flash i could not able read any instead i get only 0 in temp variable. I have confirmed that TI microcontroller is sending 0x9F instruction to serial flash via CRO but i could not able to read the data. Please help. Since it is blocking issue for us please help ASAP.

 void Configure_SPI(void)
{
        //
    // The SSI1 peripheral must be enabled for use.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
        SysCtlPeripheralEnable (SYSCTL_RCGC1_SSI1);


    //
    // For this example SSI1 is used with PortD[0:3].  The actual port and pins
    // used may be different on your part, consult the data sheet for more
    // information.  GPIO port D needs to be enabled so these pins can be used.
    // TODO: change this to whichever GPIO port you are using.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    
        GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_1); //SSI1Fss
        GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_1, GPIO_PIN_1);
        //
    // Configure the pin muxing for SSI1 functions on port D3, D2, D1, and D0.
    // This step is not necessary if your part does not support pin muxing.
    // TODO: change this to select the port/pin you are using.
    //
    GPIOPinConfigure(GPIO_PD0_SSI1CLK);
    GPIOPinConfigure(GPIO_PD2_SSI1RX);
    GPIOPinConfigure(GPIO_PD3_SSI1TX);
        
        //
    // Configure and enable the SSI port for SPI master mode.  Use SSI1,
    // system clock supply, idle clock level low and active low clock in
    // freescale SPI mode, master mode, 1MHz SSI frequency, and 8-bit data.
    // For SPI mode, you can set the polarity of the SSI clock when the SSI
    // unit is idle.  You can also configure what clock edge you want to
    // capture data on.  Please reference the datasheet for more information on
    // the different SPI modes.
    //
    ROM_SSIConfigSetExpClk(SSI1_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0,
                                                      SSI_MODE_MASTER, 100000, 8);
        

    //
    // Configure the GPIO settings for the SSI pins.  This function also gives
    // control of these pins to the SSI hardware.  Consult the data sheet to
    // see which functions are allocated per pin.
    // The pins are assigned as follows:
    //      PD3 - SSI1Tx
    //      PD2 - SSI1Rx
    //      PD1 - SSI1Fss
    //      PD0 - SSI1CLK
    // TODO: change this to select the port/pin you are using.
    //
        GPIOPinTypeSSI( GPIO_PORTD_BASE,GPIO_PIN_3| GPIO_PIN_2 | GPIO_PIN_1 | GPIO_PIN_0 );
        
    
    //
    // Enable the SSI1 module.
    //
    SSIEnable(SSI1_BASE);
}

uint32_t
SPIDataGet(uint32_t ui32Base)
{
        uint32_t pui32Data;

    //
    // Wait until there is data to be read.
    //
    while(!(HWREG(ui32Base + SSI_O_SR) & SSI_SR_RNE))
    {
    }

    //
    // Read data from SSI.
    //
    pui32Data = HWREG(ui32Base + SSI_O_DR);
    return (pui32Data);

unsigned long Jedec_ID_Read(void)
{
    uint32_t temp,dum_byte ;
    char buf[10];
    temp = 0;

    GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_1, 0);             /* enable device */
    delay_ms (100);
        
    SSIDataPut (SSI1_BASE,0x9F);         /* send JEDEC ID command (9Fh) */
    while(SSIBusy(SSI1_BASE));
    SSIDataGet (SSI1_BASE, &dum_byte);       // Dummy Byte


    temp = temp | SPIDataGet(SSI1_BASE) << 16;

    SSIDataGet (SSI1_BASE, &dum_byte);                            //Dummy Byte

    temp = temp | SPIDataGet(SSI1_BASE) << 8;

    SSIDataGet (SSI1_BASE, &dum_byte);                           //Dummy Byte
    

    temp = temp | SPIDataGet(SSI1_BASE);

    SSIDataGet (SSI1_BASE, &dum_byte);                          //Dummy Byte
    
    GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_1, GPIO_PIN_1);             /* disable device */
    delay_ms (100);
    sprintf (buf,"%x",temp);
    return temp;
}

If you want i can give more detail on this.

Thanks,

Shan