
Originally Posted by
AndyFreestone
... I also have ... loads of 18F45K22's
This is for PBP 2.60c, so only the syntax for CONFIG changes.
Code:
' PicBasic Pro program to blink all the LEDs connected to PORTD
' PIC 18F44K22 int osc
' PBP v2.60c MCS+ v2.1.0.7 U2 programmer v4.32
' MPASM v5.49 MCS v4.0.0.0
' Define LOADER_USED to allow use of the boot loader.
' This will not affect normal program operation.
asm
__CONFIG _CONFIG1H, _FOSC_INTIO67_1H & _PLLCFG_ON_1H & _PRICLKEN_ON_1H & _FCMEN_ON_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRTEN_ON_2L & _BOREN_SBORDIS_2L & _BORV_285_2L
__CONFIG _CONFIG2H, _WDTEN_OFF_2H
__CONFIG _CONFIG3H, _CCP2MX_PORTC1_3H & _PBADEN_OFF_3H & _CCP3MX_PORTE0_3H & _HFOFST_OFF_3H & _T3CMX_PORTB5_3H & _P2BMX_PORTC0_3H & _MCLRE_EXTMCLR_3H
__CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
endasm
OSCCON = %01111100
OSCCON2 = %10000100
OSCTUNE = %11000000
ANSELA = %00000000 ' Set port to digital
ANSELB = %00000000
ANSELC = %00000000
ANSELD = %00000000
ANSELE = %00000000
ADCON0 = %00000000 ' Disable ADC
TRISD = %00000000 ' Set PORTD to all output
' Define LOADER_USED 1
DEFINE OSC 64
i var byte ' Define loop variable
LEDS var PORTD ' Alias PORTD to LEDS
LEDS = %00000001 ' First LED on
mainloop:
For i = 1 to 7 ' Go through For..Next loop 7 times
Pause 1000 ' Delay for 1 seconds
LEDS = LEDS << 1 ' Shift on LED one to left
Next i
For i = 1 to 7 ' Go through For..Next loop 7 times
Pause 1000 ' Delay for 1 seconds
LEDS = LEDS >> 1 ' Shift on LED one to right
Next i
Goto mainloop ' Go back to loop and blink LED forever
End
Robert
EDIT: It's for a 18F44K22, but it is the smaller brother of the 18F45K22; same pinouts. I'm looking at it working right now, so it's good to go.
Bookmarks