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

DMA and SPI [SOLVED]
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Sun Apr 15, 2018 11:48 pm     Reply with quote

OK. You move forward.
The DMA needs to be set to increment the source buffer address. Otherwise it transfers from a single address to a single address.
curt2go



Joined: 21 Nov 2003
Posts: 200

View user's profile Send private message

PostPosted: Mon Apr 16, 2018 8:38 am     Reply with quote

I was sure I had that set. I will check.

Thank you again all for your help. This has been a crazy one for me.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Mon Apr 16, 2018 1:46 pm     Reply with quote

What you posted as your example, did not have the increment enabled.

As a comment one big problem is not handling the SPI receive. Problem is that unless you do the overrun error flag will become set. When this happens the peripheral will stop operating....
curt2go



Joined: 21 Nov 2003
Posts: 200

View user's profile Send private message

PostPosted: Mon Apr 16, 2018 2:17 pm     Reply with quote

Thank you. I will check tonight. I thought I looked at the flags and seen it was set. I also thought the CCS code sets it unless you tell it not to set #define DMA_NO_INC 0x10 . But then again I made a lot of assumptions lately that have gotten me nowhere. Smile

But i'm sure you are right. I don't think i've seen an instance of where you were wrong yet. Smile


EDIT: Yes I do not have it in continuous mode, I did so many back and forth stuff over the last few days. I will set that and hopefully be off to the races.

And I did use another DMA on the receive side. Even though i don't need it. It will keep the buffer clean.

Thank you again.
curt2go



Joined: 21 Nov 2003
Posts: 200

View user's profile Send private message

PostPosted: Mon Apr 16, 2018 5:44 pm     Reply with quote

Its clocking out way too fast ? The DMA does not seem to be stopping it just shoves as fast as it can ?
Code:

setup_dma(0, DMA_OUT_SPI1, DMA_WORD); //could be DMA_BYTE
setup_dma(1, DMA_IN_SPI1, DMA_WORD); //could be DMA_BYTE

enable_interrupts(INT_DMA0);
dma_start(0,DMA_PING_PONG|DMA_CONTINOUS,playBufferAddress,fillBufferAddress,127);
dma_start(1,DMA_CONTINOUS|DMA_PING_PONG,DMAIncomming,DMAIncomming2,127);
enable_interrupts(INT_DMA1);

playBuffer and fillbuffer are 256 byte buffers. I am filling each opposite one everytime into the DMA int. Let me know if you have any thoughts. Again I am in SLAVE mode using frame sync. The timing works fine if i manually watch the buffer and shove data in when it's empty using SPI1BUFF.
curt2go



Joined: 21 Nov 2003
Posts: 200

View user's profile Send private message

PostPosted: Mon Apr 16, 2018 5:55 pm     Reply with quote

I had my FORCE inside my loop. That is what was going on. But now the DMA is not firing again!

LOL.. It just gets better and better.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Apr 17, 2018 11:04 am     Reply with quote

If you only want to do a block and stop, then don't use continuous. Trigger the DMA, and you get the DMA interrupt when the block has been transferred.
curt2go



Joined: 21 Nov 2003
Posts: 200

View user's profile Send private message

PostPosted: Tue Apr 17, 2018 1:58 pm     Reply with quote

I have found the very root of all the issues. If I would have done this from the start it probably would have only been a few hours of fooling around.

Late last night I decided to try something. Instead of using CCS to set up the SPI I decided to do it manually. Once I set it up i decided to enable the SPI after I set up the DMA and enabled them. Well guess what. Everything works as predicted now. I get interrupts when I should , I get transfers starting properly and running properly after.

I will post some code later.
dyeatman



Joined: 06 Sep 2003
Posts: 1910
Location: Norman, OK

View user's profile Send private message

PostPosted: Tue Apr 17, 2018 4:16 pm     Reply with quote

You might also pass this on the CCS folks.
They may have some code bug issues.
_________________
Google and Forum Search are some of your best tools!!!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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