Hello Richard,
here is a complete code with config:
Code:
'* Notes : PIC16F690 *
'* : *
'****************************************************************
_INTRC_OSC_NOCLKOUT ; Using Internal Oscillator
_WDT_OFF; Edisable Watch Dog Timer
_MCLRE_OFF; disable MCLR
_CP_OFF ;Disable Code Protection
_CPD_OFF ; Disable Data Code Protection
_FCMEN_OFF ; Disable Fail Safe Clock Monitor
_IESO_OFF ; Disable Internal/External switchover
_BOR_ON ;Enable Brown out detect
_PWRTE_ON ; Enable Power up Timer
@MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON
@MyConfig = _MCLRE_OFF & _BOR_OFF
DEFINE OSC 8 ; tells PBP we use a 8 MHZ clock
OSCCON = %01110000
ANSEL = 0 ;set all digital
TRISA = %110100 ; Set RA5,RA4 and RA2 input, rest output
TRISB = %0000 ; PORT B all output
TRISC = %00000000 ; PORT C all output
CM1CON0 = 0 ' Disable comparator 1
CM2CON0 = 0 ' Disable comparator 2
led1 var portc.4
buton1 var porta.4
led1flag var bit
low led1
let led1flag = 0
init:
read 10,led1flag
pause 2
main:
if led1flag = 1 then
high led1
else
low led1
endif
if buton1 = 0 then
let led1flag = 1
goto writetoeeprom
endif
goto main
writetoeeprom:
write 10, led1flag
pause 2
debounce:
if buton1 = 0 then goto debounce
goto init
end
The WRITE and READ instructions works on 16F628, 16F688 as is in the code, but on 16F690 still not.
I think on 16F690 must to be defined something to proper work with internal eeprom, but I don't know what.
If I try simple:
Code:
led var bit
let led = 1
write 10, led
main:
read 10, led
SEROUT porta.2,T9600,[led]
end
Nothing writen in to the eeprom.
Bookmarks