bonxer
New Member
I just learned something today about Port E on a 16F877 and thought I would pass it on.
I was working on a project that output data patterns on Port C for LED control. When I push a button connected to a Port E input, it causes them to change. After making a pretty big program, I decided to double the LED output by using Port D also. Everything worked fine except for one problem. Whenever I'm holding the button down, all of the Port D LEDs turn off. When I release, they're back on. I check all the wiring and decide it's not a hardware problem.
To make a long story short I made a copy of my code and spent a few hours removing things until I got down to a bare skeleton that only made the LEDs stay on. No port E button code of any kind. Despite all my efforts, that button press still taunted me making the LEDs go off. :shock:
So I read up on Port E. Turns out that if you have a 1 in bit 4 of Tris E, it puts it into parallel slave port mode, and E's pins are used for control lines, hence screwing my Port D data. I was initializing Port E as inputs by just putting 0xFF into my TRISE. Should be 0x07 to only specify the three lines.
Just a heads up for anyone not intimately familiar with the datasheets.

I was working on a project that output data patterns on Port C for LED control. When I push a button connected to a Port E input, it causes them to change. After making a pretty big program, I decided to double the LED output by using Port D also. Everything worked fine except for one problem. Whenever I'm holding the button down, all of the Port D LEDs turn off. When I release, they're back on. I check all the wiring and decide it's not a hardware problem.
To make a long story short I made a copy of my code and spent a few hours removing things until I got down to a bare skeleton that only made the LEDs stay on. No port E button code of any kind. Despite all my efforts, that button press still taunted me making the LEDs go off. :shock:
So I read up on Port E. Turns out that if you have a 1 in bit 4 of Tris E, it puts it into parallel slave port mode, and E's pins are used for control lines, hence screwing my Port D data. I was initializing Port E as inputs by just putting 0xFF into my TRISE. Should be 0x07 to only specify the three lines.
Just a heads up for anyone not intimately familiar with the datasheets.