CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Problem with DMA and SPI

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
meca90



Joined: 06 Apr 2014
Posts: 6

View user's profile Send private message

Problem with DMA and SPI
PostPosted: Mon May 25, 2015 11:44 pm     Reply with quote

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;

Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group