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.

Configuring port A as digital input for pic16f877a in MikroC

Status
Not open for further replies.

MahmoudHassan

Full Member level 6
Joined
Oct 4, 2010
Messages
349
Helped
44
Reputation
90
Reaction score
40
Trophy points
1,328
Activity points
3,913
Hello
i wanted to configure port A to be digital but i have problem with that simply it
doesnot worked

iam using MikroC
PIC16F877a
attached protues file for the problem
i tried to configure it like that

first iteration
ADCON1 = 0x0F; // All AtoD pins on PORTA to digital
CMCON = 0x07; // Disable Comparators
ADCON1 = 0x0F; // Make PORTA all inputs for switches


Second iteration

ADCON1 = 1; // Set inputs as analog, Ref=+5V
TRISA = 0x00; // Set PORT A as inputs

Third iteration

PORTA = 0;
ADCON1 = 0x06;
TRISA = 0xCF;


Fourth Iteration

ADCON1=6;
TRISA=1;



so anybody recommend me other iterations :lol:

Thanks

(iam newbie)

any help appreciated
 

Attachments

  • untitled.bmp
    2.1 MB · Views: 134

you can just call the function in mikroC? haha
 

hi
in mikroC too you have to configure the ports as inputs and outputs.there's no function in microC which automatically make ports. if you want to make inputs, write 1 to the pins which is to be used as an inputs
disable ADC and Comparators.it's clearly mentioned in microchip data sheet. i think the system is not working because you did not configure the controller parameters like MCLR in proteus and the compiler.

ml
 
I don't know what is MCLR ?
any information about it ?
 

Thanks a lot finally it works (i don't know how but it did ! :lol:)

But what about MCLR usage ? what is it ?
 

MahmoudHassan
can you tell me how did it work plz
 

ADCON1=0b00000110;
TRISA=255;// configure port A as input
but take care it is for pic16f877a in MikroC
 

Thanks a lot finally it works (i don't know how but it did ! :lol:)

But what about MCLR usage ? what is it ?

The MCLR has two functions:

1. a MCU reset pin (Master Clear)

2. Vpp a high voltage (9-13v) for programming the device's Flash and EEPROM

Many of the PICs allow the MCLR feature to be disable so that the pin can act as a normal I/O pin.

MCLR Pin function with ICD3

In-circuit Serial Programming (ICSP)

Hope the info clears up the question concerning the MCLR.

BigDog
 
in second iteration

U write :
ADCON1 = 1; // Set inputs as analog, Ref=+5V
TRISA = 0x00; // Set PORT A as inputs

if U want port A as input you must config it like that TRISA = 0xff;

and this what happened with you when you write TRISA = 255; because ff == 255

this my vision
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top