LowLevelFunc430Xv2.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32 */
33 /*==========================================================================*\
34 | |
35 | LowLevelFunc430Xv2.h |
36 | |
37 | Low Level function prototypes, macros, and pin-to-signal assignments |
38 | regarding to user's hardware |
39 |----------------------------------------------------------------------------|
40 | Project: MSP430 Replicator |
41 | Developed using: IAR Embedded Workbench 6.20 |
42 | and: Code Composer Studio 6.0 |
43 |----------------------------------------------------------------------------|
44 | Version history: |
45 | 1.0 04/02 FRGR Initial version. |
46 | 1.1 04/02 FRGR Included SPI mode to speed up shifting function by 2.|
47 | (JTAG control now on Port5) |
48 | 1.2 06/02 ALB2 Formatting changes, added comments. Removed code used|
49 | for debug purposes during development. |
50 | 1.3 08/02 ALB2 Initial code release with Lit# SLAA149. |
51 | 1.4 09/05 SUN1 Software delays redesigned to use TimerA harware; |
52 | see MsDelay() routine. Added TA constant. |
53 | 1.5 12/05 STO Added RESET pin definition |
54 | 1.6 03/08 WLUT Removed reference to JTAGfunc430X.h file |
55 | Added data format definitions |
56 | 1.7 08/08 WLUT Added macros for RST and TEST pin handling |
57 | Added macros for Spy-Bi-Wire capability. |
58 | 1.8 10/08 WLUT Fixed macro DrvSignals to drive correct signals |
59 | for Spy-Bi-Wire. |
60 | 1.9 05/09 GC (Elprotronic) Added support for the new hardware - REP430F |
61 | 2.0 10/11 FB Added support for JSBW functions |
62 | 2.1 06/12 RL Updated commentaries |
63 |----------------------------------------------------------------------------|
64 | Designed 2002 by Texas Instruments Germany |
65 \*==========================================================================*/
68 /****************************************************************************/
69 /* INCLUDES */
70 /****************************************************************************/
71 
72 #include "Config430FR.h" // High-level user input
73 #include <msp430x54x.h>
74 
75 /****************************************************************************/
76 /* DEFINES & CONSTANTS */
77 /****************************************************************************/
78 
80 #define SPYBIWIREJTAG_IF 1
81 #define SPYBIWIRE_IF 2
83 
84 #if( INTERFACE == SPYBIWIRE_IF )
85 #define SPYBIWIRE_MODE
86 #else
87 #define JSBW
88 #endif
89 
90 #define RSTLOW_SBW 0
91 #define RSTLOW_JTAG 1
92 #define RSTHIGH_SBW 2
93 #define RSTHIGH_JTAG 3
94 
95 #ifndef __DATAFORMATS__
96 #define __DATAFORMATS__
97 #define F_BYTE 8
98 #define F_WORD 16
99 #define F_ADDR 20
100 #define F_LONG 32
101 #endif
102 
103 // Constants for runoff status
105 #define STATUS_ERROR 0 // false
106 #define STATUS_OK 1 // true
108 #define STATUS_FUSEBLOWN 2
110 
112 #define STATUS_ACTIVE 2
113 #define STATUS_IDLE 3
115 
116 /****************************************************************************/
117 /* Pin-to-Signal Assignments */
118 /****************************************************************************/
119 
120 // I/O Level translators (SN74LVC1T45) direction setup
121 
122 #define TRSLDIR P2OUT
123 
124 #define TRSL_CDIR P2DIR
125 
128 #define BRX_DIR 0x01
129 #define BTX_DIR 0x02
132 #define TEST_DIR 0x04
134 #define RST_DIR 0x08
136 #define TCK_DIR 0x10
138 #define TMS_DIR 0x20
140 #define TDOI_DIR 0x40
142 #define TDI_DIR 0x80
144 
145 #define SW_OUT P1OUT
146 #define SW_IN P1IN
147 #define SW_DIR P1DIR
148 #define SW_PULLUP P1REN
149 #define LED_OUT P1OUT
151 #define LED_DIR P1DIR
153 
155 #define SW_MODE0 0x01
156 #define SW_MODE1 0x02
158 #define SW_VPPEN 0x04
160 #define LED_YELLOW 0x08
162 #define LED_GREEN 0x10
164 #define LED_RED 0x20
166 #define SW_1 0x40
168 
169 //#define spareP17 0x80
170 
172 #define TVCC_OUT P6OUT
173 #define TVCC_DIR P6DIR
175 #define TVCC_MASK 0xF0
177 #define TVCC_SHIFT 4
179 
180 #define TVCC_EN_DIR P5DIR
181 #define TVCC_EN_OUT P5OUT
182 #define TVCC_DIS_BIT 1
183 
185 #define LED_yellow_on() ( LED_OUT |= LED_YELLOW )
186 #define LED_yellow_off() ( LED_OUT &= ~LED_YELLOW )
188 #define LED_red_on() ( LED_OUT |= LED_RED )
190 #define LED_red_off() ( LED_OUT &= ~LED_RED )
192 #define LED_green_on() ( LED_OUT |= LED_GREEN )
194 #define LED_green_off() ( LED_OUT &= ~LED_GREEN )
196 #define All_LEDs_off() ( LED_OUT &= ~(LED_GREEN | LED_RED | LED_YELLOW ))
198 
199 // JTAG ports are P5.x
201 #define JTAGOUT P5OUT
202 #define JTAGIN P5IN
204 #define JTAGDIR P5DIR
206 #define JTAGSEL P5SEL
208 #define TMS 0x20
210 #define TDI 0x80
212 #define TDO 0x40
214 #define TCK 0x10
216 #define TEST 0x04
218 #define RST 0x08
220 #define TCLK TDI
222 
225 #define BSLOUT P3OUT
226 #define BSLIN P3IN
229 #define BSLDIR P3DIR
232 #define BSLSEL P3SEL
235 #define BSLTX 0x20
238 #define BSLRX 0x10
241 
242 // VPP ports are P8.x
244 #define VPPOUT P8OUT
245 #define VPPDIR P8DIR
247 #define VPPSEL P8SEL
249 
251 #define VPPONTEST 0x04
252 #define VPPONTDI 0x02
254 
255 // Constants for Setting up Timer A
257 #define ONEMS 0x05DC
258 
259 /****************************************************************************/
260 /* Macros for processing the JTAG port */
261 /****************************************************************************/
262 
264 #define ClrTMS() ((JTAGOUT) &= (~TMS))
265 #define SetTMS() ((JTAGOUT) |= (TMS))
267 #define ClrTDI() ((JTAGOUT) &= (~TDI))
269 #define SetTDI() ((JTAGOUT) |= (TDI))
271 #define ClrTCK() ((JTAGOUT) &= (~TCK))
273 #define SetTCK() ((JTAGOUT) |= (TCK))
275 #define StoreTCLK() ((JTAGOUT & TCLK))
277 #define RestoreTCLK(x) (x == 0 ? (JTAGOUT &= ~TCLK) : (JTAGOUT |= TCLK))
279 #define ScanTDO() ((JTAGIN & TDO))
281 #define VPPon(x) (x == VPP_ON_TEST ? (SetVpp(VPPONTEST)) : (SetVpp(VPPONTDI)))
283 #define VPPoff() (SetVpp(0))
285 
286 /****************************************************************************/
287 /* SBW2/4 (JSBW) Macros to control LPMx.5 */
288 /****************************************************************************/
289 #ifdef JSBW
290 
292 #define nNOPS { _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); }
293 
295 #define SBWDATO RST
296 #define SBWCLK TEST
298 
300 #define TMSH JTAGOUT |= SBWDATO; usDelay(400); JTAGOUT &= ~SBWCLK; usDelay(1); JTAGOUT |= SBWCLK; usDelay(1);
301 #define TMSL JTAGOUT &= ~SBWDATO; usDelay(400); JTAGOUT &= ~SBWCLK; usDelay(1); JTAGOUT |= SBWCLK; usDelay(1);
303 #define TDIH JTAGOUT |= SBWDATO; usDelay(400); JTAGOUT &= ~SBWCLK; usDelay(1); JTAGOUT |= SBWCLK; usDelay(1);
305 #define TDIL JTAGOUT &= ~SBWDATO; usDelay(400); JTAGOUT &= ~SBWCLK; usDelay(1); JTAGOUT |= SBWCLK; usDelay(1);
307 #define TDOsbw TRSLDIR |= TDOI_DIR; nNOPS JTAGOUT &= ~SBWCLK; usDelay(1); JTAGOUT |= SBWCLK; usDelay(1); TRSLDIR &= ~TDOI_DIR;
309 #define TDO_RD TRSLDIR |= TDOI_DIR; nNOPS JTAGOUT &= ~SBWCLK; usDelay(1); tdo_bit = JTAGIN; usDelay(1); JTAGOUT |= SBWCLK; TRSLDIR &= ~TDOI_DIR;
311 
312 /****************************************************************************/
313 /* Macros to control Spy-Bi-Wire-IF */
314 /****************************************************************************/
315 #else
316 
318 #define SBWDATO TDI
319 #define SBWDATI TDO
321 #define SBWCLK TCK
323 
325 #define nNOPS { _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); }
326 
328 #define TMSH {JTAGOUT |= SBWDATO; nNOPS ;JTAGOUT &= ~SBWCLK; nNOPS JTAGOUT |= SBWCLK; }
329 #define TMSL {JTAGOUT &= ~SBWDATO; nNOPS JTAGOUT &= ~SBWCLK; nNOPS JTAGOUT |= SBWCLK;}
331 #define TMSLDH {JTAGOUT &= ~SBWDATO; nNOPS JTAGOUT &= ~SBWCLK; nNOPS JTAGOUT |= SBWDATO; JTAGOUT |= SBWCLK;}
336 #define TDIH {JTAGOUT |= SBWDATO; nNOPS JTAGOUT &= ~SBWCLK; nNOPS JTAGOUT |= SBWCLK;}
338 #define TDIL {JTAGOUT &= ~SBWDATO; nNOPS JTAGOUT &= ~SBWCLK; nNOPS JTAGOUT |= SBWCLK;}
340 #define TDOsbw {TRSLDIR |= TDOI_DIR; nNOPS JTAGOUT &= ~SBWCLK; nNOPS JTAGOUT |= SBWCLK; TRSLDIR &= ~TDOI_DIR;}
342 #define TDO_RD {TRSLDIR |= TDOI_DIR; nNOPS JTAGOUT &= ~SBWCLK; nNOPS tdo_bit = JTAGIN; JTAGOUT |= SBWCLK; TRSLDIR &= ~TDOI_DIR;}
344 
346 #define SetSBWTCK() (JTAGOUT |= SBWCLK)
347 #define ClrSBWTCK() (JTAGOUT &= ~SBWCLK)
349 #define SetSBWTDIO() (JTAGOUT |= SBWDATO)
351 #define ClrSBWTDIO() (JTAGOUT &= ~SBWDATO)
353 
354 #endif
355 
356 #if ( INTERFACE == SPYBIWIRE_IF )
357 
358 void ClrTCLK_sbw(void);
359 void SetTCLK_sbw(void);
361 #define ClrTCLK() ClrTCLK_sbw()
362 #define SetTCLK() SetTCLK_sbw()
364 
366 #define SetRST() (JTAGOUT |= SBWDATO)
367 #define ClrRST() (JTAGOUT &= ~SBWDATO)
369 #define ReleaseRST() ()
371 #define SetTST() (JTAGOUT |= SBWCLK)
373 #define ClrTST() (JTAGOUT &= ~SBWCLK)
375 
376 #else
377 
379 #define ClrTCLK() ((JTAGOUT) &= ~(TCLK))
380 #define SetTCLK() ((JTAGOUT) |= (TCLK))
382 
384 #define SetRST() ((JTAGOUT) |= (RST))
385 #define ClrRST() ((JTAGOUT) &= (~RST))
387 #define ReleaseRST() ( RST_dir( 0 ))
389 #define SetTST() ((JTAGOUT) |= (TEST))
391 #define ClrTST() ((JTAGOUT) &= (~TEST))
393 
394 #endif
395 
396 /****************************************************************************/
397 /* TYPEDEFS */
398 /****************************************************************************/
399 
400 #ifndef __BYTEWORD__
401 #define __BYTEWORD__
402 typedef unsigned short word;
403 typedef unsigned char byte;
404 #endif
405 
406 /****************************************************************************/
407 /* FUNCTION PROTOTYPES */
408 /****************************************************************************/
409 
410 void TMSL_TDIL(void);
411 void TMSH_TDIL(void);
412 void TMSL_TDIH(void);
413 void TMSH_TDIH(void);
414 void TMSL_TDIH_TDOrd(void);
415 void TMSL_TDIL_TDOrd(void);
416 void TMSH_TDIH_TDOrd(void);
417 void TMSH_TDIL_TDOrd(void);
418 void MsDelay(word milliseconds); // millisecond delay loop, uses Timer_A
419 void usDelay(word microeconds); // microsecond delay loop, uses nops
420 void InitController(void);
421 void InitTarget(void);
422 void ReleaseTarget(void);
423 unsigned long AllShifts(word Format, unsigned long Data);
424 void TDOisInput(void);
425 void TCLKstrobes(word Amount);
426 void ShowStatus(word Status, word Index);
427 void TriggerPulse(word Mode); // optional for test
428 void DrvSignals( void );
429 void RlsSignals( void );
430 void SetTargetVcc (word level);
431 word Get_target_Vcc( void);
432 word Get_Ext_Vcc( void );
433 void SetVpp( word source );
434 void RST_dir( word dir );
435 void IO_3state(void);
436 void SetVCoreUp( word level);
437 word Get_Vx( word index );
438 void Enable_Vpp( void );
439 void Disable_Vpp( void );
440 void TDI_dir( word dir );
441 void TDOI_dir( word dir );
442 void TEST_dir( word dir );
443 void TMS_dir( word dir );
444 void TCK_dir( word dir );
445 void configure_IO_JTAG( void );
446 void configure_IO_SBW( void );
word Get_Vx(word index)
Measure different voltages via ADC12.
void ShowStatus(word Status, word Index)
This function controls the status LEDs depending on the status argument. It stops program in error ca...
void TCK_dir(word dir)
Set the direction for the TCK pin.
void MsDelay(word milliseconds)
Delay function (resolution is 1 ms)
void DrvSignals(void)
Set up I/O pins for JTAG communication.
void TEST_dir(word dir)
Set the direction for the TEST pin.
void usDelay(word microeconds)
Delay function (resolution is ~1 us)
void ClrTCLK_sbw(void)
Clear TCLK in Spy-Bi-Wire mode.
Configurations for the MSP430 FRAM Replicator.
void configure_IO_JTAG(void)
Set JTAG pins to output direction - from REP430F to target.
void IO_3state(void)
Set all JTAG pins to input direction - from target to REP430F.
void Disable_Vpp(void)
Disable fuse blow voltage Vpp.
void InitController(void)
Initialization of the Controller Board.
void TDOI_dir(word dir)
Set the direction for the TDO pin.
void InitTarget(void)
Initialization of the Target Board (switch voltages on, preset JTAG pins)
void TMS_dir(word dir)
Set the direction for the TMS pin.
void TDOisInput(void)
This function switches TDO to Input (used for fuse blowing)
void TCLKstrobes(word Amount)
This function generates Amount strobes with the Flash Timing Generator.
void SetVCoreUp(word level)
Function to set a specific voltage level via the PMM.
void RST_dir(word dir)
Set the direction for the RST pin.
unsigned long AllShifts(word Format, unsigned long Data)
Shift a value into TDI (MSB first) and simultaneously shift out a value from TDO (MSB first)...
void SetVpp(word source)
function to set the fuse blow voltage Vpp
word Get_Ext_Vcc(void)
Determine external VCC.
void SetTargetVcc(word level)
Set target Vcc (supplied from REP430F)
void TDI_dir(word dir)
Set the direction for the TDI pin.
word Get_target_Vcc(void)
Determine target VCC.
void configure_IO_SBW(void)
Set SBW pins to output direction - from REP430F to target.
void ReleaseTarget(void)
Release Target Board (switch voltages off, JTAG pins are HI-Z)
void RlsSignals(void)
Release I/O pins.
void SetTCLK_sbw(void)
Set TCLK in Spy-Bi-Wire mode.
void Enable_Vpp(void)
Enable fuse blow voltage Vpp.

Copyright 2016, Texas Instruments Incorporated