AnsweredAssumed Answered

AD Converter Initialization Bug with Kinetis?

Question asked by Laartoor on Jun 21, 2014
Latest reply on Jun 23, 2014 by Laartoor

I use PE together with a Kinetis K10. When I configure an ADC_LDD component to use analog input pins that need the analog mux to be set, that is SExb pins, and do not use a single SExa pin, Processor Expert (version bundled with CW 10.6) generates the following code:

  /* ADC0_CFG2: MUXSEL=1 */
  ADC0_CFG2 |= ADC_CFG2_MUXSEL_MASK;
  /* ADC0_CFG1: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,ADLPC=0,ADIV=3,ADLSMP=1,MODE=3,ADICLK=0 */
  ADC0_CFG1 = ADC_CFG1_ADIV(0x03) |
              ADC_CFG1_ADLSMP_MASK |
              ADC_CFG1_MODE(0x03) |
              ADC_CFG1_ADICLK(0x00);
  /* ADC0_CFG2: MUXSEL=0,ADACKEN=0,ADHSC=0,ADLSTS=3 */
  ADC0_CFG2 = (uint32_t)((ADC0_CFG2 & (uint32_t)~(uint32_t)(
               ADC_CFG2_MUXSEL_MASK |
               ADC_CFG2_ADACKEN_MASK |
               ADC_CFG2_ADHSC_MASK
              )) | (uint32_t)(
               ADC_CFG2_ADLSTS(0x03)
              ));

That is, it first sets the mux, and then resets it again. The code happily reads the SExa pin, I had to manually set the mux in my initialization function to get the code to reference the right input.

Outcomes