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.

[SOLVED] Why does the PORTA doesn't work in PIC16F877A?

Status
Not open for further replies.

skyassasin16

Junior Member level 2
Joined
Jan 10, 2011
Messages
24
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,453
All i want is to make them all normal inputs since I am running out of pins in my project, I tried to make the value of TRISA as 0xff but when i input a switch, it seems that it doesn't read any. What exactly is PORTA and how it is used?
 

Hi skyassasin16,

Can you check followings;
ADCON1 is configured properly for Digital or Analog inputs of portA (I guess you need digital ?)
When configuring ADCON1, TRISA and reading PORTA relevant RAM banks are selected.

Also note portA is 6bit and all the pins are multiplexed with some other functions. Hence careful to select pins for input purpose only.

Thank you,
 
Hi,

I guess you use Mplab-assembly.
If you need all portA pins to be digital, 0x06 should be assigned to ADCON1,

Also you should select RAM bank of ADCON1, immediately before assigning this value by "BANKSEL ADCON1" command.

Also you may use "BANKSEL TRISA" to select RAM-bank of TRISA.

Thanks,
 
By reading the datasheet page 41 onwards, section 4.0 I/O ports, there is an example to configure PORTA (example 4-1, initializing PORTA) though it is an assembly but it gives you an idea how to do it in C as well.
 
So, okay, but what if I were to use a microswitch in RA0,. and a toggleswitches to the rest,. what would be the value of ADCON1??
 

You can find all configuration details of ADCON1 on section 11.0 of datasheet-PIC16F877A.

"use a microswitch in RA0,. and a toggleswitches to the rest," means all portA pins have digital-inputs (all are switches). Hence set ADCON1 to 0x06.

Hope this helps you,
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top