OSDN Git Service

V2.0
[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  CHIPSTICK_FR2433
5
6 \ MY_MSP430FR5738_1 MY_MSP430FR5738     MY_MSP430FR5948     MY_MSP430FR5948_1   
7
8
9 \ how to test SD_CARD driver on your launchpad:
10
11
12 \ remove the jumpers RX, TX of programming port (don't remove GND, TST, RST and VCC)
13 \ wire PL2303TA/HXD: GND <-> GND, RX <-- TX, TX --> RX
14 \ connect it to your PC on a free USB port
15 \ connect the PL2303TA/HXD cable to your PC on another free USB port
16 \ configure TERATERM as indicated in forthMSP430FR.asm
17
18
19 \ if you have a MSP-EXP430FR5994 launchpad, program it with MSP_EXP430FR5994_3Mbds_SD_CARD.txt
20 \ to do, drag and drop this file onto prog.bat
21 \ nothing else to do!
22
23
24 \ else edit forthMSP430FR.asm with scite editor
25 \   uncomment your target, copy it
26 \   paste it into (SHIFT+F8) param1
27 \   set DTC .equ 1
28 \       FREQUENCY   .equ 16
29 \       THREADS     .equ 16
30 \       TERMINALBAUDRATE    .equ 3000000
31 \         
32 \   uncomment:  CONDCOMP
33 \               MSP430ASSEMBLER
34 \               SD_CARD_LOADER
35 \               SD_CARD_READ_WRITE
36
37 \   compile for your target (CTRL+0)
38 \
39 \   program your target via TI interface (CTRL+1)
40 \
41 \   then wire your SD_Card module as described in your MSP430-FORTH\target.pat file
42
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) (or (HM)),
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
75 [UNDEFINED] MAX [IF]    \ MAX and MIN are defined in {ANS_COMP}
76     CODE MAX    \    n1 n2 -- n3       signed maximum
77         CMP @PSP,TOS    \ n2-n1
78         S< ?GOTO FW1    \ n2<n1
79     BW1 ADD #2,PSP
80         MOV @IP+,PC
81     ENDCODE
82     \
83
84     CODE MIN    \    n1 n2 -- n3       signed minimum
85         CMP @PSP,TOS    \ n2-n1
86         S< ?GOTO BW1    \ n2<n1
87     FW1 MOV @PSP+,TOS
88         MOV @IP+,PC
89     ENDCODE
90 [THEN]
91     \
92
93
94 [UNDEFINED] U.R [IF]    \ defined in {UTILITY}
95 : U.R                       \ u n --           display u unsigned in n width (n >= 2)
96 >R  <# 0 # #S #>  
97 R> OVER - 0 MAX SPACES TYPE
98 ;
99 [THEN]
100     \
101
102 [UNDEFINED] DUMP [IF]    \ defined in {UTILITY}
103 \ https://forth-standard.org/standard/tools/DUMP
104 CODE DUMP                   \ adr n  --   dump memory
105 PUSH IP
106 PUSH &BASE                  \ save current base
107 MOV #$10,&BASE              \ HEX base
108 ADD @PSP,TOS                \ -- ORG END
109 LO2HI
110   SWAP OVER OVER            \ -- END ORG END ORG 
111   U. 1 - U.                 \ -- END ORG        display org end-1  
112   $FFF0 AND                 \ -- END ORG_modulo_16
113   DO  CR                    \ generate line
114     I 7 U.R SPACE           \ generate address
115       I $10 + I             \ display 16 bytes
116       DO I C@ 3 U.R LOOP  
117       SPACE SPACE
118       I $10 + I             \ display 16 chars
119       DO I C@ $7E MIN BL MAX EMIT LOOP
120   $10 +LOOP
121   R> BASE !                 \ restore current base
122 ;
123 [THEN]
124     \
125
126 : SD_TEST
127     ECHO CR
128     ."    1 Load {UTILITY} words" CR
129     ."    2 Load {ANS_COMP} words" CR
130     ."    3 Load ANS core tests" CR
131     ."    4 Load a 100k program " CR
132     ."    5 Read only this source file" CR
133     ."    6 Write a dump of FORTH to YOURFILE.TXT" CR
134     ."    7 append a dump of FORTH to YOURFILE.TXT" CR
135     ."    8 Load truc (test error)" CR
136     ."    9 Set date and time" CR
137     ."    your choice : "
138     KEY
139     48 - 
140     DUP 1 = 
141     IF  .
142         LOAD" UTILITY.4TH"
143     ELSE DUP 2 =
144         IF  .
145             LOAD" ANS_COMP.4TH"
146         ELSE DUP 3 =
147             IF  .
148                 LOAD" CORETEST.4TH"
149             ELSE DUP 4 =
150                 IF  .
151                     NOECHO LOAD" PROG100K.4TH"
152                 ELSE DUP 5 =
153                     IF  .
154                         READ" PROG100K.4TH"
155                         BEGIN
156                             READ    \ sequentially read 512 bytes
157                         UNTIL       \ prog10k.4TH is closed
158                     ELSE DUP 6 =
159                         IF  .
160                             DEL" YOURFILE.TXT"
161                             WRITE" YOURFILE.TXT"
162                             ['] SD_EMIT IS EMIT
163                             ." DUMP "
164                             PROGRAMSTART HERE OVER - DUMP
165                             ['] (EMIT) IS EMIT
166                             CLOSE
167                         ELSE DUP 7 =
168                             IF  .
169                                 WRITE" YOURFILE.TXT"
170                                 ['] SD_EMIT IS EMIT
171                                 CR ." DUMP "
172                                 PROGRAMSTART HERE OVER - DUMP
173                                 ['] (EMIT) IS EMIT
174                                 CLOSE
175                             ELSE DUP 8 =
176                                 IF  .
177                                     LOAD" truc"
178                                 ELSE DUP 9 =
179                                     IF  .
180                                         NOECHO LOAD" RTC.4TH" \ quiet downloading...
181                                     ELSE 
182                                         DROP ." ?"
183                                         CR ."    loading TSTWORDS.4TH..."
184                                         LOAD" TSTWORDS.4TH"
185                                     THEN
186                                 THEN
187                             THEN
188                         THEN
189                     THEN
190                 THEN
191             THEN
192         THEN
193     THEN
194 ." it's done"
195 ;
196     \
197
198
199 [THEN]
200     \
201 PWR_HERE
202     \
203 SD_TEST