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.

Reading ADS1299 registers

Other Parts Discussed in Thread: ADS1299, AM4372

Hi ,


Have a situation where I expect 11 clock cycles from MASTER(AM437x) to SALVEADS1299 but when I actually probe the lines I get only 1 clock cycles. Let me explain what exactly is going on . My flow looks like this .


SDATAC - opcode 1 - 0x11 

delay of 2us

WREG command for 8 channels : - opcode1 - 0x40 | 0x05 (writing 8 channel registers for setting it into test mode)
opcode2- 8-1

Now when I probe on to clk and MOSI . I am able to detect clock only for SDTATC and after that I do not get any clock for WREG . This means it is not sending write command to slave . But why is this happening?

Now when I try to send multiple WREG command to my slave like some 5 times I start getting WREG signals on my probe lines(clk,MOSI) . Why does it require multiple WREG commands to send a write command to my SLAVE ?

I am attaching the probing signals 



Thanks
rahul

  • Rahul,

    What software are you using?

  • Hi ,

    I am just trying to write the driver for ads1299 . I am not able get any clock after sending SDATAC opcode

    Thanks
    rahul
  • Hi Biser,

    I am using spi protocol driver that is already available from ti kernel.When I say protocol driver I mean driver/spi/spi.c . I guess this has definition for spi_sync and spi_asunc, spi_message_add_tail() . I am using these functions for transfer of my spi data to my slave(ads chip). But the problem is after getting the first set clock and their data into the MOSI lines from Am437x . I am not getting any thing else on the bus that I am sending from my driver . So I wanted to know why is this so  ? My master(AM437x) clock for SPI transaction is 2 MHZ.

    Thanks

    rahul 

  • I will ask the SW team to explain SPI driver usage.

  • Hi Rahul,

    Sorry for the delayed response.

    If you check your am4372.dtsi you will see in the spi0/1 device nodes, that your spi is compatible with the "ti,am4372-mcspi","ti,omap4-mcspi", which means that you should check the apis from spi-omap2-mcspi.c. Have a look at the *_transfer functions, i.e.: omap2_mcspi_transfer_one_message()

    You can also use the spidev apis from user space. The following wiki could be of help: processors.wiki.ti.com/.../AM335x_McSPI_Driver%27s_Guide

    Hope this helps.

    Best Regards,
    Yordan
  • Hi yordan,

    Thanks for the reply . I am working on spi3 . I wanted to know how do I configure my SPI3 FIFO buffers (both Tx and RX) .Where are these information defined ? Is it in spi.c or mcspi.c. I want to change into 32 bit (word sized ) . which are those apis I have to use for it . I also what to change the frequency of my spi3 , where are they doing the scaling of spi frequency which is 48 MHZ .

    thanks
    rahul
  • HI yordan,

    What is the default spi FIFO buffer size ?

    rahul
  • Hi Rahul,

    This is done in spi-omap2-mcspi.c. Check static int omap2_mcspi_setup_transfer() function:

    /* standard 4-wire master mode:  SCK, MOSI/out, MISO/in, nCS

    * REVISIT: this controller could support SPI_3WIRE mode.

    */

    if (mcspi->pin_dir == MCSPI_PINDIR_D0_IN_D1_OUT) {

             l &= ~OMAP2_MCSPI_CHCONF_IS;

             l &= ~OMAP2_MCSPI_CHCONF_DPE1;

             l |= OMAP2_MCSPI_CHCONF_DPE0;

    } else {

             l |= OMAP2_MCSPI_CHCONF_IS;

             l |= OMAP2_MCSPI_CHCONF_DPE1;

            l &= ~OMAP2_MCSPI_CHCONF_DPE0;

    }

    /* wordlength */

    l &= ~OMAP2_MCSPI_CHCONF_WL_MASK;

    l |= (word_len - 1) << 7;

    /* set chipselect polarity; manage with FORCE */

    if (!(spi->mode & SPI_CS_HIGH))

             l |= OMAP2_MCSPI_CHCONF_EPOL; /* active-low; normal */

    else

            l &= ~OMAP2_MCSPI_CHCONF_EPOL;

    /* set clock divisor */

    l &= ~OMAP2_MCSPI_CHCONF_CLKD_MASK;

    l |= div << 2;

    /* set SPI mode 0..3 */

    if (spi->mode & SPI_CPOL)

             l |= OMAP2_MCSPI_CHCONF_POL;

    else

            l &= ~OMAP2_MCSPI_CHCONF_POL;

    if (spi->mode & SPI_CPHA)

            l |= OMAP2_MCSPI_CHCONF_PHA;

    else

            l &= ~OMAP2_MCSPI_CHCONF_PHA;

    mcspi_write_chconf0(spi, l);

    cs->mode = spi->mode;

    dev_dbg(&spi->dev, "setup: speed %d, sample %s edge, clk %s\n",

    OMAP2_MCSPI_MAX_FREQ >> div,

    (spi->mode & SPI_CPHA) ? "trailing" : "leading",

    (spi->mode & SPI_CPOL) ? "inverted" : "normal");

    return 0;

    SPI FIFO is set in omap2_mcspi_set_fifo() function in the same driver. 

    SPI controller has built in 64 byte buffer. It can be used either as a single 64 byte buffer, or, in some cases, as two separate 32 byte buffers. 

    Best Regards, 
    Yordan

  • Hi Yordan,

    If I need to do a 24 bit message (MOSI)transfer I need to generate 24 bit clock(SCLK) . Then will setting member bits_per_word = 24 in my spi_transfer structure and then doing spi_message_add_tail and spi_sync do this job ?? or should I go with DMA in SPI . The thing is I do not want a delay in my clock cycle after every byte of transfer . Is there any thing like spi_transfer will do the transfer only in one byte format ?

    Thanks
    rahul

  • Hi yordan ,

    When I set bits_per_word = 24 in my struct transfer and then do the spi_message_add_tail and spi_sync . I get the an error saying that .

    binder: 98304:2289 BC_FREE_BUFFER u5ee6d028 no match
    [ 77.309260] binder: 98304:2289 got transaction to invalid handle
    [ 77.315682] binder: 98304:2289 transaction failed 29201, size 100-0
    [ 77.322513] Unable to handle kernel NULL pointer dereference at virtual address 00000000

    Thanks
    rahul
  • Hi yordan,

    Now If I use DMA . the minimum bytes that are required for DAM is 160 . so now when I try doing a DMA transfer . Setting following : -

    static int send_byte(struct my_dev *dev,int data){        

           struct spi_message msg = { };

           struct spi_transfer transfer = { };

           msg.actual_length = 170;

            msg.is_dma_mapped = 1;

            spi_message_init(&msg);

            dev->tx_buff[0] = data;

            transfer.tx_dma = dev->tx_buff; // tx_buff = devm_kzalloc(&spi->dev, SPI_BUFF_SIZE, GFP_KERNEL | GFP_DMA);

            transfer.rx_dma = dev->rx_buff;    // rx_buff = devm_kzalloc(&spi->dev, SPI_BUFF_SIZE, GFP_KERNEL | GFP_DMA);

            transfer.len = 170;

            transfer.speed_hz =SPI_BUS_SPEED_SLOW;

            spi_message_add_tail(&transfer, &msg);

            status = spi_sync(dev->spi, &msg);

          return status;

    }

    After this I ma getting an error in spi.c file saying :-

    spi_master spi1: failed to transfer one message from queue . This message  popes form line : 603  of driver/spi/spi.c

    How do I proceed ? Is this error due to my transfer size exceeding ? Do I have to use dma_alloc_coherent ? 

     

    Thanks

    rahul 

     

  • Hi Rahul,

    Sorry for the delayed response. Is this issue still present?

    Which kernel is this? Have you check the spi-omap2-mcspi.c & spi.c drivers against the ones in latest officially released TI kernel (version 3.14.26, from: software-dl.ti.com/.../index_FDS.html)? Or against the latest sources in mainline kernel?

    Best Regards,
    Yordan