Last active
May 15, 2026 10:59
-
-
Save azolotko/a979109a5252343c1b8e39e4d3cd8af0 to your computer and use it in GitHub Desktop.
PIC16 blinky demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- --------------------------------------------------------------------------- | |
| -- Blinky demo | |
| -- --------------------------------------------------------------------------- | |
| open asm in | |
| def blinky : Asm := do | |
| let cnt0 : FileRegAddr := 0x20#7 | |
| let cnt1 : FileRegAddr := 0x21#7 | |
| let outPin : BitAddr := 0x0#3 | |
| let delay : Asm := | |
| movlw 0xFF#8 ++ | |
| movwf cnt0 ++ | |
| scope λ outer => | |
| movlw 0xFF#8 ++ | |
| movwf cnt1 ++ | |
| scope λ inner => | |
| decfsz cnt1 Dest.f ++ | |
| inner.entry.jump | |
| ++ | |
| decfsz cnt0 Dest.f ++ | |
| outer.entry.jump | |
| bank1 ++ | |
| call 0x3FF#11 ++ | |
| movwf SFR.Bank1.OSCCAL.addr ++ | |
| movlw 0x00#8 ++ | |
| movwf SFR.Bank1.ANSEL.addr ++ | |
| movlw 0b00111110#8 ++ | |
| movwf SFR.Bank1.TRISA.addr ++ | |
| bank0 ++ | |
| scope λ main => | |
| bsf SFR.Bank0.PORTA.addr outPin ++ | |
| delay ++ | |
| bcf SFR.Bank0.PORTA.addr outPin ++ | |
| delay ++ | |
| main.entry.jump |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment