IndeedDMA, as I understand it, is something that moves data from one place to the other "in the background".
Commanding the DMA to take the Data from the 10KB Buffer to the 1MB Buffer and knowing when to do it are the things that need to be done efficiently.so that it should not take any processor time (other than setup the dma transaction).
Periodically?Write some code that periodically transfers data from the 10kb buffer to the 1mb storage... that is all.. adjust the period to be "fast enough" for you.
NorthGuy said:Don't wait. As soon as something is written to the buffer start DMA.
That would not be possible:misterT said:you could trigger the dma write after every write you do in the 10kb buffer
You're right.NorthGuy said:Obviously, if you write faster than DMA can transfer it, you can run out of buffer space. You cannot prevent this, so you should be ready for this situation.
What is the "design" problem here?
different Data Parameters - the value of some real-time calculation, real-time data as the strength of the received signal at a certain time, logging messages which are transferred between 2 processors (the uC and other processor), etc.misterT said:could you even give us a hint.. what kind of data you are logging.
How often -> every few us to every few ms.misterT said:how often and how much?
I don't know when the system stops.NorthGuy said:If you only need the messages before the system stops, why do you want to write them all the time?
The problem is while the system is running.NorthGuy said:If you want to write more, can you delay stopping the system to have more time for DMA?
I haven't compared yet the time differences between writing to each memory.misterT said:How fast is the 10kb memory and how fast is the 1mb memory?
Simply.misterT said:How does the DMA work in your chip..
My question is:
What Algorithm would you use to copy data from the 10KB buffer into the 1MB buffer, which takes into account:
1. losing as much data as possible
2. wasting as less cycles as possible on 'managing' actions (e.g. actions which are not pure writing to the memory - for example, checking when the DMA should be trigger, the amount of times the uC triggers the DMA, etc).
There're many tasks running on the uC - each task has many threads and each thread logs its own parameters to the 10KB buffer using the functions I wrote for logging.misterT said:Impossible to say without better knowledge about the incoming data..
I thought of actually doing that.just trigger the DMA transaction at constant intervals. Or when the 10kb buffer reaches some limit.
I tested it and I see that the logging is not more than a pace of 1KB / 0.47ms.You say you want the "managing actions" to be very efficient, but it sounds like you have no idea what is the max. limit you can spare.. and you have no statistics about the incoming data.
It's a company-internal uC.atferrari said:What uC are you planning to use?
Can't call that statistics really.. but if you have a way to time 3ms intervals then I would trigger the DMA at 3ms rate to transfer everything in the buffer to the larger storage.I tested it and I see that the logging is not more than a pace of 1KB / 0.47ms.
How would you use that statistics for when to trigger the DMA?
Hard to say without knowing how the buffer is implemented. Calculate how much data is in the buffer and after some limit trigger the dma.What would be a 'cycles'-efficient way to check whether the 10KB buffer has reached some limit?
well the DMA doesn't pass the entire buffer, but just section of it at a time.misterT said:Can't call that statistics really.. but if you have a way to time 3ms intervals then I would trigger the DMA at 3ms rate to transfer everything in the buffer to the larger storage.
The buffer is simply a static array.misterT said:Hard to say without knowing how the buffer is implemented. Calculate how much data is in the buffer and after some limit trigger the dma.
That's exactly the thing - how to calculate when to trigger the DMA, efficiently.misterT said:Calculate how much data is in the buffer and after some limit trigger the dma.
Mostly, yes.NorthGuy said:So this is just for debugging in case the system crashes?
Actually it is very important, because without the ability to debug your failures, your product will not be mature enough nor market ready.NorthGuy said:Usually you do not want to work hard to optimize your debugging because it's going to be removed from production anyway.
I'm not sure what you're suggesting.The processor you use is probably fast, since you run so many threads. If you're called every 10us on 100MHz processor, it's one write every 1000 cycles. Initiating DMA, will probably take no more than 10 cycles, 1% overhead. If your system cannot take that, it's a problem in itself.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?