Last active
January 11, 2020 20:24
-
-
Save 7marcus9/2ee167d4ec84aa91f6fbfb542c3c7d3a to your computer and use it in GitHub Desktop.
12F629
This file contains 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
;gpasm -p P12f629 test.asm | |
#include <p12f629.inc> | |
__CONFIG _MCLRE_ON & _CP_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT ;Internal osc. | |
cblock 0x20 | |
CNT_A | |
; CNT_B | |
SAVE_W | |
SAVE_STATUS | |
txByte | |
txBitsLeft | |
endc | |
ORG 0x000 | |
goto init | |
ORG 0x004 | |
goto isr | |
FtxByte | |
MOVWF txByte | |
MOVLW 8 | |
MOVWF txBitsLeft | |
BSF STATUS, RP0 ;Bank 1 | |
CLRF CNT_A | |
txWaitBeforeStart | |
BTFSS CNT_A, 0 ;Wait Till first (maybe unfinished Cycl) ends | |
GOTO txWaitBeforeStart | |
CLRF CNT_A | |
BCF TRISIO, 0 ;Pull IO LOW | |
txWaitStartBit | |
BTFSS CNT_A, 0 | |
GOTO txWaitStartBit | |
clkOutNextBit | |
BTFSC txByte, 0 ;Skip if Bit 0 = 0 | |
BSF TRISIO, 0 ;Let IO Float | |
BTFSS txByte, 0 ;Skip if Bit 0 = 1 | |
BCF TRISIO, 0 ;Pull IO Low | |
CLRF CNT_A | |
clkOutWaitNextBit | |
BTFSS CNT_A, 0 | |
GOTO clkOutWaitNextBit | |
RRF txByte, 1 | |
DECFSZ txBitsLeft, 1 | |
GOTO clkOutNextBit | |
BSF TRISIO, 0 ;Let IO Float | |
BCF STATUS, RP0 ;Bank 0 | |
CALL wait8 | |
RETURN | |
wait8 | |
BTFSS CNT_A, 4 | |
GOTO wait8 | |
RETURN | |
main | |
nop | |
SLEEP | |
CLRWDT | |
MOVLW 0xAA | |
CALL FtxByte | |
MOVLW 0x55 | |
CALL FtxByte | |
MOVLW 0x00 | |
CALL FtxByte | |
MOVLW 0xff | |
CALL FtxByte | |
GOTO main | |
init | |
BSF STATUS, RP0 ;Bank 1 | |
;BCF TRISIO, 0 ;GPIO= Output | |
BSF TRISIO, 0 ;Just for emulator | |
MOVLW b'00000001' ;Set TMR1IE = 1 | |
MOVWF PIE1 | |
BCF STATUS, RP0 ;Bank 0 | |
MOVLW b'11000000' ;Set GIE & PEIE = 1 | |
MOVWF INTCON | |
MOVLW b'11111110' | |
MOVWF TMR1H | |
MOVLW b'01100101' | |
MOVWF TMR1L | |
; MOVLW b'00000101' ;Start Timer1 | |
MOVLW b'00000111' ;Start Timer1 Ext Clock | |
MOVWF T1CON | |
goto main | |
isr | |
;SAVE VALUES | |
MOVWF SAVE_W ;Save W to Memory | |
SWAPF STATUS, 0 ;Swap Status Nibbles and store in W | |
MOVWF SAVE_STATUS ;Save Nibbleswappes Status in Memory | |
BCF STATUS, RP0 ;Bank 0 | |
BCF PIR1, TMR1IF ;Clear Timer1 Interrupt | |
BCF T1CON, 0 | |
MOVLW b'11111110' | |
MOVWF TMR1H | |
MOVLW b'01100101' | |
MOVWF TMR1L | |
BSF T1CON, 0 | |
INCF CNT_A, 1 | |
; BTFSC STATUS, Z | |
; INCF CNT_B, 1 | |
; BSF STATUS, RP0 ;Bank 1 | |
; BTFSC CNT_A, 1 ;Goto tx_Float if CNT_A & 0x02 | |
; GOTO tx_Float | |
; | |
; BTFSC CNT_A, 2 ;Goto tx_Float if CNT_A & 0x04 | |
; GOTO tx_Float | |
; | |
; BTFSC CNT_A, 3 ;Goto tx_Float if CNT_A & 0x08 | |
; GOTO tx_Float | |
; | |
; | |
; BTFSC CNT_A, 0 ;Goto tx_Low if CNT_A & 0x01 | |
; GOTO tx_Low | |
; | |
; GOTO tx_Float | |
;tx_Low | |
; BCF TRISIO, 0 | |
; GOTO end_txS | |
;tx_Float | |
; BSF TRISIO, 0 | |
; GOTO end_txS | |
;end_txS | |
; BCF STATUS, RP0 ;Bank 0 | |
;RESTORE VALUES | |
SWAPF SAVE_STATUS, 0 | |
MOVWF STATUS | |
SWAPF SAVE_W, 1 ;SWAP REGISTER CONTENTS | |
SWAPF SAVE_W, 0 ;READ BACK AND SWAP | |
RETFIE ;Return from interrupt | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment