Just posting to either brag or kvetch that I *finally* got my PIC breadboard to work.

I've got a PIC16F630 connected to a 8x2 line LCD, and a I2C interface talking to a 32K byte EEPROM, a real time clock, and some pushbuttons. I put the mess together to form a platform for other experiments, hoping to use a PIC Basic compiler to generate some simple fast code.

Well... never could get the I2C to work right. Gave up on the Basic compiler and went right to basics in MPLAB. I could see on my 'scope the write and read to the EEPROM was working (same data out as in), but the data IN was always 0-0-0-0-0-0-0-0.


I couldn't tell you why, actually seems like a bug in the PIC, but I never could get Port A.0 to do a READ. Write OK, no read. So I switched some pins around so A.0 would always be an output to the LCD.... and it worked!

Mind you, that little bit of inspiration took about 3 months.

Gee, maybe I'll build myself a nice clock when I'm done. ;-)
Posted on 2004-07-29 16:26:45 by Ernie
Hi Ernie,

... actually seems like a bug in the PIC...

After reset, by default the CMCON register's CM2:CM0 bits are set to 0. This means that pins RA0 and RA1 are analogue inputs for the Comparator Module. The datasheet states the following: "CMCON (19h) register must be initialized to configure an analog channel as a digital input. Pins configured as analog inputs will read '0'."

I think this is the source of your problem. Setting RA2:RA0 as outputs will overide the Comparator Module, and that's why the output worked and the input not. Try to set the CM2:CM0 bits to '111'. This will turn off the Comparator Module and will set RA2:RA0 as normal digital I/O pins. After than set TRISA for inputs. You may even turn on the weak pull-up resistors for the input pins.

Posted on 2004-07-30 15:59:12 by bszente
It uses PIC16F84. The display is Vitronics VI-422-DP and LCD driver is Microchip AY0438.
Posted on 2004-07-30 21:58:50 by mrgone
Try to set the CM2:CM0 bits to '111'. This will turn off the Comparator Module and
will set RA2:RA0 as normal digital I/O pins.

Been there done that. Just could not get A.0 to READ anything.

I even tried running some simple test code (read PortA.0, write to PortC.4, loop). It sim'ed perfectly in MPLAB, didn't work at all in real hardware.

A.0 always read as a zero, same symptom as CMCON = 0x00, but I'd set that. I even tried 0x00 thru 0x07 in CMCON in case the spec had a misprint. No go.

So its either a real bug in the silicon (something I've always been wrong about before), or just perhaps my chip had a damaged pin. I only used one device during this, but I've never seen a pin burn out as an input that still works as an output.
Posted on 2004-07-31 06:39:25 by Ernie
This software goes with the schematic above. It is software adjustable for fine tune accuracy.
Posted on 2004-08-05 13:22:49 by mrgone

This one
Posted on 2004-08-25 13:07:32 by mrgone