69 #include <msp430x54x.h>
77 #define SPYBIWIREJTAG_IF 2
79 #define SPYBIWIRE_IF 3
82 #if( INTERFACE == SPYBIWIRE_IF )
83 #define SPYBIWIRE_MODE
86 #ifndef __DATAFORMATS__
87 #define __DATAFORMATS__
96 #define STATUS_ERROR 0 // false
97 #define STATUS_OK 1 // true
99 #define STATUS_FUSEBLOWN 2
103 #define STATUS_ACTIVE 2
104 #define STATUS_IDLE 3
120 #define TRSLDIR P2OUT
122 #define TRSL_CDIR P2DIR
130 #define TEST_DIR 0x04
138 #define TDOI_DIR 0x40
146 #define SW_PULLUP P1REN
147 #define LED_OUT P1OUT
149 #define LED_DIR P1DIR
153 #define SW_MODE0 0x01
154 #define SW_MODE1 0x02
156 #define SW_VPPEN 0x04
158 #define LED_YELLOW 0x08
160 #define LED_GREEN 0x10
170 #define TVCC_OUT P6OUT
171 #define TVCC_DIR P6DIR
173 #define TVCC_MASK 0xF0
178 #define TVCC_EN_DIR P5DIR
179 #define TVCC_EN_OUT P5OUT
180 #define TVCC_DIS_BIT 1
183 #define LED_yellow_on() ( LED_OUT |= LED_YELLOW )
184 #define LED_yellow_off() ( LED_OUT &= ~LED_YELLOW )
186 #define LED_red_on() ( LED_OUT |= LED_RED )
188 #define LED_red_off() ( LED_OUT &= ~LED_RED )
190 #define LED_green_on() ( LED_OUT |= LED_GREEN )
192 #define LED_green_off() ( LED_OUT &= ~LED_GREEN )
194 #define All_LEDs_off() ( LED_OUT &= ~(LED_GREEN | LED_RED | LED_YELLOW ))
199 #define JTAGOUT P5OUT
202 #define JTAGDIR P5DIR
204 #define JTAGSEL P5SEL
249 #define VPPONTEST 0x04
250 #define VPPONTDI 0x02
262 #define ClrTMS() ((JTAGOUT) &= (~TMS))
263 #define SetTMS() ((JTAGOUT) |= (TMS))
265 #define ClrTDI() ((JTAGOUT) &= (~TDI))
267 #define SetTDI() ((JTAGOUT) |= (TDI))
269 #define ClrTCK() ((JTAGOUT) &= (~TCK))
271 #define SetTCK() ((JTAGOUT) |= (TCK))
273 #define StoreTCLK() ((JTAGOUT & TCLK))
275 #define RestoreTCLK(x) (x == 0 ? (JTAGOUT &= ~TCLK) : (JTAGOUT |= TCLK))
277 #define ScanTDO() ((JTAGIN & TDO))
279 #define VPPon(x) (x == VPP_ON_TEST ? (SetVpp(VPPONTEST)) : (SetVpp(VPPONTDI)))
281 #define VPPoff() (SetVpp(0))
283 #define SetRST() ((JTAGOUT) |= (RST))
285 #define ClrRST() ((JTAGOUT) &= (~RST))
287 #define ReleaseRST() ( RST_dir( 0 ))
289 #define SetTST() ((JTAGOUT) |= (TEST))
291 #define ClrTST() ((JTAGOUT) &= (~TEST))
297 #define SBW_DELAY { _NOP();_NOP();_NOP();_NOP();_NOP();}
307 #define TMSH JTAGOUT |= SBWDATO; SBW_DELAY; JTAGOUT &= ~SBWCLK; SBW_DELAY; JTAGOUT |= SBWCLK;
308 #define TMSL JTAGOUT &= ~SBWDATO; SBW_DELAY; JTAGOUT &= ~SBWCLK; SBW_DELAY; JTAGOUT |= SBWCLK;
310 #define TMSLDH JTAGOUT &= ~SBWDATO; SBW_DELAY; JTAGOUT &= ~SBWCLK; SBW_DELAY; JTAGOUT |= SBWDATO; JTAGOUT |= SBWCLK;
315 #define TDIH JTAGOUT |= SBWDATO; SBW_DELAY; JTAGOUT &= ~SBWCLK; SBW_DELAY; JTAGOUT |= SBWCLK;
317 #define TDIL JTAGOUT &= ~SBWDATO; SBW_DELAY; JTAGOUT &= ~SBWCLK; SBW_DELAY; JTAGOUT |= SBWCLK;
319 #define TDOsbw TRSLDIR |= TDOI_DIR; SBW_DELAY; JTAGOUT &= ~SBWCLK; SBW_DELAY; JTAGOUT |= SBWCLK; TRSLDIR &= ~TDOI_DIR;
321 #define TDO_RD TRSLDIR |= TDOI_DIR; SBW_DELAY; JTAGOUT &= ~SBWCLK; SBW_DELAY; tdo_bit = JTAGIN; SBW_DELAY; JTAGOUT |= SBWCLK; TRSLDIR &= ~TDOI_DIR;
325 #define SetSBWTCK() (JTAGOUT |= SBWCLK)
326 #define ClrSBWTCK() (JTAGOUT &= ~SBWCLK)
328 #define SetSBWTDIO() (JTAGOUT |= SBWDATO)
330 #define ClrSBWTDIO() (JTAGOUT &= ~SBWDATO)
333 #if ( INTERFACE == SPYBIWIRE_IF )
338 #define ClrTCLK() ClrTCLK_sbw()
339 #define SetTCLK() SetTCLK_sbw()
345 #define ClrTCLK() ((JTAGOUT) &= ~(TCLK))
346 #define SetTCLK() ((JTAGOUT) |= (TCLK))
362 typedef unsigned short word;
363 typedef unsigned char byte;
379 void MsDelay(word milliseconds);
380 void usDelay(word microeconds);
384 word
Shift(word Format, word Data);
386 void TCLKstrobes(word Amount);
388 void TriggerPulse(word Mode);
400 void SetVpp( word source );
403 word
Get_Vx( word index );
407 void configure_IO_BSL(
void );
void Enable_Vpp(void)
Enable fuse blow voltage Vpp.
void TCK_dir(word dir)
Set the direction for the TCK pin.
void TMS_dir(word dir)
Set the direction for the TMS pin.
void TMSH_TDIH_TDOrd(void)
Combination of SBW macros: TMS high, TDI high, TDO read.
void RlsSignals(void)
Release I/O pins.
void IO_3state(void)
Set all JTAG pins to input direction - from target to REP430F.
byte TCLK_saved
Holds the last value of TCLK before entering a JTAG sequence.
void DrvSignals(void)
Set up I/O pins for JTAG communication.
void ShowStatus(word Status, word Index)
This function controls the status LEDs depending on the status argument. It stops program in error ca...
void TMSL_TDIL(void)
Combination of SBW macros: TMS low, TDI low, no TDO read.
void ClrTCLK_sbw(void)
Clear TCLK in Spy-Bi-Wire mode.
word Get_target_Vcc(void)
Determine target VCC.
void InitController(void)
Initialization of the Controller Board.
void configure_IO_JTAG(void)
Set JTAG pins to output direction - from REP430F to target.
void Disable_Vpp(void)
Disable fuse blow voltage Vpp.
void configure_IO_SBW(void)
Set SBW pins to output direction - from REP430F to target.
word Shift(word Format, word Data)
Shift a value into TDI (MSB first) and simultaneously shift out a value from TDO (MSB first)...
void usDelay(word microeconds)
Delay function (resolution is ~1 us)
void TDOI_dir(word dir)
Set the direction for the TDO pin.
void SetTCLK_sbw(void)
Set TCLK in Spy-Bi-Wire mode.
void SetVpp(word source)
function to set the fuse blow voltage Vpp
void TMSL_TDIH_TDOrd(void)
Combination of SBW macros: TMS low, TDI high, TDO read.
void IR_Ex_Blow_SBW_Shift(void)
Provide JTAG fuse blow instruction.
word Get_Vx(word index)
Measure different voltages via ADC12.
void SetVCoreUp(word level)
Function to set a specific voltage level via the PMM.
void TMSH_TDIH(void)
Combination of SBW macros: TMS high, TDI high, no TDO read.
void TDOisInput(void)
This function switches TDO to Input (used for fuse blowing)
void InitTarget(void)
Initialization of the Target Board (switch voltages on, preset JTAG pins)
void MsDelay(word milliseconds)
Delay function (resolution is 1 ms)
void TDI_dir(word dir)
Set the direction for the TDI pin.
void RST_dir(word dir)
Set the direction for the RST pin.
word Get_Ext_Vcc(void)
Determine external VCC.
void ReleaseTarget(void)
Release Target Board (switch voltages off, JTAG pins are HI-Z)
void TMSH_TDIL_TDOrd(void)
Combination of SBW macros: TMS high, TDI low, TDO read.
void SetTargetVcc(word level)
Set target Vcc (supplied from REP430F)
void TEST_dir(word dir)
Set the direction for the TEST pin.
void TMSL_TDIH(void)
Combination of SBW macros: TMS low, TDI high, no TDO read.
void TMSL_TDIL_TDOrd(void)
Combination of SBW macros: TMS low, TDI low, TDO read.
void TMSH_TDIL(void)
Combination of SBW macros: TMS high, TDI low, no TDO read.
Configurations for the MSP430 Replicator.