RA4E2 how to start ADC group B and its interrupt?

Hi,  I have two timers g_timer0 and g_timer1 running at 100kHz and 10kHz respectively.  I can see their trough interrupts in SW ISR routine.  I have setup the ADC in group scanning mode with group A to be started by g_timer0 UDF and group B by g_timer1 UDF.   I can see group A is doing fine as its end interrupt is happening on scope.  However I can't see group B end interrupt and believe it is not started by g_timer1 UDF as the ADC channel data registers values not updated.  I have checked ELSR8 and ELSR9 values.  They are set properly.  All ADC register values seem reasonable as well except that LGRRS bit in ADGSPCR needs to be set but remains zero.  Below are some screen shots from my FSP configurator.   Can you help shining some light on how to solve this problem.

Parents
  • Hello,

    When GPT0 which triggers group A is not running, is group B scan end ISR triggered ?

  • Hello sir,

    Thanks for reaching out Renesas Engineering Community.

    First of all is not necessary to enable the underflow interrupt on the timers stack.

    The underflow event will occur even though you don't enable it as interrupt in the r_gpt0 and r_gpt1 stacks.

    Also from what I can understand that you are saying is that for Group A you get the adc results for the channels you configured for this group and you don't get any readings for the channels you configured for Group B.

    Is that correct?

    To be sure what might causes this in your setting I am sorry but we would like to see your whole project to have a better overview of what might be missing.

    However I created a very simple example which I think does what you want to do.

    I have configured ADC Unit 0 in my project as you will see.

    The Scan Mode is Group Scan:

    For  Group A in this application I get readings for ADC channel 0 , while in Group B I have enabled channel 1.

    I have also configured two timers as you did GPT0 so that it's underflow event will trigger ADC SCAN of Group A.

    And GPT1 is configured so that its underflow event will trigger ADC SCAN of Group B.

    To link the ADC SCAN start event with the underflow events of the GPT timers, it is necessary to use the ELC module.

    If you do not add it the FSP Configurator will pop up an error message indicating that r_elc stack should be added.

    As you can see as soon as the adc_event variable gets value ADC_EVENT_SCAN_COMPLETE:

    I get readings for channel 0, which is enabled in GroupA.

    And when adc_event gets ADC_EVENT_SCAN_COMPLETE_GROUP_B I get the readings for channel 1 which is enables for GroupB:

    I will attach the project for you. It is on EK-RA6M4 and FSP 5.5.0 version.

    RA6M4_adc_elc.zip

    Hope it helps.

    Best Regards,

    IK

  • thank you for constructing a RA6M4_adc_elc project for this problem.  Since I don't have any RA6M4 board, I test the differences between your settings and mine on my FPB_RA4E2 board.  What I find is if I enable Internal Reference Voltage in group B Scan MAsk, group B ADC does not start thus its end interrupt does not come.    Without Internal Reference Voltage selected in group B ADC channels, group B end interrupt comes OK. 

      

    IS this an expected behavior?  I don't want to ADC internal reference voltage in group A as it is a faster loop.  I wish I have a way to obtain the internal reference voltage in group B ADC group scan.  Below scope picture shows a 1.82uS time for 3 channels ADC scan in group A.  

    it takes 4.06uS to ADC ch07 and temperature sensor in group B as below.   I believe the temperature sensor ADC time is much longer than ch07. 

  • there is a Note 2 on page 1555 of RA4E2 hardware manual saying temperature and internal voltage reference can't be used in group scan mode.   But then there are other places indicating that they can be used in group scan mode.  This is confusing.  Please clarify.

Reply Children
  • Hello sir,

    According to the table provided in the HW of RA4E2:

    In Group Mode both temperature sensor and internal reference voltage can be selected.

    The only limitation is that when Double Trigger Mode is enabled in group A only 1 ADC channel can be selected.

    The same also applies for RA6M4 where my example was made on.

    And after modifying my example:

    Group A is responsible for scanning channels 0,1,2 and Group B channel 7 , Temperature Sensor, Internal Reference Voltage.

    I can get scan results for all of them and both scan end interrupts for both groups occur:

    And for group B:

    To test the results I have connected in purpose:

    Pin P000 (AIN0) -->3.3V

    Pin P001 (AIN1) -->GND

    Pin P002(AIN2) -->3.3V

    Pin P007 (AIN7) --> GND

    and that explains the readings you see on the screenshots.

    Could you please share your project to check it in more detail and see all your settings?

    And also provide us the FSP version you are using?

    Best Regards,

    IK

  • Thx for looking into this.  I enable the internal voltage reference on ADC group B scanning.  interrupt of group B end does not come.  If I remove the internal voltage reference, the group B interrupt comes OK. Do you know how to upload my zip file for the project here?

  • Hello sir,

    I have checked your project and made some tests.

    From your settings I see that GPT0 timer has a period 100KHz (500 Raw Counts) which is 10us and it's underflow event is triggering GroupA. 

    And timer GPT1 has a period 10KHz which is 100us and it's underflow event is triggering GroupB.

    And from the settings in the adc stack:

    That means that GroupA can interrupt GroupB and GroupA has a higher priority.

    If for example Group B is converting while GroupA trigger happens, GroupA interrupts GroupB.

    And then the interrupted GroupB restarts.

    In your case the period you set for GPT0 is too small and  GroupB doesn't have enough time to do the scan and complete it. And thus you don't see the isr for scan complete for GroupB to occur.

    In case you want both Groups to be able to scan and complete their scan process than you should set the period to a bigger value than 10 us (500) raw counts.

    For example if I set the timers settings to:

    GPT0 period 100us

    And GPT1 to 1000us -->1 ms:

    I can see both interrupts getting fired, since both groups now have enough time to complete their scans.

    And the scan end interrupt for both of them occurs:

    Now in case it is a requirement of your system that these timers need to have these frequencies, you could change the scan triggers as it follows:

    And keep GPT0 frequency to 100KHz and GPT1 frequency to 10KHz.

    Because by this way might GroupB will be triggered more often than GroupA, however GroupA scan will be definitely completed since it is higher priority. Only GroupB can be interrupted by GroupA.

    Hope it helps.

    Best Regards,

    IK

  • Thx for spending time to help me understand this RA4E2 behavior.  In my application, group A needs to be higher priority than group B, including interrupt priority.  with 10uS on group A and 100uS on group B, group B is given 100uS to complete.  Below is a scope plot showing with only temperature sensor and without internal voltage reference in group B, group B has been interrupted twice by group A.   Ch1 and ch4 are group A interrupt timing and ch3 is group B interrupt time.  Entire group B interrupt time (included interrupted by group A) is 22uS.  

     

    I understand the internal voltage reference ADC time might take another 22uS.  Twice of 22uS is 44uS and should be plentiful within the 100uS time I allocate for group B.  I just don't understand why RA4E2 allows group B interrupted twice but not four times.