Code:
'****************************************************************
'* Name : ioc-demo-12f675.BAS *
'* Author : richard *
'* Notice : Copyright (c) 2023 caveat emptor *
'* : All Rights Reserved *
'* Date : 22/04/2023 *
'* Version : 1.0 *
'* Notes : 12f675 ioc gpio.0 *
'* : *
'****************************************************************
#CONFIG
cfg = _INTRC_OSC_NOCLKOUT
cfg&= _WDT_ON
cfg&= _PWRTE_OFF
cfg&= _MCLRE_ON
cfg&= _BODEN_ON
cfg&= _CP_OFF
cfg&= _CPD_OFF
__CONFIG cfg
#ENDCONFIG
DEFINE INTHAND poll
wsave VAR BYTE $20 SYSTEM
ssave VAR BYTE BANK0 SYSTEM
mode var byte
DUMMY VAR BYTE
INPT VAR GPIO.0
LED VAR GPIO.1
cmcon = 7
ANSEL = 0
TRISIO.0 = 1
TRISIO.1 = 0
IOC.0 = 1
MODE = 3
DUMMY = GPIO
INTCON = 001000
LED = 1
MAIN:
IF ! MODE THEN
LED = 0
pause 1000
LED = 1
mode = 3
DUMMY = GPIO
INTCON = 001000
endif
PAUSE 10
GOTO MAIN
asm
poll
MOVWF wsave
SWAPF STATUS,W
BCF STATUS,RP0
MOVWF ssave
BANKSEL _mode
clrf _mode
SWAPF ssave,W
MOVWF STATUS
SWAPF wsave,F
SWAPF wsave,W
ENDASM
Bookmarks