JTAGfunc430Xv2.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 | JTAGfunc430Xv2.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/08 WLUT Added instruction for JTAG_ID91 architectures |
50 | Constants for JTAG mailbox data exchange |
51 | 1.6 08/11 FB Added JSBW function prototypes |
52 | Added support for JTAG17 bugfix |
53 | Added support for Fram functions (Write/Erase/Memory |
54 | protection (MPU)/JTAG password) |
55 | 1.7 03/13 RL/MD Added unlock functions for Info A & BSL |
56 |----------------------------------------------------------------------------|
57 | Designed 2002 by Texas Instruments Germany |
58 \*==========================================================================*/
61 /****************************************************************************/
62 /* INCLUDES */
63 /****************************************************************************/
64 
65 #include "Config430Xv2.h" // High-level user input
66 
67 /****************************************************************************/
68 /* Global types */
69 /****************************************************************************/
70 
71 #ifndef __BYTEWORD__
72 #define __BYTEWORD__
73 typedef unsigned short word;
74 typedef unsigned char byte;
75 #endif
76 
77 /****************************************************************************/
78 /* Define section for constants */
79 /****************************************************************************/
80 
81 // Constants for flash erasing modes
83 #define ERASE_MAIN 0xA506
84 #define ERASE_BANK 0xA504
86 #define ERASE_SEGMENT 0xA502
88 
89 //----------------------------------------------------------------------------
90 // Constants for the JTAG instruction register (IR) require LSB first.
91 // The MSB has been interchanged with LSB due to use of the same shifting
92 // function as used for the JTAG data register (DR) which requires MSB
93 // first.
94 //----------------------------------------------------------------------------
95 
96 // Instructions for the JTAG control signal register
98 #define IR_CNTRL_SIG_16BIT 0xC8 // original value: 0x13
99 #define IR_CNTRL_SIG_CAPTURE 0x28 // original value: 0x14
101 #define IR_CNTRL_SIG_RELEASE 0xA8 // original value: 0x15
103 
104 // Instructions for the JTAG fuse
106 #define IR_PREPARE_BLOW 0x44 // original value: 0x22
107 #define IR_EX_BLOW 0x24 // original value: 0x24
109 
110 // Instructions for the JTAG data register
113 #define IR_DATA_16BIT 0x82 // original value: 0x41
114 #define IR_DATA_QUICK 0xC2 // original value: 0x43
116 
117 // Instructions for the JTAG PSA mode
119 #define IR_DATA_PSA 0x22 // original value: 0x44
120 #define IR_SHIFT_OUT_PSA 0x62 // original value: 0x46
122 
123 // Instructions for the JTAG address register
126 #define IR_ADDR_16BIT 0xC1 // original value: 0x83
127 #define IR_ADDR_CAPTURE 0x21 // original value: 0x84
129 #define IR_DATA_TO_ADDR 0xA1 // original value: 0x85
132 #define IR_BYPASS 0xFF // original value: 0xFF
134 #define IR_DATA_CAPTURE 0x42
135 
136 // JTAG identification values for all existing Flash-based MSP430 devices
138 #define JTAG_ID 0x89
139 #define JTAG_ID91 0x91
141 #define JTAG_ID99 0x99
143 // Additional instructions for JTAG_ID91 architectures
145 #define IR_COREIP_ID 0xE8 // original value: 0x17
146 #define IR_DEVICE_ID 0xE1 // original value: 0x87
148 
149 // Instructions for the JTAG mailbox
151 #define IR_JMB_EXCHANGE 0x86 // original value: 0x61
152 #define IR_TEST_REG 0x54 // original value: 0x2A
154 #define IR_TEST_3V_REG 0xF4 // original value: 0x2F
156 
157 // Constants for JTAG mailbox data exchange
159 #define OUT1RDY 0x0008
160 #define IN0RDY 0x0001
162 #define JMB32B 0x0010
164 #define OUTREQ 0x0004
166 #define INREQ 0x0001
168 
169 // Constants for data formats
170 #ifndef __DATAFORMATS__
171 #define __DATAFORMATS__
172 #define F_BYTE 8
173 #define F_WORD 16
174 #define F_ADDR 20
175 #define F_LONG 32
176 #endif
177 
178 // dedicated addresses
180 #define V_RESET 0xFFFE
181 #define V_BOR 0x1B08
183 
184 // Constants for VPP connection at Blow-Fuse
186 #define VPP_ON_TDI 0
187 #define VPP_ON_TEST 1
189 
190 #define STOP_DEVICE 0xA55A
191 
192 /****************************************************************************/
193 /* FUNCTION PROTOTYPES */
194 /****************************************************************************/
195 
196 // Low level JTAG functions
197 static word DR_Shift16(word Data);
198 static unsigned long DR_Shift20(unsigned long address);
199 static word IR_Shift(byte Instruction);
200 static void ResetTAP(void);
201 static word ExecutePOR_430Xv2(void);
202 static void SetPC_430Xv2(unsigned long Addr);
203 word VerifyPSA_430Xv2(unsigned long StartAddr, unsigned long Length, word *DataArray);
204 word GetCoreipIdXv2();
205 void jResetJtagTap(void);
206 void StartJtagJSbw(byte states);
207 void jRelease(void);
208 long jsbw_Shift(word Format, long Data);
209 long jsbw_IR_Shift(byte instruction);
210 long jsbw_DR_Shift(long data);
211 void JsbwMagicPattern(void);
212 void jsbwJtagUnlock(void);
213 
214 // High level JTAG functions
215 word GetDevice_430Xv2(void);
216 #define GetDevice GetDevice_430Xv2
217 void ReleaseDevice_430Xv2(unsigned long Addr);
218 #define ReleaseDevice ReleaseDevice_430Xv2
219 void WriteMem_430Xv2(word Format, unsigned long Addr, word Data);
220 #define WriteMem WriteMem_430Xv2
221 void WriteMemQuick_430Xv2(unsigned long StartAddr, unsigned long Length, word *DataArray);
222 #define WriteMemQuick WriteMemQuick_430Xv2
223 void WriteFLASH_430Xv2(unsigned long StartAddr, unsigned long Length, word *DataArray);
224 #define WriteFLASH WriteFLASH_430Xv2
225 word WriteFLASHallSections_430Xv2(const unsigned int *data, const unsigned long *address, const unsigned long *length_of_sections, const unsigned long sections);
226 #define WriteFLASHallSections WriteFLASHallSections_430Xv2
227 word ReadMem_430Xv2(word Format, unsigned long Addr);
228 #define ReadMem ReadMem_430Xv2
229 void ReadMemQuick_430Xv2(unsigned long StartAddr, unsigned long Length, word *DataArray);
230 #define ReadMemQuick ReadMemQuick_430Xv2
231 void EraseFLASH_430Xv2(word EraseMode, unsigned long EraseAddr);
232 #define EraseFLASH EraseFLASH_430Xv2
233 word EraseCheck_430Xv2(unsigned long StartAddr, unsigned long Length);
234 #define EraseCheck EraseCheck_430Xv2
235 word VerifyMem_430Xv2(unsigned long StartAddr, unsigned long Length, word *DataArray);
236 #define VerifyMem VerifyMem_430Xv2
237 word ProgramLockKey(void);
238 word IsLockKeyProgrammed(void);
239 void UnlockInfoA_430Xv2(void);
240 void UnlockBsl_430Xv2Flash(void);
241 
242 /****************************************************************************/
243 /* VARIABLES */
244 /****************************************************************************/
246 static word CoreId = 0;
248 static unsigned long DeviceIdPointer = 0;
250 static word DeviceId = 0;
251 
253 static unsigned short SegmentInfoAKey5xx = 0xA548;
254 
255 /****************************************************************************/
256 /* END OF SOURCE FILE */
257 /****************************************************************************/
void EraseFLASH_430Xv2(word EraseMode, unsigned long EraseAddr)
This function performs a mass erase (with and w/o info memory) or a segment erase of a FLASH module s...
void StartJtagJSbw(byte states)
Start JTAG communication in JSBW mode.
Definition: JSBW.c:79
void jsbwJtagUnlock(void)
Function for resetting the JTAG lock via JSBW.
Definition: JSBW.c:283
long jsbw_IR_Shift(byte instruction)
Function for shifting a new instruction into the JTAG instruction register through JSBW (MSB first...
Definition: JSBW.c:229
void WriteFLASH_430Xv2(unsigned long StartAddr, unsigned long Length, word *DataArray)
This function programs/verifies an array of words into the FLASH memory by using the FLASH controller...
word VerifyMem_430Xv2(unsigned long StartAddr, unsigned long Length, word *DataArray)
This function performs a Verification over the given memory range.
word EraseCheck_430Xv2(unsigned long StartAddr, unsigned long Length)
This function performs an Erase Check over the given memory range.
Configurations for the MSP430 Replicator Xv2.
void UnlockInfoA_430Xv2(void)
This function unlocks segment A of the InfoMemory (Flash)
long jsbw_Shift(word Format, long Data)
Shift a value into TDI (MSB first) and simultaneously shift out a value from TDO (MSB first)...
Definition: JSBW.c:173
word IsLockKeyProgrammed(void)
This function checks if the JTAG lock key is programmed.
word ReadMem_430Xv2(word Format, unsigned long Addr)
This function reads one byte/word from a given address in memory.
void ReleaseDevice_430Xv2(unsigned long Addr)
Function to release the target device from JTAG control.
void jRelease(void)
Releases the JSBW logic.
Definition: JSBW.c:65
void WriteMem_430Xv2(word Format, unsigned long Addr, word Data)
This function writes one byte/word at a given address ( <0xA00)
word GetDevice_430Xv2(void)
Function to take target device under JTAG control. Disables the target watchdog. Sets the global DEVI...
void UnlockBsl_430Xv2Flash(void)
This function unlocks the BSL memory protection.
word WriteFLASHallSections_430Xv2(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...
word GetCoreipIdXv2()
Function to determine & compare core identification info (Xv2)
void WriteMemQuick_430Xv2(unsigned long StartAddr, unsigned long Length, word *DataArray)
This function writes an array of words into the target memory.
void ReadMemQuick_430Xv2(unsigned long StartAddr, unsigned long Length, word *DataArray)
This function reads an array of words from the memory.
void JsbwMagicPattern(void)
Function for applying the magic pattern via JSBW.
Definition: JSBW.c:271
long jsbw_DR_Shift(long data)
Function for shifting data into the JTAG data register through JSBW (MSB first, but with interchanged...
Definition: JSBW.c:249
word ProgramLockKey(void)
This function disables JTAG access to the target device.
word VerifyPSA_430Xv2(unsigned long StartAddr, unsigned long Length, word *DataArray)
This function compares the computed PSA (Pseudo Signature Analysis) value to the PSA value shifted ou...
void jResetJtagTap(void)
Reset target JTAG interface and perform fuse-HW check.
Definition: JSBW.c:154

Copyright 2016, Texas Instruments Incorporated