1 Reply Latest reply on Oct 24, 2018 4:54 PM by DheerajK_81

    Range comparision interrupt does not work with PDL

      Hello support team,

       

      I encountered that the range comparision interrupt of the ADC does not work when using PDL 1.2 or PDL 2.1.

      When configuring the range comparision interrupt and the interrupt should get active because the sampled ad value is in the specified range, then the AdcIrqHandler() function is called but it finds no reason for the call. As a consequence the interrupt handler is called again immediately briniging the system down.

      After having a closer look at the register definition in the header file mb9abxxx.h (PDL 1.2) or the mb9bf56xr.h (PDL 2.1) I saw a wrong register structure definition.

      Here is an extract of the header file mb9abxxx.h defining the structure FM4_ADC_TypeDef:

        union {

          __IO  uint16_t ADCEN;

          stc_adc_adcen_field_t ADCEN_f;

        };

              uint8_t  RESERVED12[2];

              uint32_t OFFESET;

        union {

          __IO uint8_t WCMRCOT;

      stc_adc_wcmrcot_field_t WCMRCOT_f;

        };

              uint8_t  RESERVED13[3];

        union {

          __IO uint8_t WCMRCIF;

      stc_adc_wcmrcif_field_t WCMRCIF_f;

        };

              uint8_t  RESERVED14[3];

        union {

          __IO uint8_t WCMPCR;

      stc_adc_wcmpcr_field_t WCMPCR_f;

        };

       

      The bold printed Registers WCMRCOT and WCMRCIF (with their flag elements) are in the wrong order.

      They have to be changed like it is written in the data sheet 002-04856_FM4_Famliy_Pripheral_Manual_Main_Part_TRM.pdf:

       

      Be careful: The IAR workbench has the same mistake. If you have a look at the Special function registers of the ADC group then the rwegisters appear in the wrong order as well.

      This can be fixed by editing the file MB9B560R.xml. Herein the register Offset values have to be changed:

              <!-- REGISTER "WCMRCIF" -->

              <register>

                <name>WCMRCIF</name>

                <description>Range Comparison Flag Register</description>

                <addressOffset>0x44</addressOffset>

                <size>8</size>

                <access>read-write</access>

                <resetValue>0x00</resetValue>

                <resetMask>0x01</resetMask>

                <!-- FIELDS -->

                <fields>

                  <!-- FIELD "RCINT" -->

                  <field>

                    <name>RCINT</name>

                    <description>Range comparison interrupt factor flag</description>

                    <lsb>0</lsb>

                    <msb>0</msb>

                    <access>read-write</access>

                  </field>

                </fields>

              </register>

              <!-- REGISTER "WCMRCOT" -->

              <register>

                <name>WCMRCOT</name>

                <description>Range Comparison Threshold Excess Flag Register</description>

                <addressOffset>0x48</addressOffset>

                <size>8</size>

                <access>read-write</access>

                <resetValue>0x00</resetValue>

                <resetMask>0x01</resetMask>

                <!-- FIELDS -->

                <fields>

                  <!-- FIELD "RCOOF" -->

                  <field>

                    <name>RCOOF</name>

                    <description>Threshold excess flag bit</description>

                    <lsb>0</lsb>

                    <msb>0</msb>

                    <access>read-write</access>

                  </field>

                </fields>

              </register>

       

      Please confirm.

        • 1. Re: Range comparision interrupt does not work with PDL
          DheerajK_81

          As an additional check please do the following:

           

          Use the function Adc_GetIrqFlag(<your_adc_instance>, AdcRangeComparisonIrq) which returns a boolean stating if the range comparison result matches the condition set in the Adc_Init().

           

          But as you mentioned, the structure and the TRM are different and the positions of WCMRCOT and WCMRCIF appear in the wrong order inside the structure. This needs to be fixed.

           

          As a workaround I think you could edit the MB9B560R.xml and check if it works though I haven't tried. Will need to check. Will let you know.

           

          Do let me know if you have any observations.

           

          Regards,

          Dheeraj