Use of DMA?

12 views
Skip to first unread message

rob...@hotmail.com

unread,
Dec 6, 2025, 11:08:43 AM (13 days ago) Dec 6
to jallist
Hi all,

Has anybody of you had any need to use the Direct Memory Access (DMA) feature of a PIC?

I have no application yet but it could be handy if you want to automatically transfer a lot of data from one location to another location without using CPU cycles.

But there is already a problem with this. If for example you want to copy data from FLASH (e.g. by having a large CONST array) to a USART it would not work. For DMA you need to have the source address (so the FLASH address) of your CONST array and that address is normally provided by the WHEREIS function but this function does not work for CONST. I wonder where this limitiation of WHEREIS comes from and if there is a way to obtain the CONST address in another way. I have looked at the compiler source code but did not yet study it in sufficient detail if is just not - yet - implemented or not possible. Maybe 'older' JAL users may remember why this limitation exists?

Kind regards,

Rob





pinhe...@gmail.com

unread,
Dec 6, 2025, 11:37:14 AM (13 days ago) Dec 6
to jallist
Le 6 décembre 2025, à 17:08, rob...@hotmail.com <jal...@googlegroups.com> a écrit:

Hi Rob,

A CONSTANT has no adress during runtime.   It is replaced by its value during compiling on each instance.

Example:

Constant a = 8

B = a + 1

If you look at the same listing, you will see that a has been replaced by 8.   And if optimization does its work, you will have a b = 9, but that is another subject.

If you really need to find an adress for a constant value, example fir a string to send over to the uart, you will have to assign itvto a variable first.




--
You received this message because you are subscribed to the Google Groups "jallist" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallist+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/jallist/03d757a7-17eb-45a8-b578-1961932fcdedn%40googlegroups.com.

pinhe...@gmail.com

unread,
Dec 6, 2025, 12:16:55 PM (13 days ago) Dec 6
to jallist
Le 6 décembre 2025, à 17:37, pinhe...@gmail.com <pinhe...@gmail.com> a écrit:

Sorry for the typos.
Here is the corrected text:


"If you look at the asm listing, you will see that "a" has been replaced by 8.   And if optimization does its work, you will have b = 9, but that is another subject.

If you really need to find an adress for a constant value, example for a string to send over to the uart, you will have to assign it to a variable first."

rob...@hotmail.com

unread,
Dec 6, 2025, 12:35:34 PM (13 days ago) Dec 6
to jallist
Hi David,

You are right about a single constant. I meant a const array that is stored in Flash.

Kind regards,

Rob

Op zaterdag 6 december 2025 om 17:37:14 UTC+1 schreef pinhe...@gmail.com:

zma...@gmail.com

unread,
Dec 6, 2025, 1:50:26 PM (13 days ago) Dec 6
to jallist
Greetings,
If the constant array is accessed via a variable:

const x = { 1,2,3 }
y = 1
z = x[y]

the array will end up in the code memory as a series of RETLW. I don't think this will help with DMA.
--kylw

Rob CJ

unread,
Dec 7, 2025, 7:06:44 AM (12 days ago) Dec 7
to jallist
Hi Kyle,

I made a small change to the compiler source code, not sure yet if it works but I need to test.

There is check in the function 'pic_assign_from_value()' if something is a constant and if so the message is given that whereis cannot be applied to a constant. However, the compiler documentation states it should be possible to use whereis on a constant array which I would need for a DMA transfer to get the address of the const array.

So I made the following changes where it checks for a constant in pic_op.c.
Change:  if (!lbl) {
Into:  ((!lbl) & (!value_is_array(src))) {

The message is still given for a single constant but not for an array and the code seems to be generated.

I will now test to see if it actually works in combination with DMA.

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens zma...@gmail.com <zma...@gmail.com>
Verzonden: zaterdag 6 december 2025 19:50
Aan: jallist <jal...@googlegroups.com>
Onderwerp: Re: [jallist] Use of DMA?
 

zma...@gmail.com

unread,
Dec 7, 2025, 3:25:12 PM (12 days ago) Dec 7
to jallist
Greetings,

The difficulty is, you need to be able to distinguish (in whereis) the difference between a constant array and a variable array. If I recall (it's been a while), on the 16 bit cores constant arrays are still in code memory, but are defined using `db' so are actually contiguous bytes, as opposed to the 12 & 14 bit cores where they are `retlw' instructions. whereis on these would be pointless.
Reply all
Reply to author
Forward
0 new messages