OSDN Git Service

V207 Unlocking IO's moved from COLD to WARM
[fast-forth/master.git] / MSP430-FORTH / SD_TEST.f
1 \ TARGET SELECTION
2 \ MSP_EXP430FR5739  MSP_EXP430FR5969    MSP_EXP430FR5994    MSP_EXP430FR6989
3 \ MSP_EXP430FR4133  MSP_EXP430FR2433    MSP_EXP430FR2355    CHIPSTICK_FR2433
4 \
5
6 ; -----------
7 ; SD_TEST.f
8 ; -----------
9 \
10 \ how to test SD_CARD driver on your launchpad:
11 \
12 \
13 \ remove the jumpers RX, TX of programming port (don't remove GND, TST, RST and VCC)
14 \ wire PL2303TA/HXD: GND <-> GND, RX <-- TX, TX --> RX
15 \ connect it to your PC on a free USB port
16 \ connect the PL2303TA/HXD cable to your PC on another free USB port
17 \ configure TERATERM as indicated in forthMSP430FR.asm
18 \
19 \
20 \ if you have a MSP-EXP430FR5994 launchpad, program it with MSP_EXP430FR5994_3Mbds_SD_CARD.txt
21 \ to do, drag and drop this file onto prog.bat
22 \ nothing else to do!
23 \
24 \
25 \ else edit forthMSP430FR.asm with scite editor
26 \   uncomment your target, copy it
27 \   paste it into (SHIFT+F8) param1
28 \   set DTC .equ 1
29 \       FREQUENCY   .equ 16
30 \       THREADS     .equ 16
31 \       TERMINALBAUDRATE    .equ 3000000
32 \         
33 \   uncomment:  CONDCOMP
34 \               MSP430ASSEMBLER
35 \               SD_CARD_LOADER
36 \               SD_CARD_READ_WRITE
37
38 \   compile for your target (CTRL+0)
39 \
40 \   program your target via TI interface (CTRL+1)
41 \
42 \   then wire your SD_Card module as described in your MSP430-FORTH\target.pat file
43 \
44 \
45 \
46 \ format FAT16 or FAT32 a SD_CARD memory (max 64GB) with "FRxxxx" in the disk name
47 \ drag and drop \MSP430_COND\MISC folder on the root of this SD_CARD memory (FastForth doesn't do yet)
48 \ put it in your target SD slot
49 \ if no reset, type COLD from the console input (teraterm) to reset FAST FORTH
50 \
51 \ with MSP430FR5xxx or MSP430FR6xxx targets, you can first set RTC:
52 \ by downloading RTC.f with SendSourceFileToTarget.bat
53 \ then terminal input asks you to type (with spaces) (DMY), then (HMS),
54 \ So, subsequent copied files will be dated:
55 \
56 \ with CopySourceFileToTarget_SD_Card.bat (or better, from scite editor, menu tools):
57 \
58 \   copy TESTASM.4TH        to \MISC\TESTASM.4TH    (add path \MISC in the window opened by TERATERM)
59 \   copy TSTWORDS.4TH       to \TSTWORDS.4TH
60 \   copy CORETEST_xMPY.4TH  to \CORETEST.4TH        (x=S for FR4133, else x=H; suppr _xMPY in the window opened by TERATERM)
61 \   copy SD_TOOLS.f         to \SD_TOOLS.4TH
62 \   copy SD_TEST.f          to \SD_TEST.4TH
63 \   copy PROG100k.f         to \PROG100k.4TH
64 \   copy RTC.f              to \RTC.4TH             ( doesn't work with if FR2xxx or FR4xxx)
65
66 PWR_STATE
67
68 [DEFINED] {SD_TEST} [IF] {SD_TEST} [THEN]   \ remove {SD_TEST} 
69
70 [DEFINED] ASM [DEFINED] TERM2SD" AND [IF]   \ requirements test
71
72 MARKER {SD_TEST}
73
74 [UNDEFINED] MAX [IF]    \ MAX and MIN are defined in {ANS_COMP}
75     CODE MAX    \    n1 n2 -- n3       signed maximum
76         CMP @PSP,TOS    \ n2-n1
77         S< ?GOTO FW1    \ n2<n1
78     BW1 ADD #2,PSP
79         MOV @IP+,PC
80     ENDCODE
81
82     CODE MIN    \    n1 n2 -- n3       signed minimum
83         CMP @PSP,TOS    \ n2-n1
84         S< ?GOTO BW1    \ n2<n1
85     FW1 MOV @PSP+,TOS
86         MOV @IP+,PC
87     ENDCODE
88 [THEN]
89
90 [UNDEFINED] U.R [IF]    \ defined in {UTILITY}
91 : U.R                       \ u n --           display u unsigned in n width (n >= 2)
92 >R  <# 0 # #S #>  
93 R> OVER - 0 MAX SPACES TYPE
94 ;
95 [THEN]
96
97 [UNDEFINED] DUMP [IF]    \ defined in {UTILITY}
98 \ https://forth-standard.org/standard/tools/DUMP
99 CODE DUMP                   \ adr n  --   dump memory
100 PUSH IP
101 PUSH &BASE                  \ save current base
102 MOV #$10,&BASE              \ HEX base
103 ADD @PSP,TOS                \ -- ORG END
104 LO2HI
105   SWAP OVER OVER            \ -- END ORG END ORG 
106   U. 1 - U.                 \ -- END ORG        display org end-1  
107   $FFF0 AND                 \ -- END ORG_modulo_16
108   DO  CR                    \ generate line
109     I 7 U.R SPACE           \ generate address
110       I $10 + I             \ display 16 bytes
111       DO I C@ 3 U.R LOOP  
112       SPACE SPACE
113       I $10 + I             \ display 16 chars
114       DO I C@ $7E MIN BL MAX EMIT LOOP
115   $10 +LOOP
116   R> BASE !                 \ restore current base
117 ;
118 [THEN]
119
120 : SD_TEST
121 \ BEGIN
122     ECHO CR
123     ."    0 Set date and time" CR
124     ."    1 Load {UTILITY} words" CR
125     ."    2 Load {SD_TOOLS} words" CR
126     ."    3 Load {ANS_COMP} words" CR
127     ."    4 Load ANS core tests" CR
128     ."    5 Load a 100k program " CR
129     ."    6 Read only this source file" CR
130     ."    7 Write a dump of FORTH to YOURFILE.TXT" CR
131     ."    8 append a dump of FORTH to YOURFILE.TXT" CR
132     ."    9 Load TST_WORDS" CR
133     ."    your choice : "
134     KEY CR
135     48 - ?DUP
136     0= IF
137         LOAD" RTC.4TH"
138     ELSE 1 - ?DUP
139         0= IF
140             LOAD" UTILITY.4TH"
141         ELSE 1 - ?DUP
142             0= IF
143                 LOAD" SD_TOOLS.4TH"
144             ELSE 1 - ?DUP
145                 0= IF
146                     LOAD" ANS_COMP.4TH"
147                 ELSE 1 - ?DUP
148                     0= IF
149                         LOAD" CORETEST.4TH"
150                         PWR_STATE   \ remove words
151                     ELSE 1 - ?DUP
152                         0= IF
153                             NOECHO
154                             LOAD" PROG100K.4TH"
155                             PWR_STATE   \ remove words
156                             ECHO
157                         ELSE 1 - ?DUP
158                             0= IF
159                                 READ" PROG100K.4TH"
160                                 BEGIN
161                                     READ    \ sequentially read 512 bytes
162                                 UNTIL       \ prog10k.4TH is closed
163                             ELSE 1 - ?DUP
164                                 0= IF
165                                     DEL" YOURFILE.TXT"
166                                     WRITE" YOURFILE.TXT"
167                                     ['] SD_EMIT IS EMIT
168                                     PROGRAMSTART HERE OVER - DUMP
169                                     ['] EMIT >BODY IS EMIT
170                                     CLOSE
171                                 ELSE 1 - ?DUP
172                                     0= IF
173                                         WRITE" YOURFILE.TXT"
174                                         ['] SD_EMIT IS EMIT
175                                         CR
176                                         PROGRAMSTART HERE OVER - DUMP
177                                         ['] EMIT >BODY IS EMIT
178                                         CLOSE
179                                     ELSE 1 - ?DUP
180                                         0= IF
181                                             LOAD" TSTWORDS.4TH"
182                                         ELSE
183                                             DROP EXIT
184                                         THEN                                        
185                                     THEN
186                                 THEN
187                             THEN
188                         THEN
189                     THEN
190                 THEN
191             THEN
192         THEN
193     THEN
194     ECHO ."    it's done"
195
196 \ AGAIN          \ LOAD" don't work with loop tests.......
197 ;
198
199 PWR_HERE \ to don't forget, otherwise SD_TEST destroys itself by downloading files comprising "PWR_HERE" command...
200
201 [THEN]
202
203 SD_TEST