Dear Renesas community,
I'm looking for sample code to understand DTC with ADC scan one shot mode.
Needed scenario like 4 ADC channels conversion data want to transfer from ADCR to 4 different variables at each INTAD interrupt.
and 4 variables like arr[index], index value will be incremented at each INTAD interrupt. and index will be reseted after 4th channel ADC conversion
Could you please provide the sample code for the same?
Thanks & Regards,
Please find the attached demo project.
ANI0-ANI3 channels are scanned and stored at 0xFF400 address in RAM using DTC.
The destination address is usually specified in Code Generator…
1) Well, if you decide to have a buffer in RAM to store the results, you need to know the memory range of RAM and select an address.
But some regions of RAM are used for other purposes too, so you need…
If the DTC is enabled after the interrupt, the interrupt itself cannot trigger the DTC transfer.
Starting DTC inside the ISR cannot transfer the 1st result.
1) It is not like it skips, it is not yet active so it cannot be triggered by something that occurred in the past.
2) ADC conversion end does not set anything, it just triggers the activation source. The transfers start and stop when:
3) Yes. In this case the DTC will do a transfer and increment if needed.
Please correct me if im wrong,
When ADC conversion end will trigger the activation source automatically and it will set DTCEN1.bitno6 then without calling R_DTCD0_Start() externally as per below code snap, the transfer will be initiated, and address will be incremented in repeat mode. Correct ?
If yes, Then what is the use of R_DTCD0_Start() function ?
2. What will happen next when incremented address reach to last index of the array ? I want to start from 0th index again once it will store all the adc channel data till 4th index
1) R_DTCD0_Start makes sure the DTCEN1 bit is 1 so the DTC transfer is enabled.
2) This is what is done in repeat mode. The source or destination address is incremented until a point where it goes back to the initial address. Please read the datasheet and look into the DTC configurations of the project
1. But without calling this function as well DTC activation will be triggered after ADC conversion end and DTC transfer will happen, right? or it is mandatory to call R_DTCD0_Start() function at every end of ADC conversion.
It depends on whether the interrupt generation is enabled or disabled:
The DTCEN bits will be changed from 1 to 0 while RPTINT is 1 in repeat mode.
Here I have some queries regarding 1st point,
1. You said : But some regions of RAM are used for other purposes too",
So for this, where i can get detailed information of RAM usage, like what part of RAM used for library, stack area etc.
2. #pragma address macro is used to create/reserve a section under the RAM area during build time?
3. can we achieve this by defining the memory section in below compiler settings? and how to calculate the memory if i need uint16_t arr ; so how can i add section here ?
can you please modify the sample code and provide the added section entry in below setting instead of using #pragma address, if possible.?
1) The reserved areas are explained on the pages I mentioned. If the project uses a flash library, the self-RAM area should also be reserved. You can find the self-RAM area of your device on this document.
2) The #pragma address macro is used to tell the linker to put the adc_buffer in the specific address. It does not reserve anything in memory.
3) You could create a new section in RAM, but you would still need to tell the linker to put the adc_buffer inside this section. So you do not gain anything from doing this. It is basically the same process.
How to select the flash library?
If you have a flash library question please create a new post.
Sure, thank you so much for supporting for this DTC related query.