Teensy 4.0 ADC keeper issue

Status
Not open for further replies.

ossi

Well-known member
I used the program given below to read an analog voltage on pin 14/A0. I observed strange values and it took me some hours to learn that the keeper on this pin is enabled and leads to a current into/out of this pin changing the voltage on the pin. There was a keeper issue in the beta-thread but it it is unclear for me how this is handeled. I think activating the keeper is not a good idea since it makes the ADC-input "low ohmic" and may lead to strange results if the source has not a low inner resistance. Is there a specific reason to have the keeper enabled?
Code:
void setup() {
  Serial.begin(115200);  
  while(!Serial) ;
  Serial.println("start teensy40doADCtest1...") ;
  Serial.println("end setup...") ;  
  }

volatile int val ;

void loop() {
  val = analogRead(0) ;
  Serial.printf("ADC= %6d \n",val) ;
  delay(500) ;
  }
 
You're right, it should be disabled for pins which are used for analog (But should be enabled for the digital case(?) ) . Its clearly stated in the documentation, and we found this ssue during the beta-phase. Don't know why this got not fixed. I assumed, it was.
Can you fix that and do a pull request?
 
Last edited:
I'm not at my PC at the moment: Does pinMode(x, INPUT_DISABLE) disable the keeper?
 
Last edited:
I'm not at my PC at the moment: Does pinMode(x, INPUT_DISABLE) disable the keeper?

As I understand it, it should be enabled if the pin is an output and gets disabled, and be disabled otherwise.
See AN 5078.

Is this is correct?
I think it may be better to disable it completely for all pins. Wouldn't that be more compatible to T3.x?
 
In my case I should have used:
pinMode(PIN_A0, INPUT);
This disables the keeper. Nevertheless I think it would be good to disable keepers at startup.
 
It is sort of an interesting question.

Should the startup code run through all of the GPIO pins/pads and set them to a similar state as maybe T3.x? or should they be left at the Reset state?
In the case of: IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_02

The defaults include: PKE=1 PUE=0... So Keeper is on...

Again I wonder what is the right answer. That is analogRead could logically set to INPUT_DISABLE, but I maybe previously did something like INPUT_PULLUP or INPUT_PULLDOWN...
Which maybe works?
 
As I understand it from the AppNote, the Keeper still works with a disabled Pin. So a simple DISABLE does not help.

I think we can measure that.
Will do.
 
With the line:
Code:
IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_02 &= ~ (1<<12) ; // disable keeper
I could switch off the keeper at a0. The input current was so small that I couldn't measure it in this situation.
 
Confusion ;) you're right - I was speaking of pin disable.

oops, I've looked now at the code. ok INPUT_DISABLE disables the keeper.

I've added a 470k Voltage divider to a pin.

1) The pin has 0.6V default after power up - when we do nothing - which is questionable
2) It has 1.6V after pinMode(x, INPUT_DISABLE) - which is correct

The only way to fix this, is indeed a loop over alls pins which disables the keeper.
The Teensy 3. does not do that, so the T4 is not compatible in this regard, and it should be fixed.
 
I am working on a project for school. We plan to use the ADC to read analog audio signals (3 of them). How do I disable the keeper on these pins? I have searched the net and can't really find anything. Also, what is a keeper?
 
A keeper can be used to preserve the pin output-state when the pin driver is switched off. Further info can be obtained by the app-note:

https://www.google.com/url?sa=t&sou...FjAAegQIARAB&usg=AOvVaw2nPasH_5x-7bziVYCwG_ke

In order to disable the keeper you have to clear the pke bit of the corresponding pin. For the Teensy 4.0 pin 14=A0 it is
IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_02 &= ~ (1<<12) ; // disable keeper
AD_B1_02 is the internal name of the pin14=A0, bit 12 is the pke bit in the IOMUXC_SW_PAD_CTL_PAD_GPIO register (see datasheet).
 
Status
Not open for further replies.
Back
Top