Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > sci.electronics.design > #380544
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Newsgroups | sci.electronics.design |
| Subject | Re: OT: programming problem |
| References | <dAJQx.52004$P21.14655@fx09.iad> <mv05ie$66b$1@speranza.aioe.org> <RgTQx.75969$up4.24745@fx16.iad> |
| Message-ID | <KkWQx.4$VR.3@fx01.iad> (permalink) |
| Date | 2015-10-06 13:40 -0700 |
Robert Baer wrote:
> Martin Brown wrote:
>> On 06/10/2015 07:09, Robert Baer wrote:
>> > Yes, the same old PIC16F648A..
>> >
>> > DELAY MOVWF sW ; save W
>> > ; following gives Warning: Argument out of range. Least significant
>> > bits used.
>> > MOVF sSTATUS,STATUS ;assy: d=1;sSTATUS@25 == save STATUS
>> > CLRF COUNT1
>> > CLRF COUNT2
>> > MOVLW d'16' ; fudge for about 1 Sec delay
>> > MOVWF COUNT3
>> >
>> > LOOPIE DECFSZ COUNT3
>> > GOTO LUPOTR
>> > GOTO DEXIT
>> >
>> > LUPOTR DECFSZ COUNT2
>> > GOTO LUPINR ; COUNTed once,do inner loop
>> > GOTO LOOPIE
>> >
>> > LUPINR INCFSZ COUNT1 ; race inside inner loop
>> > GOTO LUPINR ; high speed count
>> > GOTO LUPOTR ; go for another outer count
>> >
>> > DEXIT: MOVF sW ; restore W
>> > ; following gives Warning: Argument out of range. Least significant
>> > bits used.
>> > MOVF STATUS,sSTATUS ;assy: d=0;STATUS@03 == restore STATUS
>> > RETURN
>> > Using this shows that W is NOT restored, that it set to the delay
>> value.
>> > Therefore, i can assume ditto for STATUS.
>> > Comments in listing derived from compiled code; "d" stands for the
>> > direction bit.
>> >
>> > Help?
>>
>> Learning how to program in PIC assembler might help. RTFM
>>
>> http://tutor.al-williams.com/pic-inst.html
>>
>> MOVF sW,W
>>
>> MOVF sW,F merely tests if sW==0
>>
>> Is this some sort of competition to maximise the number of GOTOs and
>> random flow of control? Heaven help the maintenance programmers.
>>
>> If you reorder the code sensibly half of the GOTOs vanish.
>> COUNT3 needs to be one less due to dropping through the loop code.
>>
>> LUPINR INCFSZ COUNT1
>> GOTO LUPINR
>> DECFSZ COUNT2
>> GOTO LUPINR
>> DECFSZ COUNT3
>> GOTO LUPINR
>> DEXIT
>>
>> I prefer to have a single delay routine that accepts W on input as the
>> exact number of cycles to delay by as a separate routine. It makes doing
>> variable precision delays in software so much easier. YMMV
>>
> Thanks again.
>
I now have an "improved" version, but still do not have satisfactory
results.
**
start: ;** setup I/O
CLRF 6 ; Set all Port B pins to logic 0
BSF 3,5 ; Bank 1 command comes next STATUS RP0 set
CLRF 6 ; sel all Port B pins as outputs
BCF 3,5 ; Bank 0 command comes next STATUS RP0 clear
CLRF ptrlo
CLRF ptrhi
CLRW
MOVWF 6 ; Port B to zero
CALL DELAY ; "freeze" LEDs
MOVLW 0xFF
MOVWF 6 ; Port B ones
CALL DELAY ; "freeze" LEDs
setup:
MOVLW Low(tab1) ; tab1 at org 0x0100
ADDWF ptrlo,W ; add pointer to W [so W=0 now]
MOVLW High(tab1) ; [so W=1 now]
BTFSC STATUS,C
INCF PCLATH,F ; carry to hi
; CALL tab1 ; first table, first location (=0)
; RETurns here
MOVWF 6 ; Port B from W shows 0x01 [OK]
CALL DELAY ; "freeze" LEDs
repeat: INCF ptrlo ; next loc
MOVWF 6 ; Port B from W shows 0x18 [???]
CALL DELAY ; "freeze" LEDs
INCF ptrlo ; next loc
MOVWF 6 ; Port B from W shows 0x18
CALL DELAY ; "freeze" LEDs
INCF ptrlo ; next loc
; BTFSC STATUS,Z
; INCF ptrhi
MOVWF 6 ; Port B from W shows 0x18
CALL DELAY ; "freeze" LEDs
GOTO setup
; ----------------------------------------------
DELAY MOVWF sW
MOVF STATUS,W
MOVWF sSTATUS
CLRF COUNT1
CLRF COUNT2
MOVLW d'93' ; fudge for about 4 Sec delay
MOVWF COUNT3
LUPINR DECFSZ COUNT1
GOTO LUPINR
DECFSZ COUNT2
GOTO LUPINR
DECFSZ COUNT3
GOTO LUPINR
DEXIT: MOVF sSTATUS,W
MOVWF STATUS
MOVF sW
RETURN
**
So something in the delay routine is setting W to 0x18.
WTH?
Back to sci.electronics.design | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
OT: programming problem Robert Baer <robertbaer@localnet.com> - 2015-10-05 23:09 -0700
Re: OT: programming problem piglet <erichpwagner@hotmail.com> - 2015-10-06 09:48 +0100
Re: OT: programming problem Robert Baer <robertbaer@localnet.com> - 2015-10-06 09:58 -0700
Re: OT: programming problem Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-06 10:51 +0100
Re: OT: programming problem Robert Baer <robertbaer@localnet.com> - 2015-10-06 10:11 -0700
Re: OT: programming problem Robert Baer <robertbaer@localnet.com> - 2015-10-06 13:40 -0700
Re: OT: programming problem Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-07 09:14 +0100
Re: OT: programming problem Robert Baer <robertbaer@localnet.com> - 2015-10-07 19:50 -0700
Re: OT: programming problem "P E Schoen" <paul@pstech-inc.com> - 2015-10-06 21:01 -0400
Re: OT: programming problem Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-07 09:16 +0100
Re: OT: programming problem Lasse Langwadt Christensen <langwadt@fonz.dk> - 2015-10-07 02:00 -0700
Re: OT: programming problem, NASTY Robert Baer <robertbaer@localnet.com> - 2015-10-07 22:23 -0700
Re: OT: programming problem, NASTY Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-08 12:05 +0100
Re: OT: programming problem, NASTY piglet <erichpwagner@hotmail.com> - 2015-10-08 16:31 +0100
Re: OT: programming problem Robert Baer <robertbaer@localnet.com> - 2015-10-07 20:10 -0700
Re: OT: programming problem new_ibm <randy.day@sasktel.netx> - 2015-10-08 08:33 -0600
Re: OT: programming problem Robert Baer <robertbaer@localnet.com> - 2015-10-07 19:33 -0700
csiph-web