Teensy 3.6 unwanted DAC output

Status
Not open for further replies.
I am amplifying the output signal from DAC pin A21 with an op amp to get to the 0-5V range instead of 0-3.3V. During startup of the Teensy I can measure a voltage after the op amp that increases up to about 4.8 V, which I really don't want to have. If I measure directly on the A21 pin, on the other hand, the voltage is 0 and also disappears from the op amp output.

This behavior seems to be independent of the specific code I upload to the Teensy. If I don't use the pin in the code at all, or if I declare it but write no value to it, the output voltage stays at 4.8V and doesn't disappear after the setup is done.
Is there anything I can do to make this go away? Preferably some piece of code that would make sure pin A21 is actively at output 0 as soon as the device has any power.

Opamp.png
 
First try adding a resistor between the signal and ground. 10K or 22K might be a good starting point.

About configuring the pin right at startup, look for "startup_early_hook" in mk20dx128.c. This code runs as soon as the chip boots, while it's still running from the internal RC oscillator (neither crystal is oscillating yet) and pretty much nothing has been initialized.
 
Awesome, thank you. Adding the resistor solved it. I'll still look into the startup_early_hook you mentioned, that sounds very useful for other things.
 
Status
Not open for further replies.
Back
Top