RL78 F13 - Needed sample code to understand DTC functionality with ADC Scan One shot mode

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,

Meet

Parents
  • Hello,

    Yes, I can provide this for you. 

    So when the INTAD occurs, you want to store the 4 results of the 4 ADC channels in a buffer using DTC, correct ?

  • Yes, every trigger of ADC SOC will generates 4 INTAD interrupts one by one after EOC(end of ADC conversation). 

    Steps: 

    1. So when 1st interrupt comes, transfer the result from ADC result register(source address is fixed for DTC) to arr[0] register. 

    2. Then when 2nd INTAD interrupt comes after 2nd channel ADC EOC, same ADC result register data should be copied to arr[1].

    3. Likewise for 3rd and 4th interrupt, DTC should transfer the ADC result register data into arr[2] and arr[3]. 

    4. Then array counter will reset and next trigger of ADC SOC, will start again and repeat steps from point no 1.

    Note :  I have considered 16 bit data transfer for 10bit ADC. 

    Kindly consider above scenario for sample code. 

    In addition, I have few queries as mentioned below - 

    1. for DTC destination address, how and where I can configure if the destination array is present in another file. e.g. uint16_t arr[4];

    2. How array index counters will be incremented while transferring next ADC result register data via DTC? 

    3. How DTC understand counter reset and destination address will start to store again from arr[0] ? 

    Thanks & Regards, 

    Meet

  • Hi,

    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[4] ; 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.

    https://www.renesas.com/us/en/document/mat/rl78-family-self-ram-list-flash-self-programming-library-rev305

    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.

  • Hi AZ_Renesas,

    May i know why you have selected DTCBLSj (block size) as 2 in your sample code?

    Actually ADCR is 16 bit register so DTCBLSj should be 1 right ? As per below table 

      

  • Hi I found the answer, it is generating as 01 only. Thanks!

  • Hi In this sample code, DTC buffer is updated only once, may i know why it's not updating current ADC conversion continuously?

  • On my project the buffer is updated continuously.

    If you have the RL78/F13 target board ANI0 is connected to VDD and ANI1 is connected to ground so you will not see much change on those channels.

    Regards

  • actually Im checking ANI3, and checking the value of adc_results_buffer[3],

    1. it is showing the initial pin ADC value

    2. when i change the ADC pin voltage to another voltage range or connect to ground. the buffer value is not changing. 

    3. when i reset the uC and start the execution, at that time DTC buffer is updating according to the current pin Voltage level once. 

Reply
  • actually Im checking ANI3, and checking the value of adc_results_buffer[3],

    1. it is showing the initial pin ADC value

    2. when i change the ADC pin voltage to another voltage range or connect to ground. the buffer value is not changing. 

    3. when i reset the uC and start the execution, at that time DTC buffer is updating according to the current pin Voltage level once. 

Children