Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Teensy 4.0 wrong register in cores analog.c ?

  1. #1
    Senior Member
    Join Date
    Feb 2019
    Posts
    123

    Teensy 4.0 wrong register in cores analog.c ?

    In the Teensy 4.0 cores file analog.c is the following line:
    ADC1_CFG = mode | ADC_HC_AIEN | ADC_CFG_ADHSC;
    As far as I understand the register ADC1_CFG gets initialized here. But the bit ADC_HC_AIEN does not belong to register ADC1_CFG but to "Control register for hardware triggers (ADCx_HC0)" as far as I understand the datasheet. Or do I understand it wrongly?

  2. #2
    Senior Member
    Join Date
    Feb 2015
    Location
    Finland
    Posts
    189
    For what it is worth, I agree. @PaulStoffregen, there is definitely something odd here.

    In cores/teensy4/analog.c:analog_init(), the ADC1_CFG = mode | ADC_HC_AIEN | ADC_CFG_ADHSC; line is equivalent to ADC1_CFG = mode | ADC_CFG_ADLPC | ADC_CFG_ADHSC; , always forcing low-power mode. I suppose it should be ADC1_CFG = mode | ADC_CFG_OVWREN | ADC_CFG_ADHSC; instead, so that the next converted sample overwrites the existing value in the data result register?

  3. #3
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,914
    Yes looks wrong! It has been this way since the file was original added at the start of T4...

    @Paul - not sure of the right Fix. That is was the code originally setup by BIT value and was translated to a symbolic name for it...
    In which case probably should be: ADC1_CFG = mode | ADC_CFG_ADLPC | ADC_CFG_ADHSC;

    That is, is it intentional to set the ADC in low power conversion mode (ADLPC)

    Note: likewise for ADC2 a couple of lines down.

  4. #4
    Senior Member
    Join Date
    Feb 2019
    Posts
    123
    If low-power mode is enabled it should be checked whether this is compatible with high-speed mode.

  5. #5
    Senior Member
    Join Date
    Feb 2019
    Posts
    123
    I have checked the option bits for the ADC. The Teensy 4.0 seems to enable "Low Power Mode" if nothing special is done.

  6. #6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •