# [SOLVED]Need help on PIC18F4550 PORT declaration

Status
Not open for further replies.

#### Haphazard

##### Newbie level 3
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 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;
}
}

Code:
    LATD=0;
LATC=0;

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

#### Haphazard

##### Newbie level 3
Thanks a lot for the help, I feel so dumb for making such a simple mistake

Status
Not open for further replies.

Replies
2
Views
1K
Replies
2
Views
882
Replies
2
Views
961
Replies
11
Views
2K
Replies
0
Views
1K