Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
SysRepeatLoop1
bsf PORTB,4 ;Set PORTB.4 On
movlw D'23'
movwf temp
DECFSZ temp
bcf PORTB,4 ;Set PORTB.4 OFF
movlw D'23'
movwf temp
DECFSZ temp
Return
SysRepeatLoopEnd1
;Set PORTB.4 On
bsf PORTB,4
;Set PORTB.4 On
bsf PORTB,4
;Set PORTB.4 On
bsf PORTB,4
;Set PORTB.4 On
bsf PORTB,4
;Set PORTB.4 On
bsf PORTB,4
;Set PORTB.4 On
bsf PORTB,4
;Set PORTB.4 On
bsf PORTB,4
;Set PORTB.4 On
bsf PORTB,4
;Set PORTB.4 On
bsf PORTB,4
;Set PORTB.4 On
bsf PORTB,4
;Set PORTB.4 On
bsf PORTB,4
;Set PORTB.4 On
bsf PORTB,4
;Set PORTB.4 On
bsf PORTB,4
;Set PORTB.4 On
bsf PORTB,4
;Set PORTB.4 On
bsf PORTB,4
;Set PORTB.4 On
bsf PORTB,4
;Set PORTB.4 On
bsf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
;Set PORTB.4 Off
bcf PORTB,4
The COW supports 10f's too, I love it. For doing lots of loops, a HLL is sure a lot easier to follow. Using Basic syntax like For...Next, DoWhile...Loop, etc. does not add extra code to the assembler.You are using a chip with 67 bytes of RAM, of which 3 are common to all banks, with a high level language. I'm surprised that ANY compiler supports such a limited chip. Switch to a chip with a 14 bit core like the 16F630 or the even better 16F721.
Mike.
;use TMR0 for delays
clrwdt ;must do prior to changing prescale, per data sheet
movlw B'11000110' ;asign prescaler to TMR0, prescale 1:128
asm option
Main:
...
...
For ON_Time = 255 to 1 'Ramp down
Call Change_Duty
Call SoftPWM
Next
For On_Time = 1 to 20 'Blank time
clrf TMR0
Delay3:
btfss TMR0,7
goto Delay3
Next
...
...
Goto Main
Yes, the second For...Next loop is a delay using TMR0. The first three lines of the above code need to initialize the OPTION register for assigning the prescaler to TMR0, and choosing the prescaler value.yup! good tips
is that 2nd FOR loop the wait command, can i put it in to cow? (this may solve alot of my probs!)
will that PICLIST delay calculator code go in to cow too?
;Program compiled by Great Cow BASIC (0.9 7/2/2010)
;Need help? See the GCBASIC forums at http://sourceforge.net/forum/?group_id=169286,
;check the documentation or email w_cholmondeley@users.sourceforge.net.
;********************************************************************************
;Set up the assembler options (Chip type, clock source, other bits and pieces)
LIST p=16F526, r=DEC
#include <P16F526.inc>
__CONFIG _CPDF_OFF & _IOSCFS_8MHz & _MCLRE_ON & _CP_OFF & _WDTE_OFF
;********************************************************************************
;Set aside memory locations for variables
TRISB EQU 13
DELAYTEMP EQU 14
DELAYTEMP2 EQU 15
SysWaitTempMS EQU 16
SysWaitTempMS_H EQU 17
;********************************************************************************
;Vectors
;Start of program memory page 0
ORG 0
BASPROGRAMSTART
;Call initialisation routines
call INITSYS
;Automatic pin direction setting
banksel TRISB
bcf TRISB,0
;Start of the main program
SysDoLoop_S1
banksel PORTB
bsf PORTB,0
movlw 100
movwf SysWaitTempMS
clrf SysWaitTempMS_H
call Delay_MS
bcf PORTB,0
movlw 100
movwf SysWaitTempMS
clrf SysWaitTempMS_H
call Delay_MS
goto SysDoLoop_S1
SysDoLoop_E1
BASPROGRAMEND
sleep
goto $
;********************************************************************************
Delay_MS
incf SysWaitTempMS_H, F
DMS_START
movlw 142
movwf DELAYTEMP2
DMS_OUTER
movlw 1
movwf DELAYTEMP
DMS_INNER
decfsz DELAYTEMP, F
goto DMS_INNER
decfsz DELAYTEMP2, F
goto DMS_OUTER
decfsz SysWaitTempMS, F
goto DMS_START
decfsz SysWaitTempMS_H, F
goto DMS_START
return
;********************************************************************************
INITSYS
bcf ADCON0,ADON
bcf ADCON0,ANS0
bcf ADCON0,ANS1
bcf CM2CON0,C2ON
bcf CM1CON0,C1ON
movlw B'11001111'
option
clrf PORTB
clrf PORTC
movlw B'00000000'
movwf TRISB
retlw 0
;********************************************************************************
;Start of program memory page 1
ORG 512
END
:020000040000FA
:100000002109A404C4040D04A404C4040605640C5A
:100010003000710013090604640C300071001309EC
:10002000040A0300120AB1028E0C2F00010C2E00EC
:10003000EE02180AEF02160AF002140AF102140A7C
:1000400000080904C904E9046B046804CF0C020029
:0A00500066006700FF0C2D00000899
:021FFE00F70FDB
:00000001FF
Example:
'This program will send a byte using PORTB.2, the value of which
'depends on whether a button is pressed.
#define RecAHigh PORTB.2 ON
#define RecALow PORTB.2 OFF
InitSer (1, r9600, 1+WaitForStart, 8, 1, none, normal)
Main:
if Button pressed then Temp = 0
if Button released then Temp = 100
SerSend (1, Temp)
Wait 1 s
goto Main
'This program will read a byte from PORTB.2, and set the green
'on if the byte is more than 50.
#define RecAHigh PORTB.2 ON
#define RecALow PORTB.2 OFF
InitSer (1, r9600, 1+WaitForStart, 8, 1, none, normal)
SerReceive (1, Temp)
if Temp > 50 then set green on
SerialPrint (1,"hello")