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.

  • Resolved

RTOS/TDA2HV: Need example code to run in the use case mode

Part Number: TDA2HV

Tool/software: TI-RTOS

Hi All,

We are working on the ADAS's TDA2x platform.We designed our custom board using a TDA2HV processor.We use using the vision SDK for development.We are using the lvds_vip_multicam_view use case. We want to use SPI's data to in our use case.For SPI interfacing TI provided the utils_Mcspi.c and utils_MCspi.h file, This file only contains SPI initialization function.So, how we can write and read into the SPI transmit and receive buffer.

My query is,
1) Can you please share SPI'slave example code in which we can run in the use case?

Please let me know if you need the more information from our side.

Thanks,
Parth Modi

  • In reply to Prasad Konnur:

    Hi Prasad,

    Thanks for the reply,

    As of now, Our TDA2x Soc is working on the Slave mode.On slave side, we receive the data perfectly from the master (MOSI).But when we send the data from Slave to Master the First bit is missing on master side(MISO line).We used the SPI mode 3(CPOL = 1and CPHA = 1) for communication.

    if we send the data 129((binary)1000 0001) from the salve then we receive the master side 3 (0000 0011).

    I have attached CRO screenshot for your information.Inside screenshot yellow line is for SCLK and the blue channel is for the MISO line.

    My query  is,

    1) How to resolve this data going wrong on the master side?

    Please suggest us some solution to resolve this issue.

    Please let me know if you need more information on our side.

    Thanks,

    Parth Modi

  • In reply to parth Modi:

    Hi Parth,

    The TDA2 SOC when configured in McSPI slave mode, does not control the clock. It will only responds to the clock sent from the external master. So it cont send the bit before master initiates the clock.

    How have you connected the slave on the board? Are the track lengths of MOSI, MISO and clock same?

    Regards,
    Prasad

  • In reply to Prasad Konnur:

    Hi Prasad,

    Our track length is as per below

    MOSI 312.61 + 4476.41 = 4789.02 mils

    MISO 306.11 + 3208.36 = 3514.47 mils

    CS# 211.32 + 3103.34 = 3314.66 mils

    CLK 248.9 + 3117.13 = 3366.03 mils

    We connected the Master device to the level shifter.

    Tad2x( slave) <-> levelshifter<->MCU(Master)

    We are getting GIO_reclaim stuck after calling GIO_issue for one time.if we call this function for 2 times than it works well(i.e one every time we need to call issues the 2 times data and reclaim claim the 2 times data).

    I have attached my code for your information.

    What is region to behind the struck the GIO_Reclaim?

    We want to take the SPI data on every instance of receive interrupt from the master.Can please share me some example code to implement it.

    Thanks,

    Parth Modi2744.mcspiSample_io.c

  • In reply to parth Modi:

    Parth,

    Only for the first time you need 2 GIO_issue, This is to prime the data to be sent as default response from slave.

    The driver internally maintains the queue for the response to be sent in case of slave mode.

    After this you can do GIO_reclaim followed by a GIO_issue.

    In the attached code I see that the issue is called only during priming.

    You can refer the example itself, which does multiple GIO_issue and reclaims.

    Regards,
    Prasad

  • In reply to Prasad Konnur:

    Hi,

    We are still facing issues in doing SPI communication So I would like to clear few points here based on your previous suggestions.

    For SPI communication , we should first make a call of GIO_issue twice followed by 2 GIO_reclaim call and these are calls to make SPI initialization only, please verify.

    Actual data transmission will start after above steps, till now no valid data read/write.

    Now in for loop we can call GIO_issue and GIO_reclaim for each data read/write , I mean one issue/reclaim in each loop, right ?

    Please clear our understanding here.

    Thanks.

  • In reply to Rajesh Rathod:

    Hi,

    The first 2 GIO_Issue are required for priming to the driver with the data to be sent as response.
    After the first 2 GIO_Issue the transfer can start. Transfer will be initiated by the external SPI master.

    After this you can do the reclaim and issue in a loop.
    The GIO_reclaim is a blocking call and does not return till the first transfer is complete.

    At the end outside the loop you can do the final recalim to get all the buffers from driver.

    Regards,
    Prasad
  • In reply to Prasad Konnur:

    Hi Prasad,

    We are trying to implement SPI communication since long time and struggling to understand the issue, please read below description for our requirement and the issue details.

    We are using TDA2XX board and Vision SDK 3.1 and we are running in the slave mode.
    Our motive is to read 13 byte data (including checksum) from Master.

    Please refer attached file for our implementation, we are using GIO_ISSUE and GIO_RECLAIM API for the receiving the data.
    To simulate data send from Master, we are using "HI-WAVE" tool.

    Below is the scenario which happens while changing the data from HI-WAVE tool.

    1. After SPI init, first we are changing data from HI-WAVE tool to simulate master to slave communication, and with this simulation slave should receive 13 byte from master but no data is received on slave side.
    2. Now again changing data from HI-WAVE to different value, we are receiving two frames of 13 byte in which first frame is incorrect while second frame has valid data.
    3. Changing data third time from HI-WAVE, we are receiving 13 byte on slave side which is garbage value.

    This above three points keeps repeating in subsequent changes.

    Please review our implementation and let us know how we can receive correct data from master to slave in single transmission only whenever master sends any data.

    You can refer function "getSpiData" in the attached file for the actual communication code and here are some constants which we have used in that file.

    / Macros for SPI Implementation /

    / Buffer size /
    #define BUFLEN (16 * 1)

    / Alignment of buffer for use of L2 cache /
    #define BUFALIGN 128

    / Number of Iterations /
    #define ITERATION_CNT 100

    / Num Bufs to be issued and reclaimed /
    #define NUM_BUFS 2

    We are struggling with the SPI since long time, please reply with the priority as we have some urgency.

    Regards,







    chains_lvdsVipMultiCamMirrorReplacement.c

  • In reply to Rajesh Rathod:

    Hi Rajesh,

    In your code the setSpiReadyHigh sets some GPIO pin, what is it used for?

    You can prime the buffers before the while, Then in the while loop you add 1 reclaim at the beginning and 1 issue at the end of the loop till you want to receive the data from external master.

    Regards,
    Prasad

  • In reply to Prasad Konnur:

    Hi,

    setSpiReadyHigh sets pin high/low to send indication to MCD that SoC is ready for send/receive data.

    As I said earlier we would like to send/receive 13 byte data and after some work we found that making it 16 byte and setting buffer alignment and buffer size to 16 works for us in one direction (MCU -> SoC) but in reverse direction (SOC -> MCU) still data is received only once on MCU side for every two send from Soc.

    Please reply your feedback.

    Regards,

  • In reply to Rajesh Rathod:

    Hi,

    Can you change the GPIO toggle after the priming?

    Also as I mentioned earlier you need to issue 2 buffers at the beginning which is called priming.
    After this you can reclaim one buffer and issue one buffer in loop till you send/receive the desired number of bytes.
    Can you change the code flow as above and try?

    Regards,
    Prasad

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.