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.

MCU-PLUS-SDK-AM243X: MCSPI LLD API for separated read and write

Part Number: MCU-PLUS-SDK-AM243X
Other Parts Discussed in Thread: SYSCONFIG

Hi BU experts,

My customer is looking for separated API for MCSPI LLD (use read and write instead of readWrite). They have tried mcspi_lld_read() and mcspi_lld_write() in the mcspi_loopback_polling_lld example but gets incorrect data.

 

I saw in the lld driver document AM64x MCU+ SDK: MCSPI Low Level Driver (ti.com) that "The MCSPI peripheral must call MCSPI_lld_readWrite() / MCSPI_lld_readWriteIntr() / MCSPI_lld_readWriteDma() before the controller starts transmitting."

Does this means separated API is not available? How to use read and write APIs properly?

Thanks,

Hang.

  • Hello,

    The Subject Matter Expert will review this post and get back to you with a response. Thank you for your patience.

  • Hello Hang,

    I am going to take your query.

    Please allow me sometime to comment on this.

    Regards,

    Vaibhav

  • Hello Hang,

    I understood the problem you are trying to address here.

    So lets put it this way.

    You see the top level API being called is comprising of both read and write.

    Now instead of having separate read and write APIs, you can simply make the API behave as a write operation or read operation

    solely based on the parameters you pass to this API: MCSPI_lld_readWrite()

    The changes would be to the arguments: 

    gMcspiTxBuffer, gMcspiRxBuffer and count

    Let me know if you need the modifications to demonstrate the same.

    Regards,

    Vaibhav

  • Hi Vaibhav,

    Thank you for the info. I've asked the customer to use the readWrite() as you suggested. However, they still have concern about the separated API and would like to know the reason why the above example is not working. Is it because not calling read() and write() in the right way or there is some issue in the API?

    Thanks,

    Hang.

  • Hello Hang,

    I am going to run this SDK example at my setup and try the approach as mentioned by you.

    If I see a data mismatch at some offset, I will debug it and come back here with a response/fix.

    Also, it might be some SysConfig dependencies missing.

    Allow me sometime to check on this and get back to you.

    Regards,

    Vaibhav

  • Hello Hang, 

    Thanks for your patience.

    I am actively working on this, please allow me few hours to get back with a fix for this.

    Regards,

    Vaibhav

  • Hello Hang,

    I have been trying to debug this and see for Interrupt mode of loopback operation in context of MCSPI.

    This seems like a issue I need some more time to debug on.

    I am pretty sure that MCSPI_lld_write() and MCSPI_lld_read() apis can be used independently.

    It might be that this is a loopback example hence, its cause problems when it comes to reading. I am pretty sure write operation is working as its intended to be.

    I am going to provide a response on this earliest by Monday.

    Regards,

    Vaibhav

  • Hello Hang,

    I found out the root cause here.

    I tried the approach where I used separate write and read APIs of MCSPI LLD in Polled Mode of operation.

    I was using the classic MCSPI Loopback example which is provided in the SDK itself.

    What I have noticed is that after the Write API is called and is finished, the actual MCSPI TX and RX Registers are filled up with correct values.

    Please notice the below attached image.

    The above registers are populated even before the read API is called. 

    Now when the read API is executed and I debugged every step, turns out that the MCSPI FIFO Write is being called again, hence, the registers TX and RX both reset to 0, and is deprived of their actual values.

    As of now, I have checked internally and got to know that these APIs basically separate write and read APIs can be used for:

    • Write API: When the MCSPI is set to controller mode of operation
    • Read API: When the MCSPI is set to Peripheral mode of operation.
    • readWrite API: To demonstrate the loopback capability.

    I hope this explains the problem.

    Thanks for your patience.

    Regards,

    Vaibhav

  • Hi Vaibhav,

    Thank you for efforts on finding the root cause. Customer is trying your config now. I will come back to you if there is any update.

    Thanks,

    Hang.

  • Hello Hang,

    Good to know that the customer is trying the configuration with the separate read and write APIs.

    Please update me with the results if any, or if they are stuck somewhere.

    Happy to help Slight smile

    Regards,

    Vaibhav

  • Hi Vaibhav,

    Customer still have issue applying your configurations, could you export you test project and share it with me?

    Thanks,

    Hang.

  • Hello Hang,

    The customer is asking for which operational mode ? I have an external sensor, based on which I can try to demonstrate an example.

    The example could be as follows:

    Simply having the sensor attached to the board and receiving data from the sensor using the MCSPI_LLD_READ API.

    Will this be a good use case for the customer?

    Looking forward to your response.

    Regards,

    Vaibhav

  • Hi Vaibhav,

    That would be OK. Could you also include the write API? They can test some waveform at the output pin.

    Thanks,

    Hang.

  • Hello Hang,

    Yes I can make this application for the customer.

    Give me sometime to get back with it.

    I will update here itself with any progress.

    Regards,

    Vaibhav

  • Hello Hang, 

    Here is a little update on the debug I was trying to do with respect to the LLD Write and Read APIs.

    I have been able to perform the read and writes successfully but without the LLD APIs, so basically using the API MCSPI_transfer()

    When I am using the LLD Write and Read API I am seeing that the data is not received.

    I have filled a bug for this and I will update you as soon as I get any insights on this issue from the dev team.

    Thanks for your patience.

    Regards,

    Vaibhav

  • Hi Vaibhav, how is the demo going?

  • Hello Hang,

    I did file a bug for this and I am in touch with the dev team to get this fixed as soon as possible.

    Please allow me time until Tuesday(26/03/2024) to get back on this.

    Thanks for your patience.

    Regards,

    Vaibhav

  • Hi Vaibhav, is there any update?

  • Hello Hang,

    I was out of office, I am back and actively working.

    I am going to resume working on this tomorrow onwards and you can expect to hear from me tomorrow IST evening.

    Regards,

    Vaibhav

  • Hello Hang,

    A little update on this, I have been able to sit today and talk about this problem with the dev team itself.

    They are working on the same.

    Once I hear from them, I will update here in this thread.

    Regards,

    Vaibhav

  • Hello Hang,

    Can you let me know any exact Peripheral part that the customer is using, and treating AM243-LP's SPI as Controller.

    This can help me further, as the last update I got from dev team is that these APIs are working fine as they are intended to be.

    Regards,

    Vaibhav

  • Hi Vaibhav,

    Customer is using SPI to control AD, DA and MRAM. Since you too reproduced the issue, could you make demo based on am243x-LP using separated read and write API to access these three types of device, and align with the dev team again?

    Regards,

    Hang.

  • Hello Hang,

    these three types of device

    Based off this, I can give you a generic main.c file for you to send it to the customer. 

    Apart from this I am also going to check if in the latest RC there are some driver changes in the file mcspi_v0_lld.c

    Please allow me sometime to follow up here.


    Meanwhile you wait on my response, I would also like you to additionally check with the customer on the following things:

    1. Is the CPOL and CPHA correctly set in the SysConfig, and is it matching the SPI mode mentioned for peripheral part ?
    2. Is the frequency for SPI set in SysConfig supported by the Peripheral?
    3. Are the lines MISO and MOSI correctly connected? For example in SysConfig if you set the option INPUT ENABLE --> D0, and D0 --> TX DISABLED, D1 --> TX ENABLED, then your D) should act as MISO and D1 as MOSI.


    Regards,

    Vaibhav