Peter_wadley
New Member
Hey there,
I've just switched over to from 16F to 18F..
Having a bit of a problem though.
I'm doing the Hello World LED blink test but having problems.
I'm using the PICKIT2 to program.
I've been trying for hours to get an LED blink on Pin 0 of Port D with no luck.
When I program the µC to blink using mikroC it was fine.
But when I use the attached code in MPLAB it does not work..
I've tried selecting the bits from MPLAB rather then setting them in code...
You can even see the commented out section where I tried hardcoding the config bits to exactly what worked with MikroC....
I've tried everything it seems!! Anyone see anything wrong with the code?
Thanks!!
I've just switched over to from 16F to 18F..
Having a bit of a problem though.
I'm doing the Hello World LED blink test but having problems.
I'm using the PICKIT2 to program.
I've been trying for hours to get an LED blink on Pin 0 of Port D with no luck.
When I program the µC to blink using mikroC it was fine.
But when I use the attached code in MPLAB it does not work..
I've tried selecting the bits from MPLAB rather then setting them in code...
You can even see the commented out section where I tried hardcoding the config bits to exactly what worked with MikroC....
I've tried everything it seems!! Anyone see anything wrong with the code?
Thanks!!
Code:
LIST P=18F4620 ;directive to define processor
#include <P18F4620.INC> ;processor specific variable definitions
;******************************************************************************
;__CONFIG _CONFIG1H, 0xC2
;__CONFIG _CONFIG2H, 0x1E
;__CONFIG _CONFIG2L, 0x1F
;__CONFIG _CONFIG3H, 0x87
;__CONFIG _CONFIG4L, 0x81
;__CONFIG _CONFIG5H, 0xC0
;__CONFIG _CONFIG5L, 0x0F
;__CONFIG _CONFIG6H, 0xE0
;__CONFIG _CONFIG6L, 0x0F
;__CONFIG _CONFIG7H, 0x40
;__CONFIG _CONFIG7L, 0x0F
__CONFIG _CONFIG1H, _OSC_HS_1H
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
CBLOCK 0x080
d1
d2
d3
ENDC
ORG 0x0000
Main:
CLRF TRISD
CLRF PORTD
Start:
BSF PORTD,0
call delay
BCF PORTD,0
call delay
goto Start
delay
; Delay for 1 second using 20mhz clock
movlw 0x2D
movwf d1
movlw 0xE7
movwf d2
movlw 0x0B
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
nop
retlw 0x00
goto Main
END
Attachments
Last edited: