Warum blinkt's nicht?
Warum blinkt's nicht?
Hallo, bin gerade aus dem Urlaub zurück und habe mir vorgenommen, mich mit SPIN auseinandersetzen. Da stellt sich auch gleich die erste Frage. Unter den Testprogrammen für Bellatrix gibt es das start-blinky.spin:
CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000
LED = 24 'HBeat-LED ist an Port 24
PUB blinky
dira[LED] := 1 'LED-Port auf Ausgabe schalten
repeat
outa[LED] := 1 'LED ON
waitcnt(cnt + CLKFREQ) '1 Sekunde warten
outa[LED] := 0 'LED OFF
waitcnt(cnt + CLKFREQ) '1 Sekunde warten
Die Funktionsweise ist mir klar. Im Buch 'Programming the propeller with spin' finde ich folgendes Listing:
{{12 Sep 09 Harprit Sandhu BlinkLED.spin Propeller Tool Ver. 1.2.6 Chapter 13 Program 1
This program turns an LED ON and OFF, with a programmable set delay. It demonstrates the use of methods in an absolutely minimal way. The clock is running at 10 MHz. Define the constants we will use. There are no variables in this program.
}}
CON
_CLKMODE=XTAL1 + PLL2X 'The system clock spec
_XINFREQ = 5_000_000 'the crystal frequency
inv_high =0 'define the inverted High state
inv_low =1 'define the inverted Low state
waitPeriod =5_000_000 'about 1/2 sec switch cycle
output_pin =27 ' habe ich auf 24 gesetzt
'High is defined as 0 and low is defined as a 1 because we are using an
'inverting buffer on the Propeller output.
PUB Go
dira [output_pin]~~ 'sets pin to an output line with ~~
outa [output_pin]~~ 'makes the pin high
repeat 'repeat forever, no number after repeat
turnOff_LED 'method call
wait 'method call
turnOn_LED 'method call
wait 'method call
PRI turnOn_LED 'method to set the LED line high
outa[output_pin] :=inv_high 'line that actually sets the LED high
PRI turnOff_LED 'method to set the LED line low
outa[output_pin] :=inv_low 'line that actually sets the LED low
PRI wait 'delay method
waitCnt(waitPeriod + cnt) 'delay is specified by the waitPeriod
Zur Anpassung habe ich den output_pin =24 gesetzt und das Progrämmchen in den Bellatrix-RAM geladen.
Warum blinkt die HBeatLED nicht so wie ich es eigentlich erwarte, sondern geht nur genau 1x an und wieder aus?
Gruß Norbert
CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000
LED = 24 'HBeat-LED ist an Port 24
PUB blinky
dira[LED] := 1 'LED-Port auf Ausgabe schalten
repeat
outa[LED] := 1 'LED ON
waitcnt(cnt + CLKFREQ) '1 Sekunde warten
outa[LED] := 0 'LED OFF
waitcnt(cnt + CLKFREQ) '1 Sekunde warten
Die Funktionsweise ist mir klar. Im Buch 'Programming the propeller with spin' finde ich folgendes Listing:
{{12 Sep 09 Harprit Sandhu BlinkLED.spin Propeller Tool Ver. 1.2.6 Chapter 13 Program 1
This program turns an LED ON and OFF, with a programmable set delay. It demonstrates the use of methods in an absolutely minimal way. The clock is running at 10 MHz. Define the constants we will use. There are no variables in this program.
}}
CON
_CLKMODE=XTAL1 + PLL2X 'The system clock spec
_XINFREQ = 5_000_000 'the crystal frequency
inv_high =0 'define the inverted High state
inv_low =1 'define the inverted Low state
waitPeriod =5_000_000 'about 1/2 sec switch cycle
output_pin =27 ' habe ich auf 24 gesetzt
'High is defined as 0 and low is defined as a 1 because we are using an
'inverting buffer on the Propeller output.
PUB Go
dira [output_pin]~~ 'sets pin to an output line with ~~
outa [output_pin]~~ 'makes the pin high
repeat 'repeat forever, no number after repeat
turnOff_LED 'method call
wait 'method call
turnOn_LED 'method call
wait 'method call
PRI turnOn_LED 'method to set the LED line high
outa[output_pin] :=inv_high 'line that actually sets the LED high
PRI turnOff_LED 'method to set the LED line low
outa[output_pin] :=inv_low 'line that actually sets the LED low
PRI wait 'delay method
waitCnt(waitPeriod + cnt) 'delay is specified by the waitPeriod
Zur Anpassung habe ich den output_pin =24 gesetzt und das Progrämmchen in den Bellatrix-RAM geladen.
Warum blinkt die HBeatLED nicht so wie ich es eigentlich erwarte, sondern geht nur genau 1x an und wieder aus?
Gruß Norbert
Drohne 400
- PIC18F2550
- Beiträge: 2851
- Registriert: Fr 30. Sep 2011, 13:08
Re: Warum blinkt's nicht?
Verwende bitte mal die Formatierung für Code.
Sonst ist der Code nicht lesbar.
Die einrückungen sind wichtig.
Sonst ist der Code nicht lesbar.
Die einrückungen sind wichtig.
Gruß
PIC18F2550
drone265/278
Barbarus hic ergo sum, quia non intellegor ulli.
Ein Barbar bin ich hier, da ich von keinem verstanden werde.
ʎɐqǝ ıǝq ɹnʇɐʇsɐʇ ǝuıǝ ɹǝpǝıʍ ǝıu ǝɟnɐʞ ɥɔı ´uuɐɯ ɥo
PIC18F2550
drone265/278
Barbarus hic ergo sum, quia non intellegor ulli.
Ein Barbar bin ich hier, da ich von keinem verstanden werde.
ʎɐqǝ ıǝq ɹnʇɐʇsɐʇ ǝuıǝ ɹǝpǝıʍ ǝıu ǝɟnɐʞ ɥɔı ´uuɐɯ ɥo
Re: Warum blinkt's nicht?
versuche mal mit EinrückenNJO hat geschrieben: repeat
outa[LED] := 1 'LED ON
waitcnt(cnt + CLKFREQ) '1 Sekunde warten
outa[LED] := 0 'LED OFF
waitcnt(cnt + CLKFREQ) '1 Sekunde warten
Code: Alles auswählen
repeat
outa[LED] := 1 'LED ON
waitcnt(cnt + CLKFREQ) '1 Sekunde warten
outa[LED] := 0 'LED OFF
waitcnt(cnt + CLKFREQ) '1 Sekunde warten
Computer lösen die Probleme, die man ohne sie gar nicht hätte!
Re: Warum blinkt's nicht?
Sorry, die Formatierung ging leider beim Kopieren verloren, hier korrekt:
Code: Alles auswählen
{{12 Sep 09 Harprit Sandhu BlinkLED.spin Propeller Tool Ver. 1.2.6 Chapter 13 Program 1
This program turns an LED ON and OFF, with a programmable set delay. It demonstrates the use of methods in an absolutely minimal way. The clock is running at 10 MHz. Define the constants we will use. There are no variables in this program.
}}
CON
_CLKMODE=XTAL1 + PLL2X 'The system clock spec
_XINFREQ = 5_000_000 'the crystal frequency
inv_high =0 'define the inverted High state
inv_low =1 'define the inverted Low state
waitPeriod =5_000_000 'about 1/2 sec switch cycle
output_pin =27 ' habe ich auf 24 gesetzt
'High is defined as 0 and low is defined as a 1 because we are using an
'inverting buffer on the Propeller output.
PUB Go
dira [output_pin]~~ 'sets pin to an output line with ~~
outa [output_pin]~~ 'makes the pin high
repeat 'repeat forever, no number after repeat
turnOff_LED 'method call
wait 'method call
turnOn_LED 'method call
wait 'method call
PRI turnOn_LED 'method to set the LED line high
outa[output_pin] :=inv_high 'line that actually sets the LED high
PRI turnOff_LED 'method to set the LED line low
outa[output_pin] :=inv_low 'line that actually sets the LED low
PRI wait 'delay method
waitCnt(waitPeriod + cnt) 'delay is specified by the waitPeriod
Drohne 400
- drohne235
- Administrator
- Beiträge: 2284
- Registriert: So 24. Mai 2009, 10:35
- Wohnort: Lutherstadt Wittenberg
- Kontaktdaten:
Re: Warum blinkt's nicht?
Bei mir blinkt es. Die Einstellungen zur Taktfrequenz (_CLKMODE = XTAL1 + PLL16X) sind zwar falsch, aber es blinkt.
"Ob Sie denken, dass Sie es können, oder ob Sie denken, dass Sie es nicht können - in beiden Fällen haben Sie recht." Henry Ford
Re: Warum blinkt's nicht?
Ich habe das obere Listing noch mal ohne Einrückungen versucht, ohne Erfolg. Die Einrückungen bringen es scheinbar. Ich bin vermutlich etwas durchs SQL verdorben, da ist die Formatierung ziemlich wurscht, wenn man mal was auf die Schnelle schreibt. Muss ich demnächst beachten.
Drohne 400
Re: Warum blinkt's nicht?
in SPIN hat die Einrückung syntaktische Bedeutung.
Das ist sehr ungewöhnlich (ich persönlich mag den Ansatz nicht), aber daran muss man sich eben halten wenn man was mit SPIN machen möchte.
Das ist sehr ungewöhnlich (ich persönlich mag den Ansatz nicht), aber daran muss man sich eben halten wenn man was mit SPIN machen möchte.
Also vonder Sache här tätch jetz ma behaupten "Mischn ägomplischd" un so...
Re: Warum blinkt's nicht?
Ich finde die Einrückungs-Pflicht eigentlich sehr vorteilhaft, zwingt sie einem doch ein Mindestmass an Struktur im Programm auf.
Gerade Schleifen oder Abfragen werden sehr schnell unübersichtlich, wenn die Bereiche, auf die sich die Schleife oder Abfrage bezieht optisch nicht erkennbar ist.
Gerade Schleifen oder Abfragen werden sehr schnell unübersichtlich, wenn die Bereiche, auf die sich die Schleife oder Abfrage bezieht optisch nicht erkennbar ist.
Computer lösen die Probleme, die man ohne sie gar nicht hätte!