JTAGfunc430X.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 | JTAGfunc430X.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 06/12 RL Updated commentaries |
50 | 1.6 03/13 RL/MD Added unlock function for Info A |
51 |----------------------------------------------------------------------------|
52 | Designed 2002 by Texas Instruments Germany |
53 \*==========================================================================*/
56 /****************************************************************************/
57 /* INCLUDES */
58 /****************************************************************************/
59 
60 #include "Config430X.h" // High-level user input
61 
62 /****************************************************************************/
63 /* Global types */
64 /****************************************************************************/
65 
66 #ifndef __BYTEWORD__
67 #define __BYTEWORD__
68 typedef unsigned short word;
69 typedef unsigned char byte;
70 #endif
71 
72 /****************************************************************************/
73 /* Define section for constants */
74 /****************************************************************************/
75 
76 //----------------------------------------------------------------------------
77 // Constants for the JTAG instruction register (IR) require LSB first.
78 // The MSB has been interchanged with LSB due to use of the same shifting
79 // function as used for the JTAG data register (DR) which requires MSB
80 // first.
81 //----------------------------------------------------------------------------
82 
83 // Instructions for the JTAG control signal register
85 #define IR_CNTRL_SIG_16BIT 0xC8 // original value: 0x13
86 #define IR_CNTRL_SIG_CAPTURE 0x28 // original value: 0x14
88 #define IR_CNTRL_SIG_RELEASE 0xA8 // original value: 0x15
90 
91 // Instructions for the JTAG fuse
93 #define IR_PREPARE_BLOW 0x44 // original value: 0x22
94 #define IR_EX_BLOW 0x24 // original value: 0x24
96 
97 // Instructions for the JTAG data register
100 #define IR_DATA_16BIT 0x82 // original value: 0x41
101 #define IR_DATA_QUICK 0xC2 // original value: 0x43
103 
104 // Instructions for the JTAG PSA mode
106 #define IR_DATA_PSA 0x22 // original value: 0x44
107 #define IR_SHIFT_OUT_PSA 0x62 // original value: 0x46
109 
110 // Instructions for the JTAG address register
113 #define IR_ADDR_16BIT 0xC1 // original value: 0x83
114 #define IR_ADDR_CAPTURE 0x21 // original value: 0x84
116 #define IR_DATA_TO_ADDR 0xA1 // original value: 0x85
119 #define IR_BYPASS 0xFF // original value: 0xFF
121 
122 // JTAG identification values for Flash-based MSP430 devices
124 #define JTAG_ID 0x89
125 
126 // Constants for data formats, dedicated addresses
127 #define F_BYTE 8
128 #define F_WORD 16
129 #define V_RESET 0xFFFE
130 
131 // Constants for VPP connection at Blow-Fuse
132 #define VPP_ON_TDI 0
133 #define VPP_ON_TEST 1
134 
135 /****************************************************************************/
136 /* Function prototypes */
137 /****************************************************************************/
138 
139 // Low level JTAG functions
140 static word DR_Shift16(word Data);
141 static unsigned long DR_Shift20(unsigned long address);
142 static word IR_Shift(byte Instruction);
143 static void ResetTAP(void);
144 static word ExecutePOR_430X(void);
145 static word SetInstrFetch(void);
146 static void SetPC_430X(unsigned long Addr);
147 static void HaltCPU(void);
148 static void ReleaseCPU(void);
149 word VerifyPSA_430X(unsigned long StartAddr, unsigned long Length, word *DataArray);
150 
151 // High level JTAG functions
152 word GetDevice_430X(void);
153 #define GetDevice GetDevice_430X
154 void ReleaseDevice_430X(unsigned long Addr);
155 #define ReleaseDevice ReleaseDevice_430X
156 void WriteMem_430X(word Format, unsigned long Addr, word Data);
157 #define WriteMem WriteMem_430X
158 void WriteMemQuick_430X(unsigned long StartAddr, unsigned long Length, word *DataArray);
159 #define WriteMemQuick WriteMemQuick_430X
160 void WriteFLASH_430X(unsigned long StartAddr, unsigned long Length, word *DataArray);
161 #define WriteFLASH WriteFLASH_430X
162 word WriteFLASHallSections_430X(const unsigned int *data, const unsigned long *address, const unsigned long *length_of_sections, const unsigned long sections);
163 #define WriteFLASHallSections WriteFLASHallSections_430X
164 word ReadMem_430X(word Format, unsigned long Addr);
165 #define ReadMem ReadMem_430X
166 void ReadMemQuick_430X(unsigned long StartAddr, unsigned long Length, word *DataArray);
167 #define ReadMemQuick ReadMemQuick_430X
168 void EraseFLASH_430X(word EraseMode, unsigned long EraseAddr);
169 #define EraseFLASH EraseFLASH_430X
170 word EraseCheck_430X(unsigned long StartAddr, unsigned long Length);
171 #define EraseCheck EraseCheck_430X
172 word VerifyMem_430X(unsigned long StartAddr, unsigned long Length, word *DataArray);
173 #define VerifyMem VerifyMem_430X
174 word BlowFuse(void);
175 word IsFuseBlown(void);
176 void UnlockInfoA(void);
177 
178 /****************************************************************************/
179 /* VARIABLES */
180 /****************************************************************************/
181 
183 static unsigned short SegmentInfoAKey = 0xA500;
184 
185 /****************************************************************************/
186 /* END OF SOURCE FILE */
187 /****************************************************************************/
word VerifyPSA_430X(unsigned long StartAddr, unsigned long Length, word *DataArray)
This function compares the computed PSA (Pseudo Signature Analysis) value to the PSA value shifted ou...
Definition: JTAGfunc430X.c:378
void ReadMemQuick_430X(unsigned long StartAddr, unsigned long Length, word *DataArray)
This function reads an array of words from the memory.
Definition: JTAGfunc430X.c:902
void ReleaseDevice_430X(unsigned long Addr)
Function to release the target device from JTAG control.
Definition: JTAGfunc430X.c:693
void WriteMem_430X(word Format, unsigned long Addr, word Data)
This function writes one byte/word at a given address ( <0xA00)
Definition: JTAGfunc430X.c:713
word ReadMem_430X(word Format, unsigned long Addr)
This function reads one byte/word from a given address in memory.
Definition: JTAGfunc430X.c:871
word VerifyMem_430X(unsigned long StartAddr, unsigned long Length, word *DataArray)
This function performs a Verification over the given memory range.
word WriteFLASHallSections_430X(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: JTAGfunc430X.c:848
word IsFuseBlown(void)
This function checks if the JTAG access security fuse is blown.
void EraseFLASH_430X(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...
Definition: JTAGfunc430X.c:932
word GetDevice_430X(void)
Function to take target device under JTAG control. Disables the target watchdog. Sets the global DEVI...
Definition: JTAGfunc430X.c:632
void UnlockInfoA(void)
This function unlocks segment A of the InfoMemory (Flash)
void WriteFLASH_430X(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...
Definition: JTAGfunc430X.c:768
void WriteMemQuick_430X(unsigned long StartAddr, unsigned long Length, word *DataArray)
This function writes an array of words into the target memory.
Definition: JTAGfunc430X.c:741
word BlowFuse(void)
This function blows the security fuse.
word EraseCheck_430X(unsigned long StartAddr, unsigned long Length)
This function performs an Erase Check over the given memory range.
Configurations for the MSP430 Replicator X.

Copyright 2016, Texas Instruments Incorporated