Jump to content
Sign in to follow this  
FrankGe

Porta Output Doesn,t Work

Recommended Posts

Hello,

 

Language BOOSTC 1.8

PIC: 16F877A

OS: Win XP SP2

 

#pragma CLOCK_FREQ 20000000

#include <system.h>

#define PORTA 0x05

volatile bit led0@PORTA.0; // RA0

volatile bit led1@PORTA.1; // RA1

volatile bit led2@PORTA.2; // RA2

volatile bit led3@PORTA.3; // RA3

 

void main( void )

{

trisa = 11110000b; //PORTA = input/output

 

while(1)

{

delay_ms(250);

led0 = led1 = led2 = led3 = 1;

delay_ms(250);

led0 = led1 = led2 = led3 = 0;

}

}

 

Watch with the debugger to the LED block of PORTA

 

It doesn't work

 

Frank

Share this post


Link to post
Share on other sites

FrankGe,

 

Make sure you set the ADCON1 register, or the analog mode of the port will be overriding. This is the correct way to use this port.

 

ie

 

adcon1 = 0x0F; // turn off port A analog mode, set all pins to digitial

 

Regards

Dave

Share this post


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...
Sign in to follow this  

×
×
  • Create New...