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.

DMA reads incorrectly from SPI on TMS470

Other Parts Discussed in Thread: ADS1278, TMS470R1B1M, HALCOGEN

Hi, 

I have configured DMA to read data over SPI (reads from ADS1278 - 2 bit adc). This works fine most of the times. Once in blue moon a power up results in bad reading over DMA. I used a scope to monitor the traffic and I noticed that the data is still good over SPI. It seems like DMA is not fetching the data correctly from SPI. The values are jumping all over the place though scope reveals that the values from ADC are good. Any idea what could be wrong. My DMA initialization for reading from SPI-1 is as follows. 

void Init_SPI1(void)
{
SPI1CTRL2 &= ~SPIEN; 
SPI1CTRL3 &= ~RX_INT_EN; 

// Configure SPI port 1
SPI1CTRL1 = 0 | CHARLEN_8; // 8 bits/char

SPI1CTRL1 |= SPI_PRESCALE_47; 

SPI1CTRL2 |= MASTER; // We are the master
SPI1CTRL2 |= CLKMOD; // We drive the clock
SPI1CTRL2 &= ~POLARITY; // CLK Polarity = 0
SPI1CTRL2 |= PHASE; // Phase = 1 

SPI1PC6 = 0 | CLK_FUN; // SCLK pin
SPI1PC6 |= SIMO_FUN; // SIMO pin
SPI1PC6 |= SOMI_FUN; // SOMI pin


SPI1CTRL3 |= DMA_REQ_EN; // DMA request enable

SPI1CTRL2 |= SPIEN; // Activate the SPI
}

void Init_DMA(void)
{
DMAGC = 0; // Channel service size = 1
DMAGD = 0; // Clear STOP and HALT mode
DMACPSCLR = 0; // Disable all control packets
DMAS = 0; // Clear all pending interrupts
DMACCP0 = 0; // Disable channels 0-3
DMACCP1 = 0; // Disable channels 4-7
DMACCP2 = 0; // Disable channels 8-11
DMACCP3 = 0; // Disable channels 12-15
}

void SPI1_DmaExchange (uint8_t *txbuf, uint8_t *rxbuf, uint16_t size)
{
DMAC01 = 0 | INTEN | DSTINC | DSTMOD_2 | SRCMOD_15;
DMASA01 = (uint32_t)&SPI1BUF + 3;
DMADA01 = (uint32_t)rxbuf;
DMATC01 = size;
// Notify the DMA that Control Packet 1 is updated
DMACPS |= CPACK_1;
// Channel 1 Configuration
DMACC0 |= SEN1 | RQEN1;
// Channel 1 Enable with Control Packet 1
DMACCP0 |= CCPACK1_1 | DMEN1;

// DMA setup for SPI1:TX (Packet 2/Channel 2)
// Control Packet 2 Configuration
DMAC02 = 0 | SRCINC | SRCMOD_2 | DSTMOD_15;
DMASA02 = (uint32_t)txbuf;
DMADA02 = (uint32_t)&SPI1DAT0 + 1;
DMATC02 = size;
// Notify the DMA that Control Packet 2 is updated
DMACPS |= CPACK_2;
// Channel 2 Configuration
DMACC0 |= SEN2 | RQEN2;
// Channel 2 Enable with Control Packet 2
DMACCP0 |= CCPACK2_2 | DMEN2;
}

Any help is appreciated. 

Pinakin 

 

  • Hi Pinakin,

    Sorry I don't have an idea about this.

    The DMA control packets themselves are stored in a RAM, and what you describe could be that something in the RAM is not initialized explicitly but is random and subject to differences in how the values are on power up. So you could try adding code to initialize even the unused RAM of the DMA controller first, during power up. Then if this makes the part act consistently you can dig deeper to see if you can identify the actual problem.

    Other than that - it will be hard to debug unless you can make the blue-moon's come more frequently.

    -Anthony
  • Anthony,

    I need to correct my phrase - it is not really once in blue moon. I am able to reproduce it almost every 1 in 7 power up runs. The ram locations I am using are defined as static arrays, which should be available when SPI and DMA are configured. Also I tried to reset SPI as well as halt and resume DMA. This did not seem to help.

    Do you have any example code for setting up DMA for SPI-1. I would like to verify if my steps are correct.

    Pinakin
  • Hi Pinakin,

    The only example code I'm aware of is on a DVD that shipped w. the IAR kickstart.   Not sure what projects are there.     Do you have that DVD?

    The TMS470R1B1M is NRND for a long time now so it is very difficult to support.  

    And it was a product that came out when we had very little in the way of software support from TI.  

    If at all possible - I would recommend you look at migrating to the TMS570LS012xx series.  

    You can get a launchpad for $19.99 which includes an on-board emulator and works with the free (unlimited in time / code size) XDS100 license.

    This product would give you a slightly larger flash size,  more than 2x the SRAM,  an upgrade to Cortex R4 (which is actually ARM7TDMI compatible unlike Cortex M)   and basically the same peripherals but all with 'upgrades'.   This is the migration path that our larger customers who started with TMS470R1B1M have taken a long time ago.   So even though the part number changes 470->570 it's going to be a very natural upgrade.      The only thing lacking is that the R1B1M in particular had 5 I2C ports .. I think there is just 1 I2C on the 122x but if you really really need more I2C ports the 122x has a second N2HET which can emulate the I2C.     (BTW N2HET is a *huge* improvement over the older HET..)

    The main benefit though is we're setup here to support you well on the TMS570 and there is quite a lot of software for it;  including HalCoGen which will let you configure all the peripherals graphically, generate your startup code to initialize the device so you just start w. your app at main(), and there are a lot more HalCoGen based examples including SPI & DMA examples for you to begin with.

  • Anthony,

    The reason I am using this controller is that our application is for high temperature. So we use HT version of this chip. I dont think TMS570 supports high temperature.

    Pinakin
  • Hi Pinakin,

    Ok, in that case if you are using the SM470 - please post questions on the HiRel forum.
    The HiRel team does have someone who is actively working with this part and is in a better position to help.
  • Anthony,

    Could you please provide a link for HiRel.

    Thanks,

    Pinakin
  • Hi Pinakin,

    e2e.ti.com/.../

    Just make sure to say you are designing for the SM470R1B1M.
    I assume you just are using TMS470R1B1M as a low cost development vehicle.

    -Anthony
  • Hi Pinakin,

    Did you get your questions answered from this forum ?
  • Anthony, 

    This issue is NOT yet resolved. I have not received any response from TI. I am still waiting for a response. 

    Pinakin 

     

  • Hi Pinakin, sorry to hear that. Did you open a thread on the HiRel forum as we discussed?
    If so please send me the link.
  • Anthony,

    Here is the link to the thread I started in HiRel forum.
    e2e.ti.com/.../1759056

    In previous message I did send schematics and also verified the example code. I would appreciate if someone can respond soon on this.

    Pinakin
  • Pinakin,

    Ok so this should be pretty easy to narrow down. I'm going to close this thread and put a next step suggestion on the HiRel forum.