'===============================================================================
' Project: LED Blink
' Target: PIC18F25Q10
' Compiler: Swordfish BASIC
' Author: Burt Ratliff & Gemini
' Description: This program blinks an LED connected to pin RB0 once per second.
'===============================================================================
' --- Device and Clock Configuration ---
' Tell the compiler which PIC microcontroller we are using.
Device = 18F25Q10
Clock=64
' Set the clock speed. The 18F25Q10 has a high-frequency internal oscillator.
' We'll use the default 64MHz, which Swordfish will automatically configure.
' For higher speeds, you would set it here, e.g., Clock = 32
Include "intosc.bas" ' Alternative: this library can auto-configure the internal oscillator (if available)
Include "system.bas" ' System library (provides NOP, Delay routines, etc.)
Include "Utils.bas" 'for SetAllDigital()
' --- Fuses / Configuration Words ---
' Swordfish handles many fuses automatically based on the 'Device' and 'Clock'
' commands. For a simple blink, we don't need to manually set them.
' For more complex projects, you would add 'Config' lines here to disable
' things like the Watchdog Timer (WDT). For example:
' Config WDT = False
' --- Pin Alias ---
' It's good practice to give a descriptive name to the pin you are using.
' Let's assume the LED is connected to Port B, pin 0.
Dim LED As PORTB.0
' --- Main Program ---
' Set the data direction for the LED pin to an output.
' In the TRIS register, 0 = Output and 1 = Input.
SetAllDigital() 'Sets All Digital
OSCCON1 = $60 'sets osc to 64
OSCFRQ = $08 'need this to if you wan't 64 mhz
ANSELB = $00 ' turns off adc
TRISB = $00 ' Set all PORTb pins as output for simplicity
LATB = $00 'Start with all pins low
' Ensure the LED starts in a known state (off).
Low(LED)
DelayMS(500) ' A brief pause before starting the loop.
' Start an infinite loop that will run forever.
While True
' Toggle the state of the LED pin (if it's on, turn it off; if off, turn on).
Toggle(LED)
' Wait for 500 milliseconds (half a second).
' The LED will be on for 500ms and off for 500ms, resulting in a 1-second blink.
DelayMS(500)
Wend