Vizier87
Active Member
Hi guys,
Sorry to ask such a simple question.
I'm using MikroC now (since I've been using Assembly for simple tasks) and couldn't get my PIC18F4455 to turn on an LED. I read the initialization on the PORTB part on the datasheet, which states:
Now here's my C code, trying to turn on all the PORTB pins,
Sometimes the PIC turned on well, but then it turns off again when I interrupt its supply i.e it doesn't seem to return to its original state. I suspect it might have to do with other configurations, but I suppose MikroC covers such details when I used the Project Wizard.
Any help would be highly appreciated.
Vizier87
Sorry to ask such a simple question.
I'm using MikroC now (since I've been using Assembly for simple tasks) and couldn't get my PIC18F4455 to turn on an LED. I read the initialization on the PORTB part on the datasheet, which states:
CLRF PORTB ; Initialize PORTB by
; clearing output
; data latches
CLRF LATB ; Alternate method
; to clear output
; data latches
MOVLW 0Eh ; Set RB<4:0> as
MOVWF ADCON1 ; digital I/O pins
; (required if config bit
; PBADEN is set)
MOVLW 0CFh ; Value used to
; initialize data
; direction
MOVWF TRISB ; Set RB<3:0> as inputs
; RB<5:4> as outputs
; RB<7:6> as inputs
Now here's my C code, trying to turn on all the PORTB pins,
C:
void main() {
PORTB=0X00;
LATB=0X00;
ADCON1=0X0F;
PORTB= 0b11111111;
while (1){
}
}
Sometimes the PIC turned on well, but then it turns off again when I interrupt its supply i.e it doesn't seem to return to its original state. I suspect it might have to do with other configurations, but I suppose MikroC covers such details when I used the Project Wizard.
Any help would be highly appreciated.
Vizier87
Last edited by a moderator: