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.

Using SPI from DSP on OMAP-L138 KiT

Other Parts Discussed in Thread: OMAP-L138

Hello!

I have OMAP-L138 Experimenter Kit and I want to communicate with one of peripheral devices which is set on SPI CS1 (there is also flash memory on SP1 CS0).

Please may you help me to figure out which registers should I use to select chip 1 

According to OMAP-L138 Technical Reference Manual, I should 

0. set 4-pin mode

spi->SPIPC0 = SOMI | SIMO | CLK | SCS0; //4-pin mode with chip select 

1. set 1 bit of SPIPC0.SCS0FUN to show that SPI_CS1 - is a SPI functional pin 

SETBIT(spi->SPIPC0, 0x00000002); //set 1st bit to show that SPI_CS1 - is a SPI functional pin 

2. set 17 bit of SPIDAT1.CSNR (It means that SPI_CS1 pin is driven high.) 

 spi->SPIDAT1 = 0;
SETBIT(spi->SPIDAT1, 0x20000); //set 17th bit (corresponds to SPI_CS1)

3. set 1 bit of SPIDEF.CSDEF (It means that SPI_CS1 pin is driven high.) 

 spi->SPIDEF = 0;
SETBIT(spi->SPIDEF, 0x00000002); //set 1st bit (corresponds to SPI_CS1) in CSDEF field

4. finally, before reading data from SPI1_CS1 device, I should set SPIDAT1.CSHOLD to held active chip select signal 

 SETBIT(spi->SPIDAT1,0x10000000); //set 28th bit which represents CSHOLD 

Is it correct or I misunderstood something? 

Thank you!

  • I still try to select device on CS1 instead CS0.

    I have tried the procedure described below to turn off CS0 device (which is flash memory) 

    // enable spi SOMI, SIMO, CLK, and SCS0.
    spi->SPIPC0 = SOMI | SIMO | CLK | SCS0; //4-pin mode with chip select
    //set 1st bit of SCS0FUN to show that SPI_CS1 - is a SPI functional pin
    SETBIT(spi->SPIPC0, 0x00000002); 
    //clear 0th bit of SCS0FUN to show that SPI_CS0 - is not a SPI functional pin
    CLRBIT(spi->SPIPC0, 0x00000001);
    //set cs 1 default
    spi->SPIDEF = 0;
    SETBIT(spi->SPIDEF, 0x00000002); //set 1st bit (corresponds to SPI_CS1) in CSDEF field

    Then I send cmd fast read (to check that I not communicate with flash on CS0 but with other device on CS1 which doesn't know this cmd) 

    And after all I still receive data from flash memory!!  

    // send the fast read cmd and addr.
    rtn = NUMONYX_sendCmdFastRead(0x00100000);
    if (rtn != ERR_NO_ERROR)
    {
    printf("NUMONYX_sendCmdFastRead Error? rtn = %d \r\n", rtn);
    return (rtn);
    }
    memset(rx_buffer, 0xFF, MAX_BUFFER_SIZE);
    //read data from SPI
    rtn = SPI_xfer(SPI1, NULL, rx_buffer, MAX_BUFFER_SIZE, SPI_HOLD_ACTIVE);
    if (rtn == ERR_NO_ERROR)
    {
    UTIL_printMem((uint32_t) rx_buffer, rx_buffer, MAX_BUFFER_SIZE, PRINT_HEADER);
    }
    
    


    I'll be grateful for any assumptions!

  • It seems that I have figured it out. Besides above-mentioned actions I have to set PINMUX

    • Setting up 0th bit in the register PINMUX5 - selects function SPI1_SCS[1]
    • Setting up 4th bit in the register PINMUX5 - selects function SPI1_SCS[0]