Dave
Always wear safety glasses while programming.
Thanks, I was not aware TOGGLE needs to read digital, so can not toggle while doing some ADC on higher ports of A.
ADCON1 = %00001111 ' Make AN0-AN12 digital
I'm betting if you had a resistor pulling the pin low, say a 10k, you'd see it going low. I'm not familiar with the 18f4620 but on a 12f683 it needs some kind of load to pull the pin low. Don't have to be alot but something.
Adding these 2 lines should allow you to drive the pin.
ADCON1=15 'Set all A/D pins digital
CMCON=7 'Turn off comparators
Shawn
If you look at section 19.5 of the datasheet for the 18F4620 you'll find this:So if you do a TOGGLE on a pin which has NOT be set to digital it will read '0', the bit will then flipped to '1' and written back to the port. Next time you do that TOGGLE it will again read the bit as '0' (even though it was previously set to '1'), flip that bit to '1' and write it to the port. Ie. it will never toggle it low because every time its told to toggle the bit it's read as low and gets toggled to high.When reading the Port register, all pins configured as analog input channels will read as cleared (a low level). Pins configured as digital inputs will convert as analog inputs. Analog levels on a digitally configured input will be accurately converted.
Page 224 in the same datasheet shows how to set ADCON1 up in order to configure the various pins as either analog or digital. And then there's the compartor as have been pointed out, see page 234. However for the 18F4620 the comparators are OFF by default so you strictly speaking you don't need to turn them off again. ALWAYS make a habit of checking IF you need to turn comparators off and/or enable digital mode on the pins you're using and HOW to do that - not all chips are the same.
/Henrik.
Yes, thanks all, Henrik is correct.
I can drive the pin low. I was losing confidence when TOGGLE did not blink. I just did not think about the need of TOGGLE to read the state of an analog pin to blink an LED.
The Olimex board came with LED hardwired to PORTA.0 I am doing ADC on 6 other A/E ports (replacing cadmium sulfide photoresistors with more durable phototransistors in eyes of solar dish trackers) (also replacing expensive pulse/I2C tilt accelerometers with cheaper analogs).
I can make the LED blink by adding 1 to a tracking bit and not use TOGGLE in this instance. I doubt the need for an LED on solar dish PC boards. PORTA.0 will be liberated. Thanks again -- Doug.
P.S. You can see progress -- Google -- matrix solar dish
Bookmarks