cancel
Showing results for 
Search instead for 
Did you mean: 

SPI DMA with ADS1256 on STM32f103RB

felipe
Associate II
Posted on January 29, 2013 at 18:04

Hi everybody,

I wanna know if its possible to use DMA SPI for drive the ADS1256 or similar where I can ''stop'' the tranfer to wait until the time to convert T6 (Delay from last SCLK edge for DIN to first SCLK) of the ads.

I tried a interrupt in TX (with a TC flag and a fuction hanlder) but it wont resolve the problem, the SCLK doesnt stop.

0690X00000602nZQAQ.jpg

I cant tought  in something to do with the DRDY pin.

I dont wanna bit banging its ugly but if its the only way...

Bye bye

5 REPLIES 5
tecnico23
Associate II
Posted on January 30, 2013 at 11:05

I don't believe that will be possible using the DMA.

I want to inform you (if you don't know) that the DMA doesn't control the NSS signal.

See this discussion,

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/DMA%20based%20SPI%20communication%20with%20NSS

Regards,

A. Paiva

felipe
Associate II
Posted on January 30, 2013 at 12:19

to be migrated, sourceId: 27825:697285D7-A9CA-445D-B16C-F23BF0E3B1A3

Posted on January 30, 2013 at 12:48

I could visualize a scheme based on timers - SCK being generated by timers chained for the non-standard waveform (and perhaps being also triggered by the DRDY signal from the ADC?), while the SPI module would be configured as slave.

(This could btw be also the answer for those who need to issue a framing signal with SPI).

I don't say it's simple or easy; the devil known to live in the details may even make it non-viable.

JW

felipe
Associate II
Posted on January 31, 2013 at 13:32

Hi,

Thankswaclawek.jan for the reply. I give up from DMA and now I am trying with normal SPI. And guess what? More problems. :( The clock appear with a latency that I can take off by removing ''

while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);

But when I do that I read wrong the data. The 3 last bytes is what I have to read from ADS1 The first byte is the command for read the conversion (ADC). Here's the code:

/* SPI1 configuration ------------------------------------------------------*/
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_32;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_Init(SPI1, &SPI_InitStructure); 
SPI_Cmd(SPI1, ENABLE); /* Enable SPI1 */
SPI_I2S_SendData(SPI1, 0x01); /* Send SPI1 data (LEITURA ADS1241)*/
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
SPI_I2S_ReceiveData(SPI1);
while(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0)==0){} /* Espera conversão*/ 
while (TxIdx < 3){
SPI_I2S_SendData(SPI1, 0x00); /* Send SPI1 data */
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
SPI1_Buffer_Rx[TxIdx] = SPI_I2S_ReceiveData(SPI1);
TxIdx++;
}
TxIdx=0;

And here's the latency. If I use the

SPI_BaudRatePrescaler_32; on 128 the latency go away. But its too slow.

0690X00000604s8QAA.png I hope somebody can help me cuz I really need this done and I have no ideia what is going on.Thanks
felipe
Associate II
Posted on February 01, 2013 at 11:25

No one knows? :(