Warum blinkt's nicht?
Verfasst: Sa 12. Jul 2014, 13:55
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