meca90
Joined: 06 Apr 2014 Posts: 6
|
Problem with DMA and SPI |
Posted: Mon May 25, 2015 11:44 pm |
|
|
Hi, I'm trying to use the DMA with SPI and SD Card, what I'm doing is simply replacing the SPI_WRITE and SPI_READ library functions that use for memory, instead DMA variables but it does not work that way, I'm missing something? I think I should mimic the structure SPI_READ() and SPI_WRITE() functions, to complete the process well. [I have had successful results with other DMA modules like PWM, ADC, UART]
For example i try to replace this
Code: |
for( i=0;i<16;i++){
spi_write(0xff);
}
|
For this
Code: |
for( i=0;i<16;i++){
CHEN3=1;
SPI1TX=0xFF;
FORCE3=1;
}
|
PD: here this code settings of SPI with DMA, and use the microcontroller DSPIC33EP256MU806
Thanks
best regards.
Code: |
setup_dma(3,DMA_OUT_SPI1,DMA_BYTE);
dma_start(3,DMA_ONE_SHOT|DMA_NO_INC|DMA_FORCE_NOW ,&SPI1TX);
setup_dma(4,DMA_IN_SPI1,DMA_BYTE);
dma_start(4,DMA_ONE_SHOT|DMA_NO_INC|DMA_FORCE_NOW,&SPI1RX);
Send a Byte:
CHEN3=1;
SPI1TX=0xFF;
FORCE3=1;
|
|
|