Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

We want to create puppets that pull their own strings. -- Ann Marion


devel / comp.lang.forth / Re: [Mecrisp Stellaris] Compiling words?

SubjectAuthor
* [Mecrisp Stellaris] Compiling words?Niclas Hedhman
`* Re: [Mecrisp Stellaris] Compiling words?Niclas Hedhman
 `- Re: [Mecrisp Stellaris] Compiling words?Niclas Hedhman

1
[Mecrisp Stellaris] Compiling words?

<db0d53d8-16ac-4dc5-a205-4abe65803e05n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24449&group=comp.lang.forth#24449

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:1c7:b0:410:9eec:9fb3 with SMTP id t7-20020a05622a01c700b004109eec9fb3mr734083qtw.8.1693154317168;
Sun, 27 Aug 2023 09:38:37 -0700 (PDT)
X-Received: by 2002:a05:6a00:1888:b0:68a:58e1:ebf9 with SMTP id
x8-20020a056a00188800b0068a58e1ebf9mr6933789pfh.2.1693154316800; Sun, 27 Aug
2023 09:38:36 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sun, 27 Aug 2023 09:38:36 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=2001:9b0:27c:6500:b26e:bfff:fe2b:62a5;
posting-account=0tV0CAoAAACOsV2rI1_-S8Y9mLjUiOgZ
NNTP-Posting-Host: 2001:9b0:27c:6500:b26e:bfff:fe2b:62a5
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <db0d53d8-16ac-4dc5-a205-4abe65803e05n@googlegroups.com>
Subject: [Mecrisp Stellaris] Compiling words?
From: hedhman@gmail.com (Niclas Hedhman)
Injection-Date: Sun, 27 Aug 2023 16:38:37 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2892
 by: Niclas Hedhman - Sun, 27 Aug 2023 16:38 UTC

Hi,

I want to interface with a WS2812, and I have set up the MCU so that I can simply send $88, $8C, $C8, $CC (for 00,01,10,11) twelve times to get the 24 bits in the RGB LED wire "protocol".

So, if I do;

: off $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi ;

I can set the LED to off. There is not enough time to keep that in an array, loop and read out each on the fly, and DMA has a side-effect that makes it not possible to use for this LED on this MCU, so I thought I should just generate the code;

: rgb ( rgb -- )( -- )
create split-rgb (ws2812b) (ws2812b) (ws2812b)
does> execute ;
;

where "split-rgb" breaks the rgb into r g b and then "(ws2812b)" loops through the 8 bits to generate the word. So, usage would be

$0 rgb off
$FFFF rgb warning

and in the background the "off" word executes the same way as the defined word above.

This is nothing I have done before and don't grok how I inject "call this particular word" into the dictionary body.

I think that I can "literal," to pop the computed byte from TOS into the dictionary so that when it is executed it pushes that value onto stack. But how do I do the same for a word to execute?

Any help/pointer would be greatly appreciated.

Niclas

P.S. for reference, I the (ws2812b) will look something like;

: (ws2812b) ( n -- )
#24 lshift \ move all bits up
4 0 do
rol rol \ shift in next two bits
dup 3 and
case
0 of $88 endof
1 of $C8 endof
2 of $8C endof
3 of $CC endof
endcase
literal, \ <-- I need a "add execute '>spi' to dictionary" here
loop
drop
;

Re: [Mecrisp Stellaris] Compiling words?

<30202b6f-691a-4633-91ae-5a161c89d381n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24456&group=comp.lang.forth#24456

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:309:b0:40f:e2a5:3100 with SMTP id q9-20020a05622a030900b0040fe2a53100mr870567qtw.6.1693206322555;
Mon, 28 Aug 2023 00:05:22 -0700 (PDT)
X-Received: by 2002:a17:902:ea04:b0:1b7:c944:edd4 with SMTP id
s4-20020a170902ea0400b001b7c944edd4mr8458067plg.2.1693206321984; Mon, 28 Aug
2023 00:05:21 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 28 Aug 2023 00:05:21 -0700 (PDT)
In-Reply-To: <db0d53d8-16ac-4dc5-a205-4abe65803e05n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:9b0:27c:6500:b26e:bfff:fe2b:62a5;
posting-account=0tV0CAoAAACOsV2rI1_-S8Y9mLjUiOgZ
NNTP-Posting-Host: 2001:9b0:27c:6500:b26e:bfff:fe2b:62a5
References: <db0d53d8-16ac-4dc5-a205-4abe65803e05n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <30202b6f-691a-4633-91ae-5a161c89d381n@googlegroups.com>
Subject: Re: [Mecrisp Stellaris] Compiling words?
From: hedhman@gmail.com (Niclas Hedhman)
Injection-Date: Mon, 28 Aug 2023 07:05:22 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Niclas Hedhman - Mon, 28 Aug 2023 07:05 UTC

[SOLVED!]

The words that I found by studying the "codegenerator-m3.s" source were;
call,
[']
ret,

Now I just need to get the bits in the stream in the right order, and will post the solution later...

Cheers
Niclas

On Sunday, August 27, 2023 at 6:38:38 PM UTC+2, Niclas Hedhman wrote:
> Hi,
>
> I want to interface with a WS2812, and I have set up the MCU so that I can simply send $88, $8C, $C8, $CC (for 00,01,10,11) twelve times to get the 24 bits in the RGB LED wire "protocol".
>
> So, if I do;
>
> : off $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi $88 >spi ;
>
> I can set the LED to off. There is not enough time to keep that in an array, loop and read out each on the fly, and DMA has a side-effect that makes it not possible to use for this LED on this MCU, so I thought I should just generate the code;
>
> : rgb ( rgb -- )( -- )
> create split-rgb (ws2812b) (ws2812b) (ws2812b)
> does> execute ;
> ;
>
> where "split-rgb" breaks the rgb into r g b and then "(ws2812b)" loops through the 8 bits to generate the word. So, usage would be
>
> $0 rgb off
> $FFFF rgb warning
>
> and in the background the "off" word executes the same way as the defined word above.
>
> This is nothing I have done before and don't grok how I inject "call this particular word" into the dictionary body.
>
> I think that I can "literal," to pop the computed byte from TOS into the dictionary so that when it is executed it pushes that value onto stack. But how do I do the same for a word to execute?
>
> Any help/pointer would be greatly appreciated.
>
> Niclas
>
>
> P.S. for reference, I the (ws2812b) will look something like;
>
> : (ws2812b) ( n -- )
> #24 lshift \ move all bits up
> 4 0 do
> rol rol \ shift in next two bits
> dup 3 and
> case
> 0 of $88 endof
> 1 of $C8 endof
> 2 of $8C endof
> 3 of $CC endof
> endcase
> literal, \ <-- I need a "add execute '>spi' to dictionary" here
> loop
> drop
> ;

Re: [Mecrisp Stellaris] Compiling words?

<c276ca80-8fa7-4e21-847f-d8b096faefcbn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24457&group=comp.lang.forth#24457

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:22c1:b0:76f:734:5677 with SMTP id o1-20020a05620a22c100b0076f07345677mr139203qki.15.1693207575075;
Mon, 28 Aug 2023 00:26:15 -0700 (PDT)
X-Received: by 2002:a05:620a:25b:b0:76f:2d1:dc21 with SMTP id
q27-20020a05620a025b00b0076f02d1dc21mr326078qkn.1.1693207574820; Mon, 28 Aug
2023 00:26:14 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 28 Aug 2023 00:26:14 -0700 (PDT)
In-Reply-To: <30202b6f-691a-4633-91ae-5a161c89d381n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:9b0:27c:6500:b26e:bfff:fe2b:62a5;
posting-account=0tV0CAoAAACOsV2rI1_-S8Y9mLjUiOgZ
NNTP-Posting-Host: 2001:9b0:27c:6500:b26e:bfff:fe2b:62a5
References: <db0d53d8-16ac-4dc5-a205-4abe65803e05n@googlegroups.com> <30202b6f-691a-4633-91ae-5a161c89d381n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c276ca80-8fa7-4e21-847f-d8b096faefcbn@googlegroups.com>
Subject: Re: [Mecrisp Stellaris] Compiling words?
From: hedhman@gmail.com (Niclas Hedhman)
Injection-Date: Mon, 28 Aug 2023 07:26:15 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Niclas Hedhman - Mon, 28 Aug 2023 07:26 UTC

On Monday, August 28, 2023 at 9:05:23 AM UTC+2, Niclas Hedhman wrote:
> [SOLVED!]
>
> The words that I found by studying the "codegenerator-m3.s" source were;
> call,
> [']
> ret,
>
> Now I just need to get the bits in the stream in the right order, and will post the solution later...

: (neopixel) ( n -- )
#24 lshift \ move all bits up
4 0 do
rol rol \ shift in next two bits
dup 3 and ( input masked )
case
0 of $88 endof
1 of $C8 endof
2 of $8C endof
3 of $CC endof
endcase
literal, \ compile top of stack (TOS) as a literal to word being defined
['] >spi \ address of ">spi" to TOS
call, \ compile a call to the address on TOS
loop
drop
;

: split-rgb ( rgb -- b r g )
dup $FF and swap ( blue )
dup #16 rshift $FF and swap ( red )
#8 rshift $FF and ( green )
;

: rgb ( rgb -- )( -- )
<builds
split-rgb \ convert 24 bits into three 8bits in order of b r g (green on TOS)
(neopixel) \ generate bitstream for green
(neopixel) \ generate bitstream for red
(neopixel) \ generate bitstream for blue
ret, \ generate a return
does> execute
;

For those interested, the Neopixel (WS2812B) is connected to the MOSI pin on SPI1 and that is set to 4Mbits/sec and 16bit mode. ">spi" simply check that the previous transfer is complete and the write directly to the SPI1-DR register.
I don't recommend using the MOSI for interfacing with the WS2812B. In my case; if I use DMA, then the MOSI pin ends up "high" and with a small delay between DMA transfers, this "high" becomes a bit. This doesn't happen when writing directly to the SPI1-DR register. One should instead use a Timer+DMA to get the bitstream, for more precise control.

BTW; this is done on STM32WLE5 and a Mecrisp Stellaris variant in parallel with CubeMX from ST, and FreeRTOS in place. See https://github.com/niclash/colibri-1dp-mcu1 for full codebase (Work in progress, as LoraWAN part is still having issues, but the Forth side feels quite solid.)

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor