Jump to content

Simulator Error On Pic16f877


Recommended Posts

I wrote this program for PIC16F877

 

 

void main(void)

{

trisa = 0xff;

trisb = 0;

 

while(1)

{

if ((porta & 010b) == 010b)

{

portb = 0xff;

}

else

{

portb = 0;

}

};

}

 

Under simulator I assigned button to porta Pin 1 and LED block to portb and result was - portb doesn't set at all when I push button.

 

This code works for PIC16F84.

Link to post
Share on other sites

messcalitto,

 

This is one of the classic mistakes ;)

 

The PIC16F877 also uses PORTA pins for analog inputs.

The default port mode is analog input.

Just changing the tris register for PORTA doesn't turn off the analog mode.

 

Please the data sheet, you need to also change ADCON registers to turn off the analog mode.

 

Regards

Dave

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...