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.

Problem with GIO_read psp function

Hello everybody!

I'm working with Omapl-138 processor; using code composer studio v 3.3.82.13, dsp/bios 5.41.02.14 and psp 01.30.01.

I'm trying transmit data from first omap to second via SPI interface. For that purposes i'm using psp functions: GIO_create, GIO_read, GIO_write.

I have no problems with transmitting data(creating gio channel and writing data to it), but have some troubles with receiving.

On receiver side i use GIO_create to create channel, it's ok, and GIO_read to get data from channel. But GIO_read returns error code -1 (generic failure).

I can see memory map of SPI1 and correct data in receive buffer, but i can't understand how to receive it via psp streaming functions...

There is my settings for spi:

    spiParams_inp = Spi_PARAMS;
    spiParams_inp.hwiNumber = 8;
    spiParams_inp.spiHWCfgData.intrLevel = TRUE;
    spiParams_inp.spiHWCfgData.masterOrSlave = Spi_CommMode_SLAVE;
    spiParams_inp.spiHWCfgData.pinOpModes = Spi_PinOpMode_SPISCS_4PIN;
    spiParams_inp.spiHWCfgData.clkInternal = FALSE;
    spiParams_inp.opMode = Spi_OpMode_INTERRUPT;
 
    spiParams_inp.loopbackEnabled   = FALSE;
    spiParams_inp.edmaHandle        = NULL;
 
    spiParams_inp.spiHWCfgData.configDatafmt[0].charLength   = 16;
    spiParams_inp.spiHWCfgData.configDatafmt[0].clkHigh      = FALSE;
    spiParams_inp.spiHWCfgData.configDatafmt[0].lsbFirst     = FALSE;
    spiParams_inp.spiHWCfgData.configDatafmt[0].oddParity    = FALSE;
    spiParams_inp.spiHWCfgData.configDatafmt[0].parityEnable = FALSE;
    spiParams_inp.spiHWCfgData.configDatafmt[0].phaseIn      = TRUE;
    spiParams_inp.spiHWCfgData.configDatafmt[0].waitEnable   = FALSE;
    spiParams_inp.spiHWCfgData.csDefault = 0x1;

Creating GIO channel this way:

   chanParams.hEdma = NULL;
    spiHandle_inp = GIO_create("/Spi1",IOM_INPUT,NULL,&chanParams,NULL);
 
    if (NULL != spiHandle_inp)
    {
        LOG_printf(&trace,"GIO_create OK! \n");
    }
    else
    {
        LOG_printf(&trace,"GIO_create ERROR! \n");
    }

 

and trying to read data:

size = sizeof(buf_dest)/sizeof(uint16_t);
devStatus = GIO_read(spiHandle_inp, &buf_dest, &size);
 
if (IOM_COMPLETED == devStatus)
       {
        LOG_printf(&trace,"GIO_read OK! \n");
    }
    else
    {
        LOG_printf(&trace,"GIO_read ERROR! \n");
    }

 

If everybody solved such problem - please help! Thanks in advance!

  • I can't tell from the code fragment that you posted but I think you have to pass in Spi_DataParam structure to GIO_read(). I've used the master mode. Never slave mode. Here's a guess:

    Spi_DataParam       dataparam;

    dataparam.outBuffer    = (Uint8*)0;
    dataparam.inBuffer     = (Uint8*)buf_dest;
    dataparam.bufLen       = sizeof(buf_dest); /* In bytes */
    dataparam.chipSelect   = YOUR_CHIP_SELECT_MASK; /* Used only in Master????? */
    dataparam.dataFormat   = Spi_DataFormat_0;
    dataparam.flags        = 0; /* 0 or Spi_CSHOLD */
    dataparam.gpioPinNum   = 0; /* Not used */
    dataparam.csToTxDelay  = 0; /* Not used */

    size = sizeof(dataparam);
    devStatus = GIO_read(spiHandle_inp, &dataparam, &size);

    Note that PSP 01.30.01 has a bug with 16 bit words. Maybe siwtch to 8 bits. My 16 bit patch here:

    http://e2e.ti.com/support/embedded/f/355/t/130781.aspx

     

     

  • Thanks for reply, Norman!
    I changed settings to work with 8-bit data.
    Applied your parameters and received error code -13 when reading with GIO_read... But the last error code,
    described in help is -12. Also I cant see correctly received data in memory window, like in previos case. Problem not resolved.

    I attempted to use GIO_control to reset channel:

    Stats spiStats;

    status = GIO_control(spiHandle_inp, IOM_CHAN_RESET, &spiStats);
    if(IOM_COMPLETED == status)
    {
        LOG_printf(&trace,"GIO_control OK! \n");
    }
    else
    {
        LOG_printf(&trace,"GIO_control ERROR! \n");
    }

    I received error code -10(illegal arguments used). What's wrong? Is it incorrect to use Stats structure here?

    It defined in "pspdrivers_01_30_01\packages\ti\pspiom\spi\spi.h" ? How can I use it?

    I also tried this function with NULL 3rd parameter and received same error code.

     

  • Not sure if I can help much more. Slave mode looks to be much different than master. I can't find any slave examples in the PSP package. Hopefully some BIOSPSP gurus will speak up. Some notes:

    Errors codes:

    iom.h
    IOM_EBADIO        -1
    IOM_ETIMEOUT      -2
    IOM_ENOPACKETS    -3
    IOM_EFREE         -4
    IOM_EALLOC        -5
    IOM_EABORT        -6
    IOM_EBADMODE      -7
    IOM_EOF           -8
    IOM_ENOTIMPL      -9
    IOM_EBADARGS      -10
    IOM_ETIMEOUTUNREC -11
    IOM_EINUSE        -12


    SpiLocal.h
    Spi_RECEIVE_OVERRUN_ERR -12
    Spi_BIT_ERR             -13
    Spi_DESYNC_ERR          -14
    Spi_PARITY_ERR          -15
    Spi_TIMEOUT_ERR         -16
    Spi_DATALENGTH_ERR      -17
    Spi_CANCEL_IO_ERROR     -18

    Looking at the SPI driver source code, it does not appear to support IOM_CHAN_RESET. These are the only supported messages:
    Spi_IOCTL_CANCEL_PENDING_IO, cmdArg unused
    Spi_IOCTL_SET_CS_POLARITY, cmdArg is pointer to Spi_CsPolarity
    Spi_IOCTL_SET_POLLEDMODETIMEOUT, cmdArg is pointer to Int32

  • There were biterror and overrun error bits set in flag status register (0x01F0E010),
    but I didn't thought it can prevent me from achieving data. Tried to resolve problem by wtiting 1 to corresponding
    bits (4 for biterr and 6 for overrun) - no effect... Trully don't understand how to handle
    this errors with BIOS API.
    Turned off all interrupts in Spi_local.h except "receiver full" and "transmitter empty". Data received correctly!
    Thanks for idea - to check Spi_local.h!