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.

PIC 18F4550 PORTB I/O Problem

Status
Not open for further replies.

bhaskarc91

Newbie level 1
Joined
Oct 10, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,287
Hello.
I am using a PIC18F4550 and Hi-Tech C to write a simple LED blinking program on all PORTB pins. However, there is neither a high nor a low on any of the pins.
Here is my code:
Code:
#include<htc.h>
#include<pic18f4550.h>

#define _XTAL_FREQ 20000000

__CONFIG(1,PLLDIV_1 & CPUDIV_OSC1_PLL2 & USBDIV_1 & FOSC_HS);
__CONFIG(2,PWRT_ON & BOR_OFF & WDT_OFF);
__CONFIG(3,MCLRE_ON & PBADEN_OFF);


void main() {
    TRISB = 0x00;

    while (1) {
        PORTB = 0xff;
    }
}
Please help.
 

Please refer to the datasheet. There are other registers that may need to be set.

---------- Post added at 11:20 ---------- Previous post was at 11:14 ----------

Hello.
I am using a PIC18F4550 and Hi-Tech C to write a simple LED blinking program on all PORTB pins. However, there is neither a high nor a low on any of the pins.
Here is my code:
Code:
#include<htc.h>
#include<pic18f4550.h>

#define _XTAL_FREQ 20000000

__CONFIG(1,PLLDIV_1 & CPUDIV_OSC1_PLL2 & USBDIV_1 & FOSC_HS);
__CONFIG(2,PWRT_ON & BOR_OFF & WDT_OFF);
__CONFIG(3,MCLRE_ON & PBADEN_OFF);


void main() {
    TRISB = 0x00;

    while (1) {
        PORTB = 0xff;
    }
}
Please help.

You are setting :

while (1) {
PORTB = 0xff;
}


how do you expect the PORTB to blink as its always set to 0xFF?

---------- Post added at 11:22 ---------- Previous post was at 11:20 ----------

You need to do something like this:


Code:
while(1){

PORTB = 0xFF;
DelayMs(10);
PORTB = 0x00;
}

and remember to include <delay.h> from the compiler folder
 

or even

while(1){

PORTB = 0xFF;
DelayMs(250);
PORTB = 0x00;
DelayMs(250);
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top