2 \author Travis Goodspeed
3 \brief JTAG handler functions.
11 extern unsigned int drwidth;
15 #define MSP430X2MODE 2
16 extern unsigned int jtag430mode;
21 unsigned long jtagtransn(unsigned long word,
22 unsigned int bitcount);
23 //! Shift 8 bits of the IR.
24 unsigned char jtag_ir_shift8(unsigned char);
25 //! Shift 16 bits of the DR.
26 unsigned int jtag_dr_shift16(unsigned int);
27 //! Shift 20 bits of the DR, MSP430 specific.
28 unsigned long jtag_dr_shift20(unsigned long in);
29 //! Stop JTAG, release pins
32 //! Setup the JTAG pin directions.
37 //! Start JTAG, unique to the '430.
39 //! Reset the TAP state machine, check the fuse.
40 void jtag430_resettap();
42 //! Defined in jtag430asm.S
43 void jtag430_tclk_flashpulses(int);
45 //High-level Macros follow
46 //! Write data to address.
47 void jtag430_writemem(unsigned int adr, unsigned int data);
48 //! Read data from address
49 unsigned int jtag430_readmem(unsigned int adr);
51 void jtag430_haltcpu();
53 void jtag430_releasecpu();
54 //! Set CPU to Instruction Fetch
55 void jtag430_setinstrfetch();
56 //! Set the program counter.
57 void jtag430_setpc(unsigned int adr);
58 //! Write data to address.
59 void jtag430_writeflash(unsigned int adr, unsigned int data);
61 //Pins. Both SPI and JTAG names are acceptable.
78 //This could be more accurate.
79 //Does it ever need to be?
81 #define JTAGDELAY(x) delay(x)
83 #define SETMOSI P5OUT|=MOSI
84 #define CLRMOSI P5OUT&=~MOSI
85 #define SETCLK P5OUT|=SCK
86 #define CLRCLK P5OUT&=~SCK
87 #define READMISO (P5IN&MISO?1:0)
88 #define SETTMS P5OUT|=TMS
89 #define CLRTMS P5OUT&=~TMS
90 #define SETTCK P5OUT|=TCK
91 #define CLRTCK P5OUT&=~TCK
92 #define SETTDI P5OUT|=TDI
93 #define CLRTDI P5OUT&=~TDI
95 #define SETTST P4OUT|=TST
96 #define CLRTST P4OUT&=~TST
97 #define SETRST P2OUT|=RST
98 #define CLRRST P2OUT&=~RST
100 #define SETTCLK SETTDI
101 #define CLRTCLK CLRTDI
103 extern int savedtclk;
104 #define SAVETCLK savedtclk=P5OUT&TCLK;
105 #define RESTORETCLK if(savedtclk) P5OUT|=TCLK; else P5OUT&=~TCLK
108 //16-bit MSP430 JTAG commands, bit-swapped
109 #define IR_CNTRL_SIG_16BIT 0xC8 // 0x13
110 #define IR_CNTRL_SIG_CAPTURE 0x28 // 0x14
111 #define IR_CNTRL_SIG_RELEASE 0xA8 // 0x15
112 // Instructions for the JTAG Fuse
113 #define IR_PREPARE_BLOW 0x44 // 0x22
114 #define IR_EX_BLOW 0x24 // 0x24
115 // Instructions for the JTAG data register
116 #define IR_DATA_16BIT 0x82 // 0x41
117 #define IR_DATA_QUICK 0xC2 // 0x43
118 // Instructions for the JTAG PSA mode
119 #define IR_DATA_PSA 0x22 // 0x44
120 #define IR_SHIFT_OUT_PSA 0x62 // 0x46
121 // Instructions for the JTAG address register
122 #define IR_ADDR_16BIT 0xC1 // 0x83
123 #define IR_ADDR_CAPTURE 0x21 // 0x84
124 #define IR_DATA_TO_ADDR 0xA1 // 0x85
125 // Bypass instruction
126 #define IR_BYPASS 0xFF // 0xFF
129 #define IR_COREIP_ID 0xE8 // 0x17
130 #define IR_DEVICE_ID 0xE1 // 0x87
133 #define MSP430JTAGID 0x89
135 #define MSP430X2JTAGID 0x91
138 unsigned int jtag430x2_syncpor();
139 //! Executes an MSP430X2 POR
140 unsigned int jtag430x2_por();
145 #define JTAG_IR_SHIFT 0x80
146 #define JTAG_DR_SHIFT 0x81
147 #define JTAG_DR_SHIFT20 0x91
151 #define JTAG430_HALTCPU 0xA0
152 #define JTAG430_RELEASECPU 0xA1
153 #define JTAG430_SETINSTRFETCH 0xC1
154 #define JTAG430_SETPC 0xC2
155 #define JTAG430_WRITEMEM 0xE0
156 #define JTAG430_WRITEFLASH 0xE1
157 #define JTAG430_READMEM 0xE2
158 #define JTAG430_ERASEFLASH 0xE3
159 #define JTAG430_ERASECHECK 0xE4
160 #define JTAG430_VERIFYMEM 0xE5
161 #define JTAG430_BLOWFUSE 0xE6
162 #define JTAG430_ISFUSEBLOWN 0xE7
163 #define JTAG430_COREIP_ID 0xF0
164 #define JTAG430_DEVICE_ID 0xF1