I still havent been able to get a version running.
Didnt do much last night - painful result of dentist appt
I have to work today but now not working late.
How can I test the latest ROM on the P2-Eval? I'm compiling the file ROM_Booter_v33_01j.spin2 with PNut v32i but I'm unable to access the serial port without resetting the Propeller and ending up with the old ROM
How can I test the latest ROM on the P2-Eval? I'm compiling the file ROM_Booter_v33_01j.spin2 with PNut v32i but I'm unable to access the serial port without resetting the Propeller and ending up with the old ROM
This is mainly for testing on the FPGA which is designed to accept a new ROM on power-up but subsequent resets will not reset the new ROM. My eval board has the reset cap removed so it requires a manual reset around the time that I am loading it. I think every Prop and P2 board should be able to disconnect the DTR from the reset but the P2 serial loader is not so critical of the reset to load time. I did use loadp2 to load the ROM onto my eval board and that seemed to worked fine. Normally I always use Dave Hein's p2asm and loadp2.
Would you mind releasing an up to date version of Taqoz bix file for the P2-ES with latest features such as SD formatting?
Yep, I just loaded everything including the kitchen sink on the P2D2 and I'm just loading up the new FPGA image that I need to check something on and then I will post the new ES image and update the Dropbox shortly.
Here's the complete TAQOZ binary for the eval board including VGA and PS/2 etc.
Just rename P2.ROM to _BOOT_P2.BIX and copy onto your SD card or else you can use loadp2 to directly load P2.ROM onto the P2 serially.
I still need to add file creation support next so you can not only create a file but also preallocate clusters in terms of bytes for the file. Given that even if we had 1MB preallocatted per file and even if we somehow had 1000 files that would still only be 1GB used.
Here is some simple code that display number 0 to 9 on a 7 segment display. The leds are connected directly to the GPIO, the 1mA drive is used so we don't need resistors. It demonstrates how switch/case is used in TAQOZ.
32 := BASE_PIN
: 1MA_DRIVE 4 11 << WRPIN ;
: INIT_LEDS BASE_PIN 8 ADO I PIN 1MA_DRIVE L LOOP ;
INIT_LEDS
: LEDS_OFF BASE_PIN 8 ADO I PIN L LOOP ;
: LEDS_ON BASE_PIN 8 ADO I PIN H LOOP ;
: LEDS_DISP BASE_PIN 7 ADO DUP 1& IF I HIGH ELSE I LOW THEN 2/ LOOP DROP ;
: 7SEG
SWITCH
0 CASE %1011111 LEDS_DISP BREAK
1 CASE %0000110 LEDS_DISP BREAK
2 CASE %0111011 LEDS_DISP BREAK
3 CASE %0101111 LEDS_DISP BREAK
4 CASE %1100110 LEDS_DISP BREAK
5 CASE %1101101 LEDS_DISP BREAK
6 CASE %1111101 LEDS_DISP BREAK
7 CASE %1000111 LEDS_DISP BREAK
8 CASE %1111111 LEDS_DISP BREAK
9 CASE %1101111 LEDS_DISP BREAK
;
: COUNT 10 0 DO I . SPACE I 7SEG 1 s LOOP LEDS_OFF ;
One of the things that we can do is create a lookup table rather than tackling decoding programmatically, that is exhausting a list of conditionals in this case. So it becomes a simple matter than to expand the array to include hex digits or even ASCII (with some awkward characters).
Have a look at this code that uses a table that is created using CREATE that simply returns its empty code address. We then compile values in after this and simply use the address it returns to index into the array of values and read them as bytes. I'm sure there is a better way of writing all 7/8 bits at a time rather than looping through them but it does make it simple especially since we set the pin to 1ma source just before we write the data, so there is no need for a special init routine. I left the extra % symbols in between the binary bytes as any symbol is allowed as a separator and this one is just as good as any. The idea was to pack them into words or longs since compiling non-word aligned values throws the compiling/execution off.
This code is setup with a default of pin 32 but you can change it at runtime using LEDPINS.
TAQOZ --- EVAL ROM COMPATIBLE VERSION
CREATE 7SEGS --- %pgfedcba segments
--- 3 2 1 0 ( packed as a long for , )
%01100110%00111011%00000110%01011111 ,
--- 7 6 5 4
%01000111%01111101%01101101%01100110 ,
--- b A 9 8
%01111000%01110111%01101111%01111111 ,
--- F E d c
%01110001%01111001%01011110%01011000 ,
--- Write bit0 to current port pin
: P! 1 AND IF H ELSE L THEN ;
: 7SEG
7SEGS + C@
: LEDS ( segments -- )
32 8 ADO I PIN $2000 WRPIN DUP P! 2/ LOOP DROP
;
--- setup the base pin for the 7-SEG LED
: LEDPINS ( pin -- ) ' LEDS C! ;
: DEMO 16 0 DO I . SPACE I 7SEG 1 s LOOP OFF LEDS ;
END
Here's a quick port of my version of LIFE that runs in an ANSI color terminal such as TeraTerm or minicom etc. Best to autobaud as high as you can go but I set minicom for 3M baud.
Look in the source at MENU to see what keys you can press to introduce patterns and change the width of the universe etc.
Copy and paste this code with a 10ms or so line delay.
TAQOZ
pub LIFE.fth ." Conway's Game of Life for TAQOZ in the P2 ROM V1.0 190226.0000 " ;
{
Adapted from code at:
http://www.forth-ev.de/wiki/doku.php/projects:4e4th:4e4th:start:beispiele
Optimized for cell widths so 32 wide for the Propeller
Modified so that lines print horizontally to optimize the cell width vertically
Widths of up to 512 can be used
Automatically expands horizontally if "expanding" mode is used: 16 WIDE EXPANDING RANDOM LIFE
}
--- *** ANSI TERMINAL SUPPORT ***
0 := black
1 := red
2 := green
3 := yellow
4 := blue
5 := magenta
6 := cyan
7 := white
: EMIT CONEMIT ;
: AEMIT CONEMIT ;
long _ansi
pub ESC ( ch -- ) $1B AEMIT AEMIT ;
pub HOME 'H'
pri ESCB ( ch -- ) '[' ESC AEMIT ;
pub PEN ( col -- ) 7 AND '3'
pri COL ( col fg/bg -- ) ESCB '0' + AEMIT 'm' AEMIT ;
pub PAPER ( col -- ) '4' COL ;
pri CUR ( cmd n -- ) '[' ESC SWAP
pri .PAR SWAP . AEMIT ;
pub XY ( x y -- ) ';' SWAP CUR 'H' .PAR ;
pub CLS $0C EMIT ;
--- Erase the screen from the current location
pub ERSCN '2' ESCB 'J' AEMIT ;
--- Erase the current line
pub ERLINE '2' ESCB 'K' AEMIT ;
pub CURSOR ( on/off -- ) '?' ESCB 25 .
pri asw IF 'h' ELSE 'l' THEN AEMIT ;
pub PLAIN '0'
pri ATR ( ch -- ) ESCB 'm' AEMIT ;
pub REVERSE '7' ATR ;
pub BOLD '1' ATR ;
pub WRAP ( on/off -- ) '?' ESCB '7' AEMIT asw ;
pub MARGINS ( top bottom -- ) '[' ESC SWAP ':' .PAR 'r' .PAR ;
PLAIN
SDBUF $800 + := universe
IFNDEF CELLS pub CELLS 4* ; }
word _lines
: #lines _lines W@ ;
8 CELLS := bits/cell
pub line ( n -- a-addr ) CELLS universe + ;
CREATE #bits
$02.01.01.00 ,
$03.02.02.01 ,
$02.01.01.00 ,
$03.02.02.01 ,
long r0
long r1
: ROL3
2 AND r0 @ OR 1 ROL r0 !
1 ROL ROT 1 ROL ROT 1 ROL ROT --- next cell in each line --- 8.4us --- x1 x2 x3 revert to original after 32 ROLs
;
pub doline ( x1 x2 x3 -- x1 x2 x3 x4 ) --- 2.8ms
0 bits/cell FOR
r0 !
OVER 2 AND 0<> r1 !
( x1 x2 x3 )
DUP >N #bits + C@
( x1 x2 x3 y )
3RD >N #bits + C@ + --- note: cell itself is counted, too. correction below.
( x1 x2 x3 y )
4TH >N #bits + C@ +
( x1 x2 x3 y )
DUP 3 = ( x1 x2 x3 y y=3 ) SWAP 4 = ( x1 x2 x3 y=3 y=4 ) --- 5.8us
r1 @ AND OR ( x1 x2 x3 y=3|y=4&x2&2 )
ROL3
r0 @
NEXT
;
SDBUF $400 + := bufgen
--- testing creating variables in code space where we can initialize and also BACKUP
CREATE cvars 0 , 0 ,
cvars := generation
cvars 2 + := ng
cvars 3 + := syn
cvars 4 + := _exp
cvars 5 + := zoom
--- define default characters for alive and dead
'*' := live
$20 := dead
pub nextgen ( -- )
0 line @ #lines 1- line @ OVER ( s: line0 x1 x2 )
0 line
#lines 4* ADO
I 4+ @ ( s: line0 x1 x2 x3 )
doline I !
ROT DROP ( s: line0 x2 x3 )
4 +LOOP
--- special treatment for last line
ROT doline #lines 1- line !
3DROP
;
pub gentask
BEGIN
nextgen
syn C@ IF BEGIN ng C@ 0= UNTIL THEN --- wait until the previous buffer has been displayed
SDBUF bufgen #lines CELLS CMOVE
ng C~~
\ zoom C@ #lines <> IF zoom C@ #lines > IF EXPAND ELSE SHRINK THEN THEN
AGAIN
;
pub .line ( bit -- )
|< #lines 0 DO
I line @ OVER AND IF live ELSE dead THEN EMIT
LOOP DROP
;
CREATE uclrs $02.07.01.06 , ( cyan | red | white | green |
$20 := wall
yellow := border
pri .WALL border PAPER wall EMIT wall EMIT black PAPER ;
pri .HEAD border PAPER wall #lines 4+ EMITS black PAPER SPACE CRLF ;
pub SHOW ( -- ) \ print current life state to console
OFF CURSOR BOLD
HOME blue PAPER
." Conway's Game of Life - P2 TAQOZ " #lines PRINT
." x32 Generation #" generation W@ PRINT
." every " LAP .LAP 8 SPACES
CRLF PLAIN BOLD white PEN black PAPER
.HEAD
bits/cell 0 DO
.WALL
--- new color
generation W@ I + 3 AND uclrs + C@ PEN
I .line
white PEN .WALL SPACE CRLF
LOOP
.HEAD
PLAIN
;
--- commands ---
--- set terminal screen width for matrix
pub WIDE DUP zoom C!
pub WIDEa 16 MAX 512 MIN _lines W! ;
pub SHRINK #lines 1- WIDEa ;
pub WIDER #lines 1+ WIDEa 0 #lines 1- line ! ;
pub EXPAND WIDER universe DUP 4+ #lines 1- CELLS <CMOVE 0 0 line ! ;
--- modes
pub EXPANDING _exp C~~ ;
pub SYNCH ( on/off -- ) syn C! ;
--- PATTERN CREATION ---
pub VOID ( -- ) universe #lines CELLS ERASE ;
pub SEED ( x1 .. xn n -- ) FOR I line ! NEXT ;
--- some well known patterns:
pub GLIDER ( -- ) 7 1 2 3 SEED ;
pub FPENT ( -- ) 4 $0C 6 3 SEED ;
pub LWSS ( -- ) $0F $11 1 $12 4 SEED ;
pub DIEHARD $47 $C0 2 3 SEED ;
pub ACORN $67 8 $20 3 SEED ;
--- create a random pattern as a seed
--- usage: random life
\ pub BITS? ( n -- bits ) 0 BL 0 DO OVER I |< AND IF 1+ THEN LOOP NIP ;
pub RANDOM #lines FOR RND I line ! NEXT ;
--- Copy a pattern of longs from memory (such as ROM)
--- Usage: $E000 copy life
pub COPY ( src -- ) #lines FOR DUP @ I line ! 4+ NEXT DROP ;
pub MENU
SWITCH
'R' CASE RANDOM BREAK
'G' CASE GLIDER BREAK
'D' CASE DIEHARD BREAK
'A' CASE ACORN BREAK
'L' CASE LWSS BREAK
'F' CASE FPENT BREAK
'W' CASE WIDER BREAK
'E' CASE EXPAND BREAK
'<' CASE SHRINK BREAK
'>' CASE WIDER BREAK
$08 CASE VOID BREAK
$20 CASE WKEY DROP BREAK
CASE@ '1' '9' WITHIN IF CASE@ '0' - 4 << zoom W! THEN
;
pub LIFE
1 NEWCOG 5 ms ' gentask 1 TASK W!
generation ~
HOME LAP LAP
BEGIN
_exp C@ IF
0 line @ IF EXPAND THEN
#lines 1- line @ IF WIDER THEN
THEN
syn C@ IF BEGIN ng C@ UNTIL ng C~ THEN
SHOW generation W++
KEY MENU CASE@ $0D =
UNTIL
_exp C~
CRLF
syn C~~ ng C~~
;
pub DEMO
OFF CURSOR
CLS OFF SYNCH 64 WIDE
RANDOM
SHOW
LIFE
ON CURSOR
;
END
You can also add the code to change the P2 clock as well. Since TAQOZ doesn't actually know the baud rate it is running at when you first boot into it, you need to specify that before you change the clock frequency the first time. Say that you want to talk at 3M baud at 300 MHZ, this is all you need to do:
3 M CONBAUD TURBO
TAQOZ
long cb
pub CONBAUD ( baud -- ) DUP cb ! 63 PIN DUP RXD 62 PIN TXD ;
1,000,000 := 1M
\ *** P2 CLOCK CONTROL ***
( CLOCK MODES )
--- 1098_7654_321098_7654321098_7654_32_10
--- 0000_000E_DDDDDD_MMMMMMMMMM_PPPP_CC_SS
long _clk
long _fin
--- set the
pub CLKSET _clk @ HUBSET ;
( PLL should run between 100 to 200MHz )
--- Usage: 30 pf or 15 pf or 0 pf or -15 pf to disable
pri pf ( pf -- ) 15 / 1+ 3 AND 2 << $0C
pri CLK! ( data mask -- ) _clk @ SWAP ANDN OR _clk ! ;
pub PLLEN 24 |< _clk SET ;
pub PLLOFF 24 |< _clk CLR ;
pub XIDIV ( 1..64 -- ) 1- $3F AND 18 << $00FC0000 CLK! ;
( ends up as multiply)
pub VCOMUL ( 1..1024 -- ) 1- $3FF AND 8 << $3FF00 CLK! ;
--- Divide the PLL by 1 2 4 6 ... 30 for the system clock when SS = %11
pub PLLDIV ( 2..30 -- ) 2/ 1- $0F AND 4 << $0F0 CLK! ;
pub CLKSRC CLKSET DUP 1 > IF 200,000 WAITX THEN 3 AND 3 CLK! CLKSET ;
pub USEPLL 3 CLKSRC ;
pub USEXTAL 2 CLKSRC ;
pub RCSLOW 1 HUBSET _clk ~ ;
20,000,000 := _xin
--- Set P2 CLOCK to selected MHZ ( simple PLL settings only )
pub CLOCK ( HZ --- )
--- align to multiples of XIN
_xin U/ _xin *
pri CLOCK1
DUP ' CLKHZ 2+ ! _clk ~
--- defaults of 15pF and an XI divide of 1
15 pf PLLEN 1 XIDIV
--- then multiply up the base input frequency
CLKHZ _xin U/ VCOMUL
--- default PLL divider of 1 and enable
1 PLLDIV USEPLL
--- reload to calculate baud rate setting
cb @ CONBAUD
;
--- nominal rcfast freq ( Use <new value> ' RCFAST 2+ ! )
pub RCFAST 22,400,000 CLOCK1 0 HUBSET _clk ~ ;
pub P2MHZ M CLOCK ;
pub IDLE 40 P2MHZ ;
pub COAST 120 P2MHZ ;
pub CRUISE 180 P2MHZ ;
pub FAST 240 P2MHZ ;
pub TURBO 300 P2MHZ ;
END
Are those words all using space in the ROM, and fixed, or do you define that at run time ?
Seems they would be very rarely used, and who is going to remember what CRUISE or FAST or TURBO actually mean, in MHz ?
Are those words all using space in the ROM, and fixed, or do you define that at run time ?
Seems they would be very rarely used, and who is going to remember what CRUISE or FAST or TURBO actually mean, in MHz ?
Wot? You've never used shortcuts yourself?
The point is that these are the primitives and also some examples of using them. Even Chip did this with early Spin code as he'd have the object and the demo. The demo showed how the object could be used. In this case i type TURBO as a shortcut which only takes 4 code bytes but anyone can define their own or none.
Of course if i hadn't added these words some might not have understood fully just how easy it is to use. Even building up a totally different clock configuration using the individual fields is easy.
Anyway, turbo means faster than normal in anyone's dictionary.
@"Peter Jakacki" what are you working on next? I2c? Assembler?
I've been doing a lot with FAT32 including all the format and disk reporting utilities and file creation etc. Interestingly although the maximum size of a file in FAT32 is 4Gb less one byte, it is possible for a file to have a much larger space allocated through the cluster chain and why they didn't used the reserved byte after the attribute for another 8 bits of address is probably to be expected.
But you have reminded me about i2c so i might check this when i get back onto it.
there is a couple things I want to tackle with it
1. being able to track down what is changing in the source files take a look at this example
2. Having all the stuff at the same place
3. Allow other people to fix typos or errors
4. Allow other people to contribute new sample code, drivers, docs, etc...
5. Not having to rely on shared dropbox folders, so people can just clone the repo to access all the work
6. I would like to have the all the docs converted to markdown so it would display nicely on github and not rely on google docs or Microsoft word etc...
There is still a lot of work to do but I wanted at least something to start. Tell me what you think, if you think it is useful or if you have other ideas.
Hey Fred, i had a quick look and it looks good. Now i just need to see how i fit in with this environment
It's simple, just a couple steps to add to what you are already doing. First start by installing git command line tools.
#1 Open a terminal and navigate where you want to put your project
#2a (if the repository is not on your filesystem yet) clone it
git clone https://github.com/speccy88/taqoz
#2b (if the repository is already there) you need to check if there is no new work done by pulling the latest changes
git pull
#3 Work on your files
#4 When you are done, you can commit your commit and leave a note of what you did
git add .
git commit -m "i2c driver finally completed ;)"
#5 Push your local change to the github repo so that everyone can pull the latest changes
git push origin master
Hey Fred, i had a quick look and it looks good. Now i just need to see how i fit in with this environment
It's simple, just a couple steps to add to what you are already doing. First start by installing git command line tools.
Thanks, there are quite a few ways and I thank you also for your initiative. The problem is me, can I work and fit into an "office" with others vs just being "home" by myself
Comments
Didnt do much last night - painful result of dentist appt
I have to work today but now not working late.
Please, where is the latest test code?
The last kept outputting a message every ~1s
This is mainly for testing on the FPGA which is designed to accept a new ROM on power-up but subsequent resets will not reset the new ROM. My eval board has the reset cap removed so it requires a manual reset around the time that I am loading it. I think every Prop and P2 board should be able to disconnect the DTR from the reset but the P2 serial loader is not so critical of the reset to load time. I did use loadp2 to load the ROM onto my eval board and that seemed to worked fine. Normally I always use Dave Hein's p2asm and loadp2.
Next step is i2c and also I just received a W5500 module so I can test easynet and maybe try to get MQTT to work.
Yep, I just loaded everything including the kitchen sink on the P2D2 and I'm just loading up the new FPGA image that I need to check something on and then I will post the new ES image and update the Dropbox shortly.
Just rename P2.ROM to _BOOT_P2.BIX and copy onto your SD card or else you can use loadp2 to directly load P2.ROM onto the P2 serially.
I still need to add file creation support next so you can not only create a file but also preallocate clusters in terms of bytes for the file. Given that even if we had 1MB preallocatted per file and even if we somehow had 1000 files that would still only be 1GB used.
curious,
Mike
Could you please share the code you used for these modules?
It could be improved a lot but here is the bare minimum to display a string on the screen.
the sensor has a frequency output that I read with a smartpin
One of the things that we can do is create a lookup table rather than tackling decoding programmatically, that is exhausting a list of conditionals in this case. So it becomes a simple matter than to expand the array to include hex digits or even ASCII (with some awkward characters).
Have a look at this code that uses a table that is created using CREATE that simply returns its empty code address. We then compile values in after this and simply use the address it returns to index into the array of values and read them as bytes. I'm sure there is a better way of writing all 7/8 bits at a time rather than looping through them but it does make it simple especially since we set the pin to 1ma source just before we write the data, so there is no need for a special init routine. I left the extra % symbols in between the binary bytes as any symbol is allowed as a separator and this one is just as good as any. The idea was to pack them into words or longs since compiling non-word aligned values throws the compiling/execution off.
This code is setup with a default of pin 32 but you can change it at runtime using LEDPINS.
Here's a quick port of my version of LIFE that runs in an ANSI color terminal such as TeraTerm or minicom etc. Best to autobaud as high as you can go but I set minicom for 3M baud.
Look in the source at MENU to see what keys you can press to introduce patterns and change the width of the universe etc.
Copy and paste this code with a 10ms or so line delay.
Seems they would be very rarely used, and who is going to remember what CRUISE or FAST or TURBO actually mean, in MHz ?
Wot? You've never used shortcuts yourself?
The point is that these are the primitives and also some examples of using them. Even Chip did this with early Spin code as he'd have the object and the demo. The demo showed how the object could be used. In this case i type TURBO as a shortcut which only takes 4 code bytes but anyone can define their own or none.
Of course if i hadn't added these words some might not have understood fully just how easy it is to use. Even building up a totally different clock configuration using the individual fields is easy.
Anyway, turbo means faster than normal in anyone's dictionary.
I've been doing a lot with FAT32 including all the format and disk reporting utilities and file creation etc. Interestingly although the maximum size of a file in FAT32 is 4Gb less one byte, it is possible for a file to have a much larger space allocated through the cluster chain and why they didn't used the reserved byte after the attribute for another 8 bits of address is probably to be expected.
But you have reminded me about i2c so i might check this when i get back onto it.
Also any update on the P2D2 stuff? Response probably belongs in the other thread.
https://github.com/speccy88/TAQOZ
there is a couple things I want to tackle with it
1. being able to track down what is changing in the source files take a look at this example
2. Having all the stuff at the same place
3. Allow other people to fix typos or errors
4. Allow other people to contribute new sample code, drivers, docs, etc...
5. Not having to rely on shared dropbox folders, so people can just clone the repo to access all the work
6. I would like to have the all the docs converted to markdown so it would display nicely on github and not rely on google docs or Microsoft word etc...
There is still a lot of work to do but I wanted at least something to start. Tell me what you think, if you think it is useful or if you have other ideas.
it is a work in progress
@HydraHacker would you like to contribute your Guess game in the repo?
@twm47099 would you like to host the code you have done so far?
It's simple, just a couple steps to add to what you are already doing. First start by installing git command line tools.
Thanks, there are quite a few ways and I thank you also for your initiative. The problem is me, can I work and fit into an "office" with others vs just being "home" by myself