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

Routine for DMA and AT25DF161 in the DSPIC33FJ256GP506.

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



Joined: 01 Aug 2011
Posts: 26
Location: BRAZIL

View user's profile Send private message Visit poster's website

Routine for DMA and AT25DF161 in the DSPIC33FJ256GP506.
PostPosted: Thu Dec 29, 2011 6:54 am     Reply with quote

I'm trying to use the DMA to read 4 channels of AD in DSPIC33FJ256GP506 and send straight to a memory AT25DF161 in SPI2.
Could someone give a help with this, because I do not even know where to begin.
I need to read these four channels at top speed for 2 seconds. So I want to use DMA.
I need some example using DMA and a routine for PIC AT25DF161 memories.

I really appreciate everyone's attention.

Thank you, Hugo.
temtronic



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

View user's profile Send private message

PostPosted: Thu Dec 29, 2011 7:36 am     Reply with quote

Where to begin....split the project up into smaller tasks,tackle one, then the next.
Your 'datalogger' consists of several tasks so
1) cut code to read the 4 channels of analog and display on say a local LCD or send to PC. That way you'll decide what kind of buffering,noise levels, etc. you have to deal with.Actually start with one channel then keep adding 1 until all 4 are correct. You don't say what resolution(8 bit,10 bit) but more means it's more susceptable to 'noise'.

when you're happy that section or task works ,start on the 'save data to memory' task. Don't use the A2D data but hard data( known values).Again cut the code, test say by displaying the data going to the AT25 on one line of LCD then read back the data,display on the 2nd line of LCD. This will show you whether your routine is working correctly.

The 3rd task is some kind of 'control interface( stop/start/reset) task. Pushbuttons or commands from a PC ?. Again,cut code, get it to work with say LEDs to show where the program is running( stop/capture/save/etc).

Once all 3 tasks are 'up and running', merge them into one main program and it should work fine......

If that works, then recode the datatransfer to use DMA.

By breaking the project down into smaller managable sections, you can build up 'functions' and 'routines' that you know work instead of one monster program that no one can figure out where ,what went wrong.
hugo_br



Joined: 01 Aug 2011
Posts: 26
Location: BRAZIL

View user's profile Send private message Visit poster's website

PostPosted: Thu Dec 29, 2011 8:54 am     Reply with quote

Hello temtronic.

What I want is to do that. Start with smaller, separate routines and then roll them into a larger routine.

I want just that, a datalogger. I need to read 4 channels of AD in 10bits in the DMA mode and transfer this data to this memory 4MB AT25DF161.
I need to separate these readings of ADs with ";" and then be easy to structure on PC.
I record all of these four readings AD in memory and then send everything that was written in this memory to a PC via RS232. Analyze these data will be made ​​later by its own software to eliminate unwanted data. For now I will not worry about noise.

I need even with examples of DMA routines and routines for reading and writing of this memory AT25DF161.

Thank you for your help.

Hugo.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Dec 29, 2011 10:06 am     Reply with quote

I don't think, that DMA brings you far in writing the Flash. After writing 256 Bytes, you need to poll the Flash for write termination, typical 1 ms, up to 5 ms.
temtronic



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

View user's profile Send private message

PostPosted: Thu Dec 29, 2011 8:26 pm     Reply with quote

hmm..as the snow flies....

downloaded the flash info sheet, says it's 16 megabit..that's 2 megabytes.

IF you can store 256 bytes in 1ms, in 2 seconds you'ld save 2048 blocks of 256 bytes each. To save 4 ADC 10 bit readings( easy if 16 bit) + a delimiter( comma for CSV files) you need 12 bytes per 'record' ( or recording), so you could save 170 'records' in your 2 second limit.

That's providing you did nothing else. Haven't considered reading the ADCs,formatting data to be stored, SPI configuration( where to store, counters,etc).

If you can or have the time, crunch the numbers again but I'd seriously look at using a Vinculum and flashdrive for your 'datalogger'. Tons of storage space and very fast. Currently I have one at 115,200 baud with zero problems. That's 11,500 bytes / second or 958 of your 'quad adc data records in csv format' . If you want more data the Vinculum will do 3,000,000 baud ( 300,000 bytes/second, about 50,000 records in 2 seconds.

Vinny modules are about $30 each and cn be 'up and running' in an hour.
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