JTAGfunc430.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 | JTAGfunc430.h |
36 | |
37 | JTAG Function Prototypes and Definitions |
38 |----------------------------------------------------------------------------|
39 | Project: JTAG Functions |
40 | Developed using: IAR Embedded Workbench 6.20 |
41 | and: Code Composer Studio 6.0 |
42 |----------------------------------------------------------------------------|
43 | Version history: |
44 | 1.0 04/02 FRGR Initial version. |
45 | 1.1 06/02 ALB2 Formatting changes, added comments. |
46 | 1.2 08/02 ALB2 Initial code release with Lit# SLAA149. |
47 | 1.3 01/06 STO Minor cosmetic changes |
48 | 1.4 04/07 WLUT WriteFLASHallSections changed due to function spec |
49 | 1.5 03/13 RL/MD Added unlock function for Info A |
50 |----------------------------------------------------------------------------|
51 | Designed 2002 by Texas Instruments Germany |
52 \*==========================================================================*/
55 /****************************************************************************/
56 /* INCLUDES */
57 /****************************************************************************/
58 
59 #include "Config430.h" // High-level user input
60 
61 /****************************************************************************/
62 /* Global types */
63 /****************************************************************************/
64 
65 #ifndef __BYTEWORD__
66 #define __BYTEWORD__
67 typedef unsigned int word;
68 typedef unsigned char byte;
69 #endif
70 
71 /****************************************************************************/
72 /* Define section for constants */
73 /****************************************************************************/
74 
75 //----------------------------------------------------------------------------
76 // Constants for the JTAG instruction register (IR) require LSB first.
77 // The MSB has been interchanged with LSB due to use of the same shifting
78 // function as used for the JTAG data register (DR) which requires MSB
79 // first.
80 //----------------------------------------------------------------------------
81 
82 // Instructions for the JTAG control signal register
84 #define IR_CNTRL_SIG_16BIT 0xC8 // original value: 0x13
85 #define IR_CNTRL_SIG_CAPTURE 0x28 // original value: 0x14
87 #define IR_CNTRL_SIG_RELEASE 0xA8 // original value: 0x15
89 
90 // Instructions for the JTAG fuse
92 #define IR_PREPARE_BLOW 0x44 // original value: 0x22
93 #define IR_EX_BLOW 0x24 // original value: 0x24
95 
96 // Instructions for the JTAG data register
99 #define IR_DATA_16BIT 0x82 // original value: 0x41
100 #define IR_DATA_QUICK 0xC2 // original value: 0x43
102 
103 // Instructions for the JTAG PSA mode
105 #define IR_DATA_PSA 0x22 // original value: 0x44
106 #define IR_SHIFT_OUT_PSA 0x62 // original value: 0x46
108 
109 // Instructions for the JTAG address register
112 #define IR_ADDR_16BIT 0xC1 // original value: 0x83
113 #define IR_ADDR_CAPTURE 0x21 // original value: 0x84
115 #define IR_DATA_TO_ADDR 0xA1 // original value: 0x85
118 #define IR_BYPASS 0xFF // original value: 0xFF
120 
121 // JTAG identification values for Flash-based MSP430 devices
123 #define JTAG_ID 0x89
124 
125 // Constants for data formats, dedicated addresses
126 #define F_BYTE 8
127 #define F_WORD 16
128 #define V_RESET 0xFFFE
129 
130 // Constants for VPP connection at Blow-Fuse
132 #define VPP_ON_TDI 0
133 #define VPP_ON_TEST 1
135 
136 /****************************************************************************/
137 /* Function prototypes */
138 /****************************************************************************/
139 
140 // Low level JTAG functions
141 word DR_Shift16(word Data);
142 word IR_Shift(byte Instruction);
143 void ResetTAP(void);
144 word ExecutePOR(void);
145 word SetInstrFetch(void);
146 void SetPC(word Addr);
147 void HaltCPU(void);
148 void ReleaseCPU(void);
149 word VerifyPSA(word StartAddr, word Length, word *DataArray);
150 
151 // High level JTAG functions
152 word GetDevice(void);
153 void ReleaseDevice(word Addr);
154 void WriteMem(word Format, word Addr, word Data);
155 void WriteMemQuick(word StartAddr, word Length, word *DataArray);
156 void WriteFLASH(word StartAddr, word Length, word *DataArray);
157 word WriteFLASHallSections(const unsigned int *data, const unsigned long *address, const unsigned long *length_of_sections, const unsigned long sections);
158 word ReadMem(word Format, word Addr);
159 void ReadMemQuick(word StartAddr, word Length, word *DataArray);
160 void EraseFLASH(word EraseMode, word EraseAddr);
161 word EraseCheck(word StartAddr, word Length);
162 word VerifyMem(word StartAddr, word Length, word *DataArray);
163 word BlowFuse(void);
164 word IsFuseBlown(void);
165 void UnlockInfoA(void);
166 
167 /****************************************************************************/
168 /* VARIABLES */
169 /****************************************************************************/
171 static unsigned short SegmentInfoAKey = 0xA500;
172 
173 /****************************************************************************/
174 /* END OF SOURCE FILE */
175 /****************************************************************************/
word VerifyMem(word StartAddr, word Length, word *DataArray)
This function performs a Verification over the given memory range.
Definition: JTAGfunc430.c:1232
void UnlockInfoA(void)
This Function unlocks segment A of the InfoMemory (Flash)
Definition: JTAGfunc430.c:1307
word WriteFLASHallSections(const unsigned int *data, const unsigned long *address, const unsigned long *length_of_sections, const unsigned long sections)
This function programs/verifies a set of data arrays of words into a FLASH memory by using the "Write...
Definition: JTAGfunc430.c:957
word ExecutePOR(void)
Function to execute a Power-On Reset (POR) using JTAG CNTRL SIG register.
Definition: JTAGfunc430.c:239
void WriteFLASH(word StartAddr, word Length, word *DataArray)
This function programs/verifies an array of words into the FLASH memory by using the FLASH controller...
Definition: JTAGfunc430.c:797
word IR_Shift(byte Instruction)
Function for shifting a new instruction into the JTAG instruction register through TDI (MSB first...
Definition: JTAGfunc430.c:137
void ReleaseDevice(word Addr)
Function to release the target device from JTAG control.
Definition: JTAGfunc430.c:721
word EraseCheck(word StartAddr, word Length)
This function performs an Erase Check over the given memory range.
Definition: JTAGfunc430.c:1220
word ReadMem(word Format, word Addr)
This function reads one byte/word from a given address in memory.
Definition: JTAGfunc430.c:980
word GetDevice(void)
Function to take target device under JTAG control. Disables the target watchdog. Sets the global DEVI...
Definition: JTAGfunc430.c:659
void ReadMemQuick(word StartAddr, word Length, word *DataArray)
This function reads an array of words from the memory.
Definition: JTAGfunc430.c:1013
void HaltCPU(void)
Function to set the CPU into a controlled stop state.
Definition: JTAGfunc430.c:311
void WriteMem(word Format, word Addr, word Data)
This function writes one byte/word at a given address ( <0xA00)
Definition: JTAGfunc430.c:741
word BlowFuse(void)
This function blows the security fuse.
Definition: JTAGfunc430.c:1240
void ReleaseCPU(void)
Function to release the target CPU from the controlled stop state.
Definition: JTAGfunc430.c:325
void ResetTAP(void)
Reset target JTAG interface and perform fuse-HW check.
Definition: JTAGfunc430.c:180
word IsFuseBlown(void)
This function checks if the JTAG access security fuse is blown.
Definition: JTAGfunc430.c:1290
void WriteMemQuick(word StartAddr, word Length, word *DataArray)
This function writes an array of words into the target memory.
Definition: JTAGfunc430.c:769
void SetPC(word Addr)
Load a given address into the target CPU's program counter (PC).
Definition: JTAGfunc430.c:289
word SetInstrFetch(void)
Function to set target CPU JTAG FSM into the instruction fetch state.
Definition: JTAGfunc430.c:267
void EraseFLASH(word EraseMode, word EraseAddr)
This function performs a mass erase (with and w/o info memory) or a segment erase of a FLASH module s...
Definition: JTAGfunc430.c:1044
word DR_Shift16(word Data)
Function for shifting a given 16-bit word into the JTAG data register through TDI.
Definition: JTAGfunc430.c:94
Configurations for the MSP430 Replicator.

Copyright 2016, Texas Instruments Incorporated