en:pfw:dht22-msp430g2553-noforth
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:pfw:dht22-msp430g2553-noforth [2025-04-25 01:11] – mka | en:pfw:dht22-msp430g2553-noforth [2025-04-26 21:15] (current) – mka | ||
---|---|---|---|
Line 1: | Line 1: | ||
< | < | ||
- | \ Read DHT22 (bitbang) | + | \ Read DHT22 data. (bit bang) |
\ TI MSP430G2553 Launchpad with noForth mv 2553 240101 | \ TI MSP430G2553 Launchpad with noForth mv 2553 240101 | ||
(* | (* | ||
- | To do: timeout | + | To do: monitor |
History | History | ||
- | V0065 - Temperature in tenths of a degree. mk 20250424 | + | v0066 - Display negative temperatures correctly. |
- | V0064 - Loops named with ( A ) ... ( D ). Variants of loops B and D studied. | + | V0065 - Represent |
+ | V0064 - Loops named with ( A ) ... ( D ). Variants of loops B and D studied. | ||
V0063 - Cleaned up the code. Data output reduced to the essentials. mk 20250421 02:04 | V0063 - Cleaned up the code. Data output reduced to the essentials. mk 20250421 02:04 | ||
V0062 - Works well, output rounded to whole digits. mk 20250419 21:51 | V0062 - Works well, output rounded to whole digits. mk 20250419 21:51 | ||
Line 28: | Line 29: | ||
026 P1SEL Port Select | 026 P1SEL Port Select | ||
041 P1SEL2 | 041 P1SEL2 | ||
- | 027 P1REN | + | 027 P1REN |
*) | *) | ||
Line 36: | Line 37: | ||
hex | hex | ||
- | \ helper | + | \ tools |
code cls ( -- ) s0 # sp mov next end-code | code cls ( -- ) s0 # sp mov next end-code | ||
code p1H #1 021 & .b bis next end-code \ set lines | code p1H #1 021 & .b bis next end-code \ set lines | ||
- | code p1L #1 021 & .b bic next end-code | + | code p1L #1 021 & .b bic next end-code |
- | code p6H 40 # 021 & .b bis next end-code | + | code p6H 40 # 021 & .b bis next end-code |
- | code p6L 40 # 021 & .b bic next end-code | + | code p6L 40 # 021 & .b bic next end-code |
Line 57: | Line 58: | ||
pio p1H p6H 1 ms p1L 10 ms ( p6L ) p1H ; \ 1 ms == 100┬Ás ! | pio p1H p6H 1 ms p1L 10 ms ( p6L ) p1H ; \ 1 ms == 100┬Ás ! | ||
- | Code @data ( -- sun moon hum tmp chk chksum ) \ read sensor data | + | Code @data ( -- sun moon |
+ | \ i.e ( -- sun moon hum tmp chk chksum ) | ||
\ get response time | \ get response time | ||
#1 022 & .b bic \ p1,0 IN | #1 022 & .b bic \ p1,0 IN | ||
Line 154: | Line 156: | ||
; | ; | ||
- | : .tmp ( tmp -- ) | + | |
- | 10 /mod 3 .r [char] | + | : .tmp ( tmp -- ) \ Print temperature with sign, one decimal place and degree symbol |
+ | dup hx 8000 and hx 8000 = | ||
+ | if [char] - else [char] + then emit | ||
+ | hx 7fff and ( tmp -- +tmp ) | ||
+ | 10 /mod 3 .r [char] | ||
[char] f decemit | [char] f decemit | ||
[char] C emit space | [char] C emit space | ||
- | ; | + | ; |
| | ||
- | : .hum ( hum -- ) \ rounded to whole percent | + | : .hum ( hum -- ) \ Print the relative humidity |
10 / . ." %rel" space | 10 / . ." %rel" space | ||
; | ; | ||
- | : dht22 ( -- ) \ print temperatur and humidity | + | : dht22 ( -- ) \ get temperatur and humidity |
cr (dht22) | cr (dht22) | ||
= if ." chk " else ." chksum error" cls exit then | = if ." chk " else ." chksum error" cls exit then |
en/pfw/dht22-msp430g2553-noforth.1745536286.txt.gz · Last modified: 2025-04-25 01:11 by mka