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 CCS Technical Support

dsPIC33 SPI with DMA

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



Joined: 06 May 2013
Posts: 33
Location: Toronto

View user's profile Send private message

dsPIC33 SPI with DMA
PostPosted: Thu Jan 03, 2019 10:28 am     Reply with quote

Hello All,

I am working on a project where FPGA and dsPIC33 are communicating through SPI. FPGA is a main processor, Master in SPI and sends temperature/Voltages setting to dsPIC33. Also read back temperature/Voltages readings. Is it possible for dsPIC33 to focus on temperature and voltage PID loops and read/write set points and feedback for temperature and voltages with SPI - DMA. I tried with SPI interrupt, it works but slow down the speed for SPI. I want to make it more faster. FPGA and dsPIC33 both running with 40Mh clock.
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Jan 03, 2019 10:56 am     Reply with quote

Yes. Heck, temperature is a slow response almost not worthy of full blown PID controller. 'voltage' might be different though.
2+ decades ago, I was controlling a 3d helicopter using a 16F877/20MHz in realtime via the internet so with a 'powerhouse' dsPIC33 it should be very, very easy to control whatever you're controlling.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Thu Jan 03, 2019 11:50 am     Reply with quote

You need to tell us more about the comms required.

Key thing with SPI, is that you have to use two DMA channels. One for
the transmission, and one for the reception.
A lot depends on the 'nature' of the SPI involved.
Ideally you need a fixed length 'packet'.
So a description of the data involved and the transactions involved.
Are there transfers both ways at the same time, or is there a setup
transmission followed by reads?
Is there anything to synchronise this or does it just happen as fast
as possible?
tripper269



Joined: 06 May 2013
Posts: 33
Location: Toronto

View user's profile Send private message

PostPosted: Thu Jan 03, 2019 12:29 pm     Reply with quote

I am using two DMA channels, for Rx and Tx. It will be fixed length packet, one or two bytes. The transfer will be on both sides at same time and it should work as fast as possible. whenever CPU is free, it should be able to write/read from DMA.

Thanks for reply.
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Thu Jan 03, 2019 12:33 pm     Reply with quote

You really want to be looking at a much larger packet.
You receive a DMA interrupt when the entire transfer is finished.
At this point you process the data.
Now using only a two byte packet, would mean that this would be
happening every two bytes.

DMA, does not involve the CPU. The CPU can be working while
DMA is occurring. The RAM is 'dual ported', so both the CPU
and the DMA controller can be accessing it at the same time. So
DMA does not happen 'when the CPU is idle', it is occurs all the time.

If you want just a two byte packet, then you probably need to be
triggering the DMA using a timer, rather than having it run 'as fast
as possible'. The DMA controller will then transfer the two byte
packet after it is triggered by the timer, and you get the completion
interrupt after the bytes have been transferred. This transfer will
be done at the same time as the CPU is working.

This is slightly different on the PIC33, compared to some of the
more basic PIC's. On the lower chips the DMA instead 'cycle steals',
only accessing the RAM, when the CPU is not doing so. I suspect
you are thinking of this way of functioning. On the PIC33, the DMA
system is more capable.
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