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:
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
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.
yeah, I missed out the TRISB while pasting the code, but still, the results are the same. I'm not sure if I missed out anything else. It's just turning a pin on....
You set the config under the top menu; Project -> Edit_Project
then check the config boxes as desired.
You should have a good read through the PIC datasheet under "Special features of the CPU" chapter which described the effect of all the config options.
You set the config under the top menu; Project -> Edit_Project
then check the config boxes as desired.
You should have a good read through the PIC datasheet under "Special features of the CPU" chapter which described the effect of all the config options.
Hi guys,
Still no avail. I changed the Brown Out to "Disabled in Hardware, SBOREN Disabled". Anything else which needs to be changed?BTW, my crystal osc is 20 MHz, just to inform you guys.
Here's a screenshot: **broken link removed**
With a 20MHz crystal you need the prescaler set to 5 so the PLL gets 4MHz. The output will be 96MHz and so you need to divide it by something like 4 to get a usable 24MHz. So postscaler = 4. The oscillator type should be HSPLL (High speed - pll enabled).