kiewic
- 22nd April 2010, 19:42
Hi.
I'm trying to make a PIC 18F2550 blinks using pickit 2 and the internal oscillator. But it doesn't do it. Here is what I have tried.
1. I have the following code.
OSCCON = $70 'Int CLK 8MHz
OSCTUNE.6 = 1 'PLL 4x
ADCON1= %00001111 '$0F = disable A/D converter
TRISA = %00000000 'All pins are outputs
TRISB = %00000000
TRISC = %00000000
DEFINE OSC 32 '4x 8MHz
flip:
PORTC.0 = 1 'Turn on LED
PAUSE 500 'Delay for .5 seconds
PORTC.0 = 0 'Turn off LED
PAUSE 500
GOTO flip
END
2. This is my configuration on 18F2550.INC file.
LIST
LIST p = 18F2550, r = dec, w = -311, w = -230, f = inhx32
INCLUDE "P18F2550.INC" ; MPASM Header
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG3H, _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L & 0DFh
__CONFIG _CONFIG1H, _FOSC_INTOSCIO_EC_1H
__CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
NOLIST
3. I supposed the circuit is correct, because it runs with the following assambler code using MPLAB.
;_INTRC_OSC_NOCLKOUT
#include <p18F2550.inc>
cblock 0x20
Delay1 ; Define two file registers for the
Delay2 ; delay loop
endc
org 0
Start:
; bsf STATUS,RP0 ; select Register Page 1
bcf TRISC,0 ; make IO Pin B.0 an output
; bcf STATUS,RP0 ; back to Register Page 0
MainLoop:
bsf PORTC,0 ; turn on LED C0
OndelayLoop:
decfsz Delay1,f ; Waste time.
goto OndelayLoop ; The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions
decfsz Delay2,f ; The outer loop takes and additional 3 instructions per lap * 256 loops
goto OndelayLoop ; (768+3) * 256 = 197376 instructions / 1M instructions per second = 0.197 sec.
; call it a two-tenths of a second.
bcf PORTC,0 ; Turn off LED C0
OffDelayLoop:
decfsz Delay1,f ; same delay as above
goto OffDelayLoop
decfsz Delay2,f
goto OffDelayLoop
goto MainLoop ; Do it again...
end
Can you help me? Thanks.
I'm trying to make a PIC 18F2550 blinks using pickit 2 and the internal oscillator. But it doesn't do it. Here is what I have tried.
1. I have the following code.
OSCCON = $70 'Int CLK 8MHz
OSCTUNE.6 = 1 'PLL 4x
ADCON1= %00001111 '$0F = disable A/D converter
TRISA = %00000000 'All pins are outputs
TRISB = %00000000
TRISC = %00000000
DEFINE OSC 32 '4x 8MHz
flip:
PORTC.0 = 1 'Turn on LED
PAUSE 500 'Delay for .5 seconds
PORTC.0 = 0 'Turn off LED
PAUSE 500
GOTO flip
END
2. This is my configuration on 18F2550.INC file.
LIST
LIST p = 18F2550, r = dec, w = -311, w = -230, f = inhx32
INCLUDE "P18F2550.INC" ; MPASM Header
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG3H, _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L & 0DFh
__CONFIG _CONFIG1H, _FOSC_INTOSCIO_EC_1H
__CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
NOLIST
3. I supposed the circuit is correct, because it runs with the following assambler code using MPLAB.
;_INTRC_OSC_NOCLKOUT
#include <p18F2550.inc>
cblock 0x20
Delay1 ; Define two file registers for the
Delay2 ; delay loop
endc
org 0
Start:
; bsf STATUS,RP0 ; select Register Page 1
bcf TRISC,0 ; make IO Pin B.0 an output
; bcf STATUS,RP0 ; back to Register Page 0
MainLoop:
bsf PORTC,0 ; turn on LED C0
OndelayLoop:
decfsz Delay1,f ; Waste time.
goto OndelayLoop ; The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions
decfsz Delay2,f ; The outer loop takes and additional 3 instructions per lap * 256 loops
goto OndelayLoop ; (768+3) * 256 = 197376 instructions / 1M instructions per second = 0.197 sec.
; call it a two-tenths of a second.
bcf PORTC,0 ; Turn off LED C0
OffDelayLoop:
decfsz Delay1,f ; same delay as above
goto OffDelayLoop
decfsz Delay2,f
goto OffDelayLoop
goto MainLoop ; Do it again...
end
Can you help me? Thanks.