OSDN Git Service

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