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.

TMS320F28384D: F28384D SPIB_BASE not communicating with CAT25128. while porting project from F28379D launchpad.

Part Number: TMS320F28384D
Other Parts Discussed in Thread: LAUNCHXL-F28379D, C2000WARE


Dear Team,

we have created a project using SPIA_BASE with respected PIns

58  -  SIMO

59  -  SOMI

60  -  CLK

61  -  GPIO_FOR CS

to communicate and store data to an EEPROM IC CAT25128 using LAUNCHXL-F28379Dlaunchpad and it works.

But when i tried to port it to SPIB_BASE on our customer required custom board TMS320F28384D THE TX DATA AND RX DATA IS MISS MATCHED. what are we doing wrong.

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

FOR LAUNCHXL-F28379Dlaunchpad.

below image: while reading EEPROM Status register. and the spi is configured to 4 bitrate. in launchpad.

below image: writing data to eeprom through spia base from launch pad.and the spi is configured to 4 bitrate

writing data to the eeprom cat25128

below image: Reading data to eeprom through spia base from launch pad.and the spi is configured to 4 bitrate

below are the pin mux, SPIA_BASE configuration and send and receive function used in LAUNCHXL-F28379D launchpad.

uint16_t spitxrx(uint16_t data){
    uint32_t base = SPIA_BASE;
    uint16_t z, RX;
    z = data << 8;
    z &= 0xff00;
    while((HWREGH(base + SPI_O_STS) & SPI_STS_BUFFULL_FLAG) != 0U);
    HWREGH(base + SPI_O_TXBUF) = z;

    while((HWREGH(base + SPI_O_STS) & SPI_STS_INT_FLAG) == 0U);
    RX = (HWREGH(base + SPI_O_RXBUF));
    return(RX);
}

void PinMux_init()
{
    GPIO_setPinConfig(GPIO_58_SPISIMOA);
    GPIO_setPadConfig(58, GPIO_PIN_TYPE_PULLUP);
    GPIO_setQualificationMode(58, GPIO_QUAL_ASYNC);

    GPIO_setPinConfig(GPIO_59_SPISOMIA);
    GPIO_setPadConfig(59, GPIO_PIN_TYPE_PULLUP);
    GPIO_setQualificationMode(59, GPIO_QUAL_ASYNC);

    GPIO_setPinConfig(GPIO_60_SPICLKA);
    GPIO_setPadConfig(60, GPIO_PIN_TYPE_PULLUP);
    GPIO_setQualificationMode(60, GPIO_QUAL_ASYNC);

    GPIO_setPinConfig(GPIO_61_GPIO61);
    GPIO_setPadConfig(61, GPIO_PIN_TYPE_STD);
    GPIO_setDirectionMode(61, GPIO_DIR_MODE_OUT);
}

void SPI_init()
{
    SPI_disableModule(SPIA_BASE);
    SPI_setConfig(SPIA_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA1,
                  SPI_MODE_MASTER, 10000000, 8); ////// bitrate set to 4.
    SPI_disableFIFO(SPIA_BASE);
    SPI_disableLoopback(SPIA_BASE);
    SPI_setEmulationMode(SPIA_BASE, SPI_EMULATION_FREE_RUN);
    SPI_enableModule(SPIA_BASE);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

FOR CUSTOM BOARD-F28384D.
our custom board uses a 20MHZ external oscillator. and the available spi pins are 24,25,26,27. we configrued the LSPCLK to be divided by 1. and set the LSPCLK prescaler to 1.

24  -  SIMO

25  -  SOMI

26  -  CLK

27  -  GPIO for CS

Below image: While reading EEPROM status register. using custom board. bitrate set to 4

Below image: while writing Data to EEPROM with custom board . bitrate set to 4.

Below image: While reading data from EEPROM Address with custom board. bitrate set to 4. YOU CAN SEE THAT THE EEPROM IS SENDING DATA BUT IT IS MISS MATCHED.



The Below are the pin mux and spi base configuration and function used to send and recive data

uint16_t spitxrx(uint16_t data){                                  //function to send and recive data.
    uint32_t base = SPIB_BASE;
    uint16_t z, RX;
    z = data << 8;
    z &= 0xff00;
    while((HWREGH(base + SPI_O_STS) & SPI_STS_BUFFULL_FLAG) != 0U);
    HWREGH(base + SPI_O_TXBUF) = z;

    while((HWREGH(base + SPI_O_STS) & SPI_STS_INT_FLAG) == 0U);
    RX = (HWREGH(base + SPI_O_RXBUF));
    return(RX);
}

void PinMux_init()
{
    //
    // SPIB -> mySPI0 Pinmux
    //
    GPIO_setMasterCore(24, GPIO_CORE_CPU1);
    GPIO_setPinConfig(GPIO_24_SPIB_SIMO);
    GPIO_setPadConfig(24, GPIO_PIN_TYPE_PULLUP);
    GPIO_setQualificationMode(24, GPIO_QUAL_ASYNC);

    GPIO_setMasterCore(25, GPIO_CORE_CPU1);
    GPIO_setPinConfig(GPIO_25_SPIB_SOMI);
    GPIO_setPadConfig(25, GPIO_PIN_TYPE_PULLUP);
    GPIO_setQualificationMode(25, GPIO_QUAL_ASYNC);

    GPIO_setMasterCore(26, GPIO_CORE_CPU1);
    GPIO_setPinConfig(GPIO_26_SPIB_CLK);
    GPIO_setPadConfig(26, GPIO_PIN_TYPE_PULLUP);
    GPIO_setQualificationMode(26, GPIO_QUAL_ASYNC);

    // GPIO27 -> SPI_CS_GPIO Pinmux
    GPIO_setMasterCore(27, GPIO_CORE_CPU1);
    GPIO_setPinConfig(GPIO_27_GPIO27);
    GPIO_setPadConfig(27, GPIO_PIN_TYPE_STD);
    GPIO_setDirectionMode(27, GPIO_DIR_MODE_OUT);

}
void SPI_init()                                                                                              //same as which i used in launch pad f28379d except for base and pins.
{
    //mySPI0 initialization
    SPI_disableModule(SPIB_BASE);
    SPI_setConfig(SPIB_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA1,
                  SPI_MODE_MASTER, 40000000, 8);                ///bitrate set to 4.
    SPI_disableFIFO(SPIB_BASE);
    SPI_disableLoopback(SPIB_BASE);
    SPI_setEmulationMode(SPIB_BASE, SPI_EMULATION_FREE_RUN);
    SPI_enableModule(SPIB_BASE);
}


  • Ajay,

    Logic analyzer you are using seems to support only upto 8 MHz. In your SPI code, you are using SPI at 40 MHz. Your logic analyzer will not be able to sample SPI signals fast enough.

    Switch oscilloscope with much higher bandwidth.

    Regards,

    Manoj

  • Manoj,

    Unfortunately we don't have the support of oscilloscope, so we reduced the clock frequency to 1MHz. still the problem hasn't resolved yet.

    below are the screenshots for clk frequency 1MHz.

    below: Read EEPROM register using F28384D. SPIB_BASE as master.

    Below : enable write and writing data to EEPROM address.

    Below : read the written EEPROM address.

    Below : Expression window while transmitting and receving  YOU CAN SEE THAT THE SEND DATA AND READ DATA ARE MISS MATCHED.

    sendData = transmit data.

    readData = Receive data.

    Below are the screenshots of TX and RX buffers while transmitting and receiving data.

    TX buffer

    RX buffer

    below are Peripheral and pin configurations

    void PinMux_init()
    {
        // GPIO27 -> CS_PIN_27 Pinmux
        GPIO_setPinConfig(GPIO_27_GPIO27);
        //
        // SPIB -> SPIB_master Pinmux
        //
        GPIO_setPinConfig(GPIO_24_SPIB_SIMO);
        GPIO_setPinConfig(GPIO_25_SPIB_SOMI);
        GPIO_setPinConfig(GPIO_26_SPIB_CLK);

    }

    void GPIO_init(){
            
        //CS_PIN_27 initialization
        GPIO_setDirectionMode(CS_PIN_27, GPIO_DIR_MODE_OUT);
        GPIO_setPadConfig(CS_PIN_27, GPIO_PIN_TYPE_STD);
        GPIO_setMasterCore(CS_PIN_27, GPIO_CORE_CPU1);
        GPIO_setQualificationMode(CS_PIN_27, GPIO_QUAL_ASYNC);
    }
    void SPI_init()
    {
        
        //SPIB_master initialization
        SPI_disableModule(SPIB_master_BASE);
        SPI_setConfig(SPIB_master_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA1,
                      SPI_MODE_MASTER, 1000000, 8);
        SPI_disableFIFO(SPIB_master_BASE);
        SPI_disableLoopback(SPIB_master_BASE);
        SPI_setEmulationMode(SPIB_master_BASE, SPI_EMULATION_FREE_RUN);
        SPI_enableModule(SPIB_master_BASE);
    }

    function used to send and recieve data

    uint16_t spitxrx(uint16_t data){
        uint32_t base = SPIB_BASE;
        uint16_t z, RX;
        z = data << 8;
        z &= 0xff00;
        while((HWREGH(base + SPI_O_STS) & SPI_STS_BUFFULL_FLAG) != 0U);
        HWREGH(base + SPI_O_TXBUF) = z;

        while((HWREGH(base + SPI_O_STS) & SPI_STS_INT_FLAG) == 0U);
        RX = (HWREGH(base + SPI_O_RXBUF));
        return(RX);
    }

  • Are you writing and reading from the same EEPROM address? The logic analyzer snapshots don't seem to suggest so.

    When you attached scopeshots please let us what you are transmitting and receiving. Provide clear description of the problem going into the details. It is difficult to decipher looking into scopeshots and arbitrary code for us to find the problem.

    For example:

    1) Transmit WRITE ENABLE byte (0x06)

    2) Transmit byte 0x02 (What does this byte represent? Is this WRITE command byte?)

    3) Transmit 0x0 (Is this EEPROM address?) Why are you sending two 0's

    Did you read any status register in EEPROM to make you a reading from EEPROM correctly?

    Also, have you check spi_ex6_eeprom example in C2000Ware?

    Regards,

    Manoj

  • Manoj,

    Are you writing and reading from the same EEPROM address? The logic analyzer snapshots don't seem to suggest so.

    Yes we are reading and writing in the same address (0x0000).

    Transmit byte 0x02 (What does this byte represent? Is this WRITE command byte?)

    Yes, 0x02 is a Command to write data to the address. and in the Read screenshot byte 0x03 is read command to read an address.

    Transmit 0x0 (Is this EEPROM address?) Why are you sending two 0's

    The EEPROM has a 16 bit address array and we are sending data in 8bits, hence the two 0's.

    Did you read any status register in EEPROM to make you a reading from EEPROM correctly?

    Yes manoj we read the status register of the mentioned EEPROM, and the EEPROM returned 0x0000.

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    have you check spi_ex6_eeprom example in C2000Ware?

    Like you've suggested we have tried out the spi_ex6_eeprom example program from c2000ware V 4_01_00_00, by changing the master base to SPIB_BASE and the spi pins to 24, 25, 26, 27 in the same spi_ex6_eeprom.syscfg file.. and changed the SPIA_BASE to SPIB_BASE in main file.

    While running the program the data in the variable TXbuff[BUFFER_SIZE] was written successfully.

    when reading the address by using SPI_readByte_EEPROM(base, EEPROM_ADDR), it returns the value  (0x01) which the first value of the array TXbuff, the PASS value counts and moves to the next command.

    But while reading the second data using SPI_read16bits_EEPROM(base, SPI_DATA_LITTLE_ENDIAN, EEPROM_ADDR), it returns the value (65281) which was not equal to 0x0201, and it went to ESTOP;--BELOW screenshot

    The same happened while reading the data using SPI_read16bits(base, SPI_DATA_BIG_ENDIAN, EEPROM_ADDR), it returns the value (511) which was not equal to 0x0102 , and it went to ESTOP.--BELOW screenshot

    the same happened  in SPI_read24bits_EEPROM(base, SPI_DATA_LITTLE_ENDIAN, EEPROM_ADDR), it returned the value(16776961) which was not equal to 0x030201, hence ESTOP.--BELOW screenshot

    while reading data from SPI_read24bits_EEPROM(base, SPI_DATA_BIG_ENDIAN, EEPROM_ADDR), it returned the value (131071) which was not equal to 0x010203, and it went to ESTOP.--BELOW screenshot

    and while using the SPI_read32bits_EEPROM(base, SPI_DATA_LITTLE_ENDIAN, EEPROM_ADDR), it returned the value (4294967041) which was not equal to 0x04030201 hence it went to ESTOP.--BELOW screenshot

    and while reading using the SPI_read32bits_EEPROM(base, SPI_DATA_BIG_ENDIAN, EEPROM_ADDR) , it returned the value (33554431), which was not equal to 0x01020304 hence it went to ESTOP.--BELOW screenshot

    And while reading 64 addresses using readData(EEPROM_ADDR, &RXbuff[0], BUFFER_SIZE, NO_DELAY), the first character of the array is returned as 1 and the rest is returned as 0xff(255). which is not equal to TXbuff[64], hence it went to ESTOP.--BELOW screenshot

    Below are spi pheripheral and pin mux configuration in board.c generated by spi_ex6_eeprom.syscfg file.

    void Board_init()
    {
        EALLOW;

        PinMux_init();
        GPIO_init();
        SPI_init();

        EDIS;
    }

    void PinMux_init()
    {
        // GPIO27 -> SPI_CS_GPIO Pinmux
        GPIO_setPinConfig(GPIO_27_GPIO27);
        //
        // SPIB -> mySPI0 Pinmux
        //
        GPIO_setPinConfig(GPIO_24_SPIB_SIMO);
        GPIO_setPinConfig(GPIO_25_SPIB_SOMI);
        GPIO_setPinConfig(GPIO_26_SPIB_CLK);

    }

    void GPIO_init(){
            
        //SPI_CS_GPIO initialization
        GPIO_setDirectionMode(SPI_CS_GPIO, GPIO_DIR_MODE_OUT);
        GPIO_setPadConfig(SPI_CS_GPIO, GPIO_PIN_TYPE_STD);
        GPIO_setMasterCore(SPI_CS_GPIO, GPIO_CORE_CPU1);
        GPIO_setQualificationMode(SPI_CS_GPIO, GPIO_QUAL_SYNC);
    }
    void SPI_init()
    {
        
        //mySPI0 initialization
        SPI_disableModule(mySPI0_BASE);
        SPI_setConfig(mySPI0_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA1,
                      SPI_MODE_MASTER, 1000000, 8);
        SPI_disableFIFO(mySPI0_BASE);
        SPI_disableLoopback(mySPI0_BASE);
        SPI_setEmulationMode(mySPI0_BASE, SPI_EMULATION_STOP_MIDWAY);
        SPI_enableModule(mySPI0_BASE);
    }

  • SPI EEPROM provided was written with EEPROM AT25128/256. The command structure might not be the same across different EEPROM vendors. You mostly likely have to adapt this example for your EEPROM.

    CAT25128 datasheet want user to send only 1 byte address after OPCODE. why are you sending two address bytes?

    Regards,

    Manoj

  • SPI EEPROM provided was written with EEPROM AT25128/256. The command structure might not be the same across different EEPROM vendors. You mostly likely have to adapt this example for your EEPROM.

    The command opcodes are same for AT25128 and CAT25128. And we have adapted the example to for our EEPROM.

    CAT25128 datasheet want user to send only 1 byte address after OPCODE. why are you sending two address bytes?

    The CAT25128 uses 16-bit address array so i send 2 bytes of address data.

    And we have already worked this project using LAUNCHXL-F28379D and it works.

    The problem is that we don't have any SPI pins available other than GPIO24, GPIO25, GPIO26, GPIO27 on our custom board which has TMS320F28384D. So we ported the project for TMS320F28384D and configured these pins for SPI, and we have mentioned issues.

    Right now forget about F28384D custom board.

    we can proceed with launchpad itself.

    We have used GPIO24, GPIO25, GPIO26, GPIO27 in  LAUNCHXL-F28379D. and we configured as  SPIB_BASE.

    we converted SPI A Base program to SPIB_BASE. but we face problem  and not functioning Like SPIA BASE.

    Kindly confirm MUX configuration..

    BELOW pin configuration and peripheral configuration used in LAUNCHXL-F28379D for GPIO's GPIO24, GPIO25, GPIO26, GPIO27:

    void PinMux_init()
    {
        GPIO_setPinConfig(GPIO_24_SPISIMOB);
        GPIO_setPadConfig(24, GPIO_PIN_TYPE_PULLUP);
        GPIO_setQualificationMode(24, GPIO_QUAL_ASYNC);

        GPIO_setPinConfig(GPIO_25_SPISOMIB);
        GPIO_setPadConfig(25, GPIO_PIN_TYPE_PULLUP);
        GPIO_setQualificationMode(25, GPIO_QUAL_ASYNC);

        GPIO_setPinConfig(GPIO_26_SPICLKB);
        GPIO_setPadConfig(26, GPIO_PIN_TYPE_PULLUP);
        GPIO_setQualificationMode(26, GPIO_QUAL_ASYNC);

        GPIO_setPinConfig(GPIO_27_GPIO27);
        GPIO_setPadConfig(27, GPIO_PIN_TYPE_STD);
        GPIO_setDirectionMode(27, GPIO_DIR_MODE_OUT);
    }
    ////////////////////////////////////////////////////////////SPI Initialize///////////////////////////////////////////////////////////////////////////////////////////
    void SPI_init()
    {
        SPI_disableModule(SPIB_BASE);
        SPI_setConfig(SPIB_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA1,
                      SPI_MODE_MASTER, 1000000, 8);
        SPI_disableFIFO(SPIB_BASE);
        SPI_disableLoopback(SPIB_BASE);
        SPI_setEmulationMode(SPIB_BASE, SPI_EMULATION_STOP_MIDWAY);
        SPI_enableModule(SPIB_BASE);
    }

    Thanks and Regards

    Sunil

  • Sunil,

    Your PinMUX configuration looks just fine.

    Only thing I would change is below configuration.

        SPI_setEmulationMode(SPIB_BASE, SPI_EMULATION_FREE_RUN)

    Are you able to get the same thing working in SPIA configuration on F28388d launchpad?

    Regards,

    Manoj

  • Manoj,

    Only thing I would change is below configuration.

        SPI_setEmulationMode(SPIB_BASE, SPI_EMULATION_FREE_RUN)

    Yes manoj we changed the emulation mode to SPI_EMULATION_FREE_RUN and SPI_PROT_POL0PHA1 now its working.

    Thank you for your valuable time and support.

    Regards,

    Sunil.