Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

pic did not receive any input

Status
Not open for further replies.

r0b0t1c

Newbie level 4
Newbie level 4
Joined
Jan 28, 2013
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,330
hi. im using PIC16F877a to make a line following robot.
im programming using C language.
it run with no problem when i simulate it using Proteus.
the problem is, when i flash it into PIC, nothing happen.
the PIC is like not responding when there is input.

for example, when i give input '1' to PORTC RC0,
i want the PIC to send the output '1' to PORTB RB0, something like that.

here is my program

Code:
#include <htc.h>
int main(void) {
    TRISB = 0X00; //PortB as output
    TRISC = 0XFF; //PortC as input

    while(1)
    {

//stop
        if(PORTC == 0x00 || PORTC == 0x09 || PORTC == 0x0B || PORTC == 0x0D)
        { PORTB = 0x00;
        }
        
//straight
        if(PORTC == 0x60 || PORTC == 0xF0)
        { PORTB = 0x05;
        }
        
//right
        if(PORTC == 0x80 || PORTC == 0x40)
        { PORTB = 0x01;
        }
        
//left
        if(PORTC == 0x10 || PORTC == 0x20)
        { PORTB = 0x04;
        }
        
//sharp left
        if(PORTC == 0xC0 || PORTC == 0xA0 || PORTC == 0xE0)
        { PORTB = 0x9;
        }
        
//sharp right
        if(PORTC == 0x30 || PORTC == 0x70 || PORTC == 0x50)
        { PORTB = 0x6;
        }

    }
    return 0;
    }

do i need to include any header file or configuration?
 

Could be that you are inputting a code not tested for?

The return 0 doesn't do anything and the main could be a void function rather than an int.
 

so i just change to void main()?

im using logic state
sorry. forgot to attach the circuit
here it is cir.PNG
 

so i just change to void main()?
That and removing the return line.

Your circuit appears to be missing all the power supply decoupling, crystal, input and reset circuitry.
 
Last edited:

Also check you have programmed the configuration fuses. I'm not sure about Proteus but most simulators ignore fuse settigs when they run but a real processor must have them configured.

Brian.
 

First ensure that microcontroller is working or not. Just set any pin as High or low to get confirmation that CLK and reset are applied correctly to microcontroller. If it is working. Then you have you check whether PORTC by default is IO or not. If not check the register configuration in Datasheet.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top