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: Arm-based microcontrollers forum

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

Hi,

The preceding Zip file has a msp430 driver library...How to porting this file in Am243x Launchpad? 

I tried porting that file, but the SPI communication does not function on that code.

The above file is a porting to AM243x launchpad. I need your help.

Thanks 

  • Hi Abi Bharathi,

    1. Both the links that you posted don't seem to work. Can you please recheck?

    2. Also can you please explain why do you want to port the msp430 driver library to am243x?

    3. What is the exact functionality that you want to achieve?

    Can you please answer the above to enable us to help you better?

    Regards,
    Shaunak

  • Hi Shaunak,

    We used the AM243X launchpad controller in our project and would want to port it. I want to read load cell's(1022)  adc value and then calibrate it. So, in that adc value in the SPI interface.

    https://www.ti.com/product/ADS131M02#design-development

    The above link has a driver library...


    Thanks

    Abinaya

  • Hi Abinaya,

    The AM243x McSPI driver API and usage are different than that of the MSP430. Please refer to the AM243x MCU+ SDK example:mcspi_loopback_am243x-lp_r5fss0-0_nortos_ti-arm-clang. The McSPI instance initialization/open code is generated based on the example.syscfg by syscfg automatically.

    You can download the latest AM243x MCU+ SDK from: MCU-PLUS-SDK-AM243X Software development kit (SDK) | TI.com

    Best regards,

    Ming

  • Hi Ming,

    Sorry for the delayed response....

    • I am able to use TI’s SDK ,mcu_plus_sdk_am243x_09_00_00_30, example (mcspi_loopback) to send/receive data over SPI between AM243x LP boards and Arduino.
    • “MCSPI_transfer()” to send and receive SPI data between master/slave at the same time (synchronously) which is not usable in our use cases. We need  Master as  am243x lp and  Slave is a ADC15 CLICK module itself with a ads131m03 24 bit adc  i can send a txbuf  0x00 and receive SPI data in rxbuf is 0 while using that MCSPI_transfer function
    • I have tried other SPI drivers (MCSPI_writeTxDataReg() and MCSPI_readRxDataReg()) to write and read SPI data respectively but it received in random  data 112.
    • Other than MCSPI_transfer(), MCSPI_writeTxDataReg() and MCSPI_readRxDataReg() API function calls, is there any other API I can use to read and write SPI data?

    The preceding image is a taken in logic analyzer waveform.

    Thanks,

    Abinaya

  • Hi Abinaya,

    If you use the AM243x LP as the SPI master, then the SPI clock should have been provided by the AM243x LP. The MCSPI_transfer() is the right function to call for receiving the data from ADC15 CLICK module with the TX buffer set to zero (or anything). The SPI clock generated by the MCSPI_transfer() will be used by both TX and RX. From the screen capture, I did not see the SPI clock (Channel 3). Without SPI clock, the SPI slave will not send any data. That is why you did not receive any data from SPI slave.

    Can you send me your SPI configuration (example.syscfg) and the parameter settings for MCSPI_transfer()?

    Best regards,

    Ming

  • Hi Ming,

    Thank you for the reply. 

    The following image shows the SPI setup (example.sysconfig).

     

    The below function includes parameter setting for MCSPI_transfer().

    uint8_t spiSendReceiveByte(const uint8_t dataTx){

    Drivers_open();
    Board_driversOpen();


    uint32_t baseAddr, chNum;
    uint8_t dataRx;
    baseAddr = CONFIG_MCSPI0;
    chNum = gConfigMcspi0ChCfg[0].chNum;
    MCSPI_Transaction spiTransaction;                                              

    MCSPI_Transaction_init(&spiTransaction);
    spiTransaction.channel = gConfigMcspi0ChCfg[0].chNum;
    spiTransaction.dataSize = 16;
    spiTransaction.csDisable = TRUE;
    spiTransaction.count = (spiTransaction.dataSize/8);
    spiTransaction.txBuf = 0x00;
    spiTransaction.rxBuf = dataRx;
    spiTransaction.args = NULL;

    uint32_t transferOK = MCSPI_transfer(gMcspiHandle[CONFIG_MCSPI0], &spiTransaction);

    DebugP_log("send data %d\r\n",dataTx);
    DebugP_log("receive data %d\r\n",dataRx);


    Board_driversClose();
    Drivers_close();

    return NULL;

    }

    Can you possibly offer some guidance on how to read adc data via SPI communication?

    Thanks,

    Abinaya

  • Hi Abinaya,

    As I mentioned in the previous post, you will need to set "spiTransaction.txBuf = dataTx;" to make SPI clock working.

    Best regards,

    Ming

  • Hi Ming,

    Thank you very much. Actually, I did everything you indicated in your response, and sure, SPI is currently worked, however the adc data is not being read by dataRx.

    The function below is for reading adc data.

    bool readData(adc_channel_data *DataStruct)
    {
    int i;
    uint8_t bytesPerWord = getWordByteLength();
    uint8_t dataRx[4] = { 0 };

    /* Set the nCS pin LOW */

    setCS(LOW);

    dataRx[i] = spiSendReceiveByte(0x15);

    DataStruct->response = combineBytes(dataRx[0], dataRx[1]);

    dataRx[i] = spiSendReceiveByte(0x00);

    DataStruct->channel1 = signExtend(&dataRx[0]);

    dataRx[i] = spiSendReceiveByte(0x00);

    DataStruct->channel2 = signExtend(&dataRx[0]);


    setCS(HIGH);

    // Returns true when a CRC error occurs
    return NULL;
    }

    If there is any instruction or example program can indicates how to utilize function to read adc data.

    Thanks,

    Abinaya

  • Hi Abinaya,

    If the McSPI RX/TX of the AM243x is working properly, then you should focus on the HW connection between the AM243x LP and the ADS131M02. Please refer to the 9.1.6 Code Example and 9.1.3 Minimum Interface Connections of the ADS131M02 2-Channel, Simultaneously-Sampling, 24-Bit, Delta-Sigma ADC datasheet (Rev. A) (ti.com).

    Best regards,

    Ming

  • Hi Ming,

    Thankyou very much for your response...

    As you mentioned, I'm checking with that code and interface connection to write that code based on the ads131m02 referred that sample code.

    I'm using 1022 loadcell interface with the ADC15 click module using in AM243x lp 

    The am243x lp sends one register address to the adc module, which responds with 16-bit data. 

    The following function sends and receives data using SPI communication.

    I am sending in that write register 16 bit value is 0x6000 received from the adc module value is 53dc (HEX).if I don't know if the data is correct or not.

    Is it possible to send  a single register value and get the same value back from adc?

    Thanks,

    Abinaya

  • Hi Abinaya,

    I am not an expert of ads131m02 and personally I never used this part before. I think the best place to ask for help is the e2e ADC forum.

    Best regards,

    Ming