Re: Propeller und Forth
Verfasst: Fr 22. Apr 2011, 17:18
Hey, das ist cool.
Gibt es eigentlich konkrete Pläne was du mit dem Aufbau machen möchtest?

Retro Style Eigenbau Computer mit Parallax Propeller
https://www.hive-project.de/board/
dafür hab ich mich jetzt entschieden, da geht auch schon, werd ich morgen posten.drohne235 hat geschrieben:
Zwei Ideen:
1. Die SerialCog in Assembler ein wenig erweitern.
Code: Alles auswählen
c" x " 2 cogx
[/quote]2. Die serialcog temporär beenden, selbst die Leitungen von Forth aus steuern und danach die serialcog wieder starten.
Zu Version 1: Wenn ich es recht in Erinnerung habe, erkennt die serialcog an ihrer Eingangsvariable (32Bit!) durch ein gesetztes Bit 8 (also 0x000001nn), dass der Wert im unteren Byte gesendet werden soll. Mit einem anderen Bit könnte man also durchaus weitere Funktionen aufrufen, wie eine Break-Funktion.
Zu Version 2: Im Startmechanismus von PropForth kann man sich anschauen, wie die serialcog gestartet wird. Beenden ist ja kein Problem, die Break-Funktion dann schön komfortabel in einem Forthwort.
Das sind die Sachen die mir so ganz spontan einfallen, sollte problemlos machbar sein. Am einfachsten ist wahrscheinlich Variante 2, da man da alles bequem unter Forth testen kann - sowas ist ja immer eine Stärke von Forth.
Kann es grad nicht testen, aber könnte etwa so funktionieren:Wie kann ich meherer AsCII zeichen zu einem Cstr zusammenbasteln und dann mit cogx ausgeben?
Code: Alles auswählen
' Transmit
'
transmit jmpret task1Ptr, task2Ptr
rdword txdata, v_in
cmp txdata, #$000 wz 'oo generates a break
if_z jmp #:sbreak
test txdata, #$100 wz ' wz is 1 if all bit after AND are 0 -> sending data if bit 8 is not set
if_nz jmp #transmit
mov t1 , #$100
wrword t1 , v_in ' write $100 back to addres V_in
or txdata,#$100 ' add start and stopbit
shl txdata,#2
or txdata,#1
mov txbits,#11
mov txcnt,cnt ' cnt = system counter
jmp #:bit
:sbreak mov t1 , #$100
wrword t1 , v_in ' write $100 back to addres V_in
mov txdata, #$1 ' write 1 to Txdata
shl txdata, #32 ' shift left 1 to %10000000000000000000000000000000
sar txdata, #32 ' shift arithmetic right to get $FFFFFFFF, is there any better way to get this result?
mov txbits, #32 ' reduce this number to get a shorter break now its 32 marks/spaces
mov txcnt, cnt
Code: Alles auswählen
: zeile c" xxx" ;
0 zeile 1+ C!
Code: Alles auswählen
\ das Original
: cogx io 2+ W@ rot2 cogio io 2+ W! .cstr cr io 2+ W! ;
\ ohne CRLF
: cogwocrlf io 2+ W@ rot2 cogio io 2+ W! .cstr io 2+ W! ;
Code: Alles auswählen
fl
\ I like to send some command to any serialport and receive some answers from this port
\ the answer should be shown on the console
\ this is a very common task in any kind of instrumentation
\ herer its a RS422 port
\
\ i have addd modified the PropForth.spin a little bit to create an odd parity serial signal
\ and also to create a break signal (12 bits low) which is genaerated if i am sending 0x7C
\
\ a place for the output of the serial driver
hex
wvariable inchar 100 inchar W!
decimal
\ defining the con nr. for the comicating cog
2 wconstant orbitcog
\ defining the io pins for the instrument
5 wconstant orbitrxpin
4 wconstant orbittxpi
6 constant orbitresetpin
\ defining the baudrate for the instrument
9600 wconstant orbitbaudrate
\ serial no. of 2 instruments each 10 chars
: orbits c" 130B520P01130B520P02" ;
orbitcog cogstop
orbitrxpin orbittxpin orbitbaudrate orbitcog startserialcog
10 delms
\ es wird ein cogw definiert wie cogx nur ohne cr
decimal
\ not used anymore = cogx without crlf : cogw io 2+ W@ rot2 cogio io 2+ W! .cstr io 2+ W! ;
\ RS422 direction switch
: ausgang orbitresetpin pinout ;
: aus orbitresetpin pinhi ;
: ein orbitresetpin pinlo ;
hex
\all following words are using hexadecimal constants
7C wconstant w_strich
52 wconstant w_R
4E wconstant w_N
49 wconstant w_I
31 wconstant w_1
53 wconstant w_S
: send
aus
emit
1 delms
ein
1 delms
;
: sendbreak
aus
w_strich emit
2 delms
ein
;
: solinit
ausgang
sendbreak
1 delms
w_R send
1 delms
0 send
1200 delms
;
: solnotify
sendbreak
2 delms
w_N send
2 delms
0 send
;
: solsetaddr
\ (index -) give 1..x index of the orbit code in orbits
\ calculate the index of the string
\ attention * is only in the Propforth.f !
sendbreak
1 delms
w_S send
1 delms
dup
send
1 delms
1-
B *
orbits
1+
\ the address of the string on the stack
swap +
\ swap the index and the address and add the index
aus
A
\ give out 10 signs
.str
4 delms
ein
0 send
;
: solident
sendbreak
1 delms
w_I send
1 delms
1 send
;
: solread
\ (index - )
sendbreak
1 delms
w_1 send
send
;
\ this is the core of everything
\ solcomopen redirets the output of the forth console two the serialcog started above
\ an emit is now sending to another serial interface
\ all bytes received are stored in the serial input buffer of the orbitcog
\these code was published by SalS in the Propeller Forum
fl
: solcomopen
\ get the current output ptr of orbitcog, leave on the stack
orbitcog cogio 2+ W@
\ set the output of orbitcog to point to inchar
inchar orbitcog cogio 2+ W!
\ get the current output ptr of this cog, leave on the stack
io 2+ W@
\ set the output ptr of this cog to the input of orbitcog
orbitcog cogio io 2+ W!
;
\ now read out the iputbuffer of orbitcog to the console
: solinput
hex
\ input no. of bytes to read
\ restore this cogs output pointer
io 2+ W!
\ the serial port buffers up to 128 characters on input, so they should all be there
F 0
do
i .
\ poll for a char, 4096 times max
1000 0
do
\ is there a character from the serial port
inchar W@ 100 and 0=
if
\ get the char
inchar W@
\ set inchar ready to receive next char
100 inchar W!
.
leave
then
loop
cr
loop
\ STILL BIG question: not clear what this should do???
\ orbitcog cogio 2+ W!
;
: orbitinit
solcomopen
1 delms
solinit
2 delms
solinput
;
: orbitsetaddr
solcomopen
1 delms
1 solsetaddr
2 delms
solinput
;
: orbitread
solcomopen
1 delms
1 solread
2 delms
solinput
;