🇩🇪
Zitat von: vloki date=1763390927Ansonsten könnte Lesson 3 so aussehen:
So sieht es in der hatten Realität aus: Sie rotieren, die 4 LEDs ! Nicht wirklich, aber ihr Leuchten !
Der Debugger hat nix zu meckern und morgen mache ich mich dran, zu verstehen, warum das klappt! Heute steckte ich noch mit beiden Armen tief und lange im Rollladenkasten, aber wenn morgen der voll krasse Durchblick erreicht werden sollte, dann......, dann passiert leider nix: sitze z.Z. auf dem Trockenen, nix mit "auf den Erfolg machen wir erst mal einen und einen zweiten und den dritten sowieso usw. .......drauf".
Grüße, picassrotieren.jpg
init0:
clrf TRISC,A ;make all of PORTC an output
init1:
movlw 0x08;
movwf LATC,A; setzt Bit 3 und löscht alle anderen Bits
Mainloop:
OndelayLoop:
decfsz Delay1,f,A ;Waste time.
goto OndelayLoop ;The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions
decfsz Delay2,f,A ;The outer loop takes an additional 3 instructions per lap * 256 loops
goto OndelayLoop ;(768+3) * 256 = 197376 instructions / 250K instructions per second = 0.79 sec.
Rotate:
bcf STATUS,0,A ;clear the carry
rrcf LATC,F,A ;shift the LEDs and turn on the next LED to the right
bnc MainLoop ;
bra init1 ;repeat this program forever
bsf LATC,3,A
movlw 0x08;
movwf LATC,F,A; setzt Bit 3 und löscht alle anderen Bits
Rotate:
bcf STATUS,0,A ;clear the carry
rrcf LATC,F,A ;shift the LEDs and turn on the next LED to the right
bnc MainLoop ;
bsf LATC,3,A ;yes, it did and now start the sequence over again by turning on DS4
bra MainLoop ;repeat this program forever
Zitat von: vloki in Gestern um 15:48:47 CETDas shift left gibt es bei den PIC18 nichtRLCF f, d, a Rotate Left f through Carry
Zitat von: picass in Gestern um 09:55:05 CETAuch das Shift-Left und die Prüfung des geschobenen Carry-Bits wird angemeckert: wäre keine korrekte Syntax.Für das Carry finde ich irgendwie auch keinen gültigen Namen. Muss man evtl. selber definieren.
; PICkit 3 Starter Kit
; Assembly Lesson 3
;
; VSK @THU 17.11.2025
; MPLABX v6.20 / pic-as v3.10
; Board: PICkit 3 Low Pin Count Demo Board
; *******************************************************************
; * See Low Pin Count Demo Board User's Guide for Lesson Information*
; *******************************************************************
; config statements in Config_18F1xQ41.s
; cpu clock speed is set to 1MHz in the configuration bits
#include <xc.inc>
GLOBAL Delay1,Delay2;make them global -> watchable when debugging
PSECT udata_acs ;shared memory location that is accessible from all banks
Delay1:
DS 1 ;reserve 1 byte for Delay1
Delay2:
DS 1 ;reserve 1 byte for Delay2
; -------------------LATC-----------------
; Bit#: -7---6---5---4---3---2---1---0---
; LED: ---------------|DS4|DS3|DS2|DS1|-
; ----------------------------------------
PSECT resetVec,class=CODE,reloc=2 ; define "-presetVec=0h" in custom linker options
resetVec:
;cpu clock speed is set to 1MHz in the configuration bits
clrf TRISC,A ;make all of PORTC an output
movlw 00001000B ;start the rotation by setting DS4 ON
movwf LATC,A ;write contents of the working register to the latch
MainLoop:
OndelayLoop:
decfsz Delay1,f,A ;Waste time.
goto OndelayLoop ;The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions
decfsz Delay2,f,A ;The outer loop takes an additional 3 instructions per lap * 256 loops
goto OndelayLoop ;(768+3) * 256 = 197376 instructions / 250K instructions per second = 0.79 sec.
Rotate:
rrcf LATC,F,A ;shift the LEDs and turn on the next LED to the right
btfss STATUS,0,A ;did the bit rotate into the carry (i.e. was DS1 just lit?)
goto MainLoop ;nope, repeat this program forever
bsf LATC,3,A ;yes, it did and now start the sequence over again by turning on DS4
bcf STATUS,0,A ;clear the carry
goto MainLoop ;repeat this program forever
END resetVec
Zitat von: picass in Gestern um 09:55:05 CETÜbers Wochenende lief leider nicht viel, was u.a. daran lag, dass ab der Lesson3 nichts mehr ging.Jo, wie erwähnt war ich nie über Lesson 2 hinaus gekommen ;-)