PIC16F876A - PortC 3, 4, 5 are not outputing

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
Raslan
Posts: 758
Joined: 02 Jul 2006 12:31
Location: Syria & Finland
Contact:

PIC16F876A - PortC 3, 4, 5 are not outputing

#1 Post by Raslan » 21 Aug 2018 08:56

Good Morning
MCU: PIC16F876A
HW : EasyPic4

Problem: PortC pin 3 ,4 and 5 can not output anything

Test Code:

Code: Select all

main:
     TrisB = 0x00   ' Set port B to digital input
     TrisC = 0xFF   ' Set Port C to digital output
     While True
                   PortB = PortC  ' Copy the status of portC to portB
     Wend
What is the problem?
I have tested the code over three MCUs... are my MCUs having problem?
in the datasheet never found any relevant information regarding this issue

Thank you for your kind help
Best Regards
Razi
I am learning in this forum a lot from the others' problems and experinces...
"Give me a fish, I eat for a day. Teach me how to fish, I eat for a life time."

paulfjujo
Posts: 1558
Joined: 24 Jun 2007 19:27
Location: 01800 St Maurice de Gourdans France
Contact:

Re: PIC16F876A - PortC 3, 4, 5 are not outputing

#2 Post by paulfjujo » 21 Aug 2018 19:53

hello



do you want to display the reading of port C ?
what about comparator ?

Raslan
Posts: 758
Joined: 02 Jul 2006 12:31
Location: Syria & Finland
Contact:

Re: PIC16F876A - PortC 3, 4, 5 are not outputing

#3 Post by Raslan » 21 Aug 2018 21:41

paulfjujo wrote:hello

do you want to display the reading of port C ?
what about comparator ?
I would like to make it simple like this
if I write this code

Code: Select all

PortC = 0xFF
then it is expected that all port C have digital High (+5V). However, the actual result is:
PortC.0 is High
PortC.1 is High
PortC.2 is High
PortC.3 is no change (LOW)
PortC.4 is no change (LOW)
PortC.5 is no change (LOW)
PortC.6 is High
PortC.7 is High
I am learning in this forum a lot from the others' problems and experinces...
"Give me a fish, I eat for a day. Teach me how to fish, I eat for a life time."

Sparky1039
Posts: 1179
Joined: 24 Nov 2005 20:07
Location: Colorado, USA

Re: PIC16F876A - PortC 3, 4, 5 are not outputing

#4 Post by Sparky1039 » 21 Aug 2018 22:55

Problem: PortC pin 3 ,4 and 5 can not output anything
This is because you configured all pins of PortC as inputs.

Code: Select all

TrisC = 0xFF   ' Set Port C to digital output

Raslan
Posts: 758
Joined: 02 Jul 2006 12:31
Location: Syria & Finland
Contact:

Re: PIC16F876A - PortC 3, 4, 5 are not outputing

#5 Post by Raslan » 22 Aug 2018 16:38

Sparky1039 wrote:
Problem: PortC pin 3 ,4 and 5 can not output anything
This is because you configured all pins of PortC as inputs.

Code: Select all

TrisC = 0xFF   ' Set Port C to digital output
I wish it was easy as the above... but actually I did a mistake when I was writing my question... but in reality I did

Code: Select all

TrisC = 0x00
so the problem is not solved yet... :roll:
I am learning in this forum a lot from the others' problems and experinces...
"Give me a fish, I eat for a day. Teach me how to fish, I eat for a life time."

Sparky1039
Posts: 1179
Joined: 24 Nov 2005 20:07
Location: Colorado, USA

Re: PIC16F876A - PortC 3, 4, 5 are not outputing

#6 Post by Sparky1039 » 22 Aug 2018 17:18

Forum members can't provide you good advice if you don't supply correct or complete information. Proof read your post before submitting next time.

Last thing to check is, make sure the MSSP module (I2C/SPI) is disabled if you are not planning to use it.
SSPCON1.SSPEN = 0; // <bit 5> disable MSSP module

Outside of the TRISC register configured as outputs and the MSSP module disabled, there is nothing else to prevent the ports from working correctly as an output (except a damaged part). Have you tried something simple like blinking an LED on these ports and see if that works?

Post Reply

Return to “mikroC PRO for PIC General”