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] Need help on PIC18F4550 PORT declaration

Status
Not open for further replies.

Haphazard

Newbie level 3
Joined
Mar 24, 2012
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,297
Hi, I am a beginner in PIC programming and I found a problem while trying out my PIC18f4550, I am using MPLAB C18,
The PORTD7 and PORTC7 is unable to be placed on high, I would like to ask if there's anything wrong with my code initialization. I have simulated in MPLAB simulator (the output on the simulator appeared normal,but failed in hardware for D7 and C7) and also redeclared some of the SFRs that I fear might be causing this problem. The output in hardware for RC7 & RD7 is always 0V.

Code:
#include <p18f4550.h>
#include "delays.h"

#pragma config FOSC = HS	
#pragma	config FCMEN = OFF			
#pragma	config IESO = OFF		
#pragma	config PWRT = OFF			
#pragma	config BOR = OFF		
#pragma	config WDT = OFF			
#pragma	config MCLRE = ON		
#pragma	config PBADEN = OFF		
#pragma	config CCP2MX = ON		
#pragma	config LVP = OFF		
#pragma	config XINST = OFF		

void main()
{
SPPCON=0x00;
CCP1CON=0x00;
CCP2CON=0x00;
UCON=0x00;
UCFG=0x00;
TRISD = 0x00;
TRISC = 0x00;	
PORTD=0;
PORTC=0;

while(1)
{
PORTC=0X7F;
PORTD=0X7F;
}
}
Thanks in advance
 

Code:
    LATD=0;
    LATC=0;
    
    while(1)
    {
        LATC=0XFF;
        LATD=0XFF;
0xff, not 0x7f
Use LAT register for output, PORT register only for input
 

Thanks a lot for the help, I feel so dumb for making such a simple mistake
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top