I tried this code:
#chip 10F200, 4
#mem 16
#config _MCLRE_OFF & _CP_OFF & _WDT_OFF
movlw 0xC0
option
dir GPIO b'11111110'
set GPIO.0 ON
wait 20 us
set GPIO.0 OFF
Using Mplab I realized that the delay isn't 20 us but, it is longer.
I think that the asm routine for the us delay isn't correct.
The routine that I get is:
--------------
Delay_US
DUS_START
decfsz SysWaitTempUS, F
goto DUS_START
retlw 0
--------------
The value of SysWaitTempUS is 20
movlw 20
movwf SysWaitTempUS
decfsz is one cycle
goto is two cycle
In this way the delay that I get is about three times the set delay.
The code of the input file is:
;Program compiled by Great Cow BASIC (0.9 24/12/2006)
;Need help? See the GCBASIC forums at http://sourceforge.net/forum/?group_id=169286,
;check the documentation or email hconsidine@bigpond.com.
;Set up the assembler options (Chip type, clock source, other bits and pieces)
LIST p=10F200, r=DEC
#include <P10F200.inc>
__CONFIG _MCLRE_OFF&_CP_OFF&_WDT_OFF
;Start of the main program
movlw 0XC0
option
movlw B'11111110'
tris GPIO
bsf GPIO,0
movlw 20
movwf SysWaitTempUS
call Delay_US
bcf GPIO,0
BASPROGRAMEND
sleep
goto $
;********************************************************************************
;Subroutines included in program
;********************************************************************************
Delay_US
DUS_START
decfsz SysWaitTempUS, F
goto DUS_START
retlw 0
Thanks for reporting that bug! I've been able to eliminate this problem for fixed us delays, and have added an error message for variable delays. The update is at http://gcbasic.sourceforge.net/newfiles/update.zip
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried this code:
#chip 10F200, 4
#mem 16
#config _MCLRE_OFF & _CP_OFF & _WDT_OFF
movlw 0xC0
option
dir GPIO b'11111110'
set GPIO.0 ON
wait 20 us
set GPIO.0 OFF
Using Mplab I realized that the delay isn't 20 us but, it is longer.
I think that the asm routine for the us delay isn't correct.
The routine that I get is:
--------------
Delay_US
DUS_START
decfsz SysWaitTempUS, F
goto DUS_START
retlw 0
--------------
The value of SysWaitTempUS is 20
movlw 20
movwf SysWaitTempUS
decfsz is one cycle
goto is two cycle
In this way the delay that I get is about three times the set delay.
The code of the input file is:
;Program compiled by Great Cow BASIC (0.9 24/12/2006)
;Need help? See the GCBASIC forums at http://sourceforge.net/forum/?group_id=169286,
;check the documentation or email hconsidine@bigpond.com.
;********************************************************************************
;Set up the assembler options (Chip type, clock source, other bits and pieces)
LIST p=10F200, r=DEC
#include <P10F200.inc>
__CONFIG _MCLRE_OFF&_CP_OFF&_WDT_OFF
;********************************************************************************
;Set aside memory locations for variables
SysWaitTempUS equ 16
;********************************************************************************
;Jump to initialisation code when PIC is reset
ORG 0
call INITSYS
goto SystemInitialise
;********************************************************************************
;Various initialisation routines, automatically called by GCBASIC
SystemInitialise
;********************************************************************************
;Start of the main program
movlw 0XC0
option
movlw B'11111110'
tris GPIO
bsf GPIO,0
movlw 20
movwf SysWaitTempUS
call Delay_US
bcf GPIO,0
BASPROGRAMEND
sleep
goto $
;********************************************************************************
;Subroutines included in program
;********************************************************************************
Delay_US
DUS_START
decfsz SysWaitTempUS, F
goto DUS_START
retlw 0
;********************************************************************************
INITSYS
retlw 0
;********************************************************************************
END
ciao
stefano
Thanks for reporting that bug! I've been able to eliminate this problem for fixed us delays, and have added an error message for variable delays. The update is at http://gcbasic.sourceforge.net/newfiles/update.zip