Avery Zycherman

HC908JK8CPE: Severe EMI or incorrect ADC code?

Discussion created by Avery Zycherman on Mar 13, 2007
Latest reply on Mar 15, 2007 by bigmac
Hey Guys,
I have a circuit which used to work flawlessly but I started messing around with it and now I am having a problem with what I think is severe EMI. I am using a standard breadboard (the really good pale yellow kind with V/G rails along both sides) and trying to do ADC conversions on two pins about every 500ms. If i use a pulldown resistor on both pins, I get 0 and 0 as the values (correct operation) but as soon as voltage starts getting applied to one of them, the other one goes crazy as well!
My code is as follows:
1) The program recieves an SCI Recieve interupt and get a 'S' char... it then executes:
START_ADC_CONVERSION(0x06); //Start conversion on PTB2
START_ADC_CONVERSION(0x07); //Start conversion on PTB3
char GetADCValue(void) {
while(!ADSCR_COCO) {} //Wait until data is ready
return ADR; //return the value
2) The program then sends these values back in a 4-byte packet, as follows:
//Now transmit a packet containing all the sensor data
TransmitChar('S'); //Indicate that this is a sensor detail packet
TransmitChar(END_CHAR); //Indicate end of packet transmission
With both items grounded, this is the (as expected) output:
83 0 0 69 (S 0 0 E)
83 0 0 69 (continues forever...)
With voltage (literally directly from V) applied to only ONE of the pins, this is the crazy output over a few seconds:

83 255 0 69 (seems about right, but on the wrong pin) (500ms)

83 255 255 69 (where did the 255 on the second input come from?) (1000ms)

83 0 255 69 (now it switched!?) (1500ms)

83 0 255 69 (still switched...) (2000ms)

83 0 71 69 (71, WHAT THE HECK!) (2500ms)

It goes on like that forever, just throwing crazy numbers everywhere. Has anyone seen anythign like this before? Am I the victim of EMI here or is somethign else going on? I swear this same circuit used to work just fine...


Alban edit: Added part number in subject line according to msgid=5172

Message Edited by Alban on 2007-03-13 10:35 PM