View previous topic :: View next topic |
Author |
Message |
nilsener
Joined: 06 Dec 2005 Posts: 59
|
16F913 / 16F916, Problem with PORT C |
Posted: Tue Dec 06, 2005 1:05 pm |
|
|
Dear,
PCWH 3.236
MPLAB 7.22
PIC 16F916
If I set the Port C as an output using
Code: |
fast_io(c);
set_tris_c(0);
|
the pins RC3-7 are already acting as an output but the pins RC0-2 are still acting as an input. The pin RC0-2 can alternatively used to drive an LCD device and so I thinks that this may be the problem. What can I do to get the port c completely as an output?
Thanks for helping
Best Regards
nilsener |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Dec 06, 2005 1:23 pm |
|
|
If you look at the pin diagram in the 16F916 data sheet, you'll see that
those pins are shared with the VLCD module. Then if you look at the
LCDCON register description, you'll see that the VLCDEN bit is set = 1
(i.e., it's enabled) after reset. So those pins are not in digital i/o
mode after reset.
Then if you look at the CCS startup code in the .LST file, you'll see
that they don't turn that bit off. They don't change LCDCON at all.
So to turn off that bit, one quick way is to add the line shown in bold,
to your program, below:
Quote: | #use fast_io(c)
void main()
{
setup_lcd(LCD_DISABLED);
set_tris_c(0);
while(1);
} |
|
|
|
Guest
|
|
Posted: Wed Dec 07, 2005 2:47 am |
|
|
Thanks PCM programmer, it runs now!
Regards
nilsener |
|
|
|