126 return(
Shift(F_WORD, data));
139 #ifdef SPYBIWIRE_MODE
174 return(
Shift(F_BYTE, instruction));
184 #ifdef SPYBIWIRE_MODE
186 for (i = 6; i > 0; i--)
212 for (i = 6; i > 0; i--)
274 for (i = 50; i > 0; i--)
333 #ifdef SPYBIWIRE_MODE
342 static word VerifyPSA(word StartAddr, word Length, word *DataArray)
346 word PSA_CRC = StartAddr-2;
366 for (i = 0; i < Length; i++)
369 if ((PSA_CRC & 0x8000) == 0x8000)
386 PSA_CRC ^= DataArray[i];
423 word VerifyPSA(word StartAddr, word Length, word *DataArray)
427 word PSA_CRC = StartAddr-2;
446 for (i = 0; i < Length; i++)
449 if ((PSA_CRC & 0x8000) == 0x8000)
460 &DataArray[0] == 0 ? (PSA_CRC ^= 0xFFFF) : (PSA_CRC ^= DataArray[i]);
510 static void CheckJtagFuse_SBW(
void)
526 static void CheckJtagFuse_JTAG(
void)
529 SetTMS();_NOP();_NOP();_NOP();
530 ClrTMS();_NOP();_NOP();_NOP();
532 SetTMS();_NOP();_NOP();_NOP();
533 ClrTMS();_NOP();_NOP();_NOP();
535 SetTMS();_NOP();_NOP();_NOP();
540 static void EntrySequences_RstHigh_SBW()
576 static void EntrySequences_RstHigh_JTAG()
609 static word StartJtag(
void)
617 EntrySequences_RstHigh_SBW();
621 EntrySequences_RstHigh_JTAG();
637 CheckJtagFuse_JTAG();
644 static void StopJtag (
void)
667 JtagId = StartJtag();
673 if(i >= MAX_ENTRY_TRY)
690 for (i = 50; i > 0; i--)
695 DeviceId =
ReadMem(F_WORD, 0x0FF0);
697 DeviceId = (DeviceId << 8) + (DeviceId >> 8);
747 if (Format == F_WORD)
774 SetPC((word)(StartAddr-4));
781 for (i = 0; i < Length; i++)
790 #ifdef SPYBIWIRE_MODE
797 void WriteFLASH(word StartAddr, word Length, word *DataArray)
800 word addr = StartAddr;
801 word FCTL3_val = SegmentInfoAKey;
833 for (i = 0; i < Length; i++, addr += 2)
875 void WriteFLASH(word StartAddr, word Length, word *DataArray)
878 word addr = StartAddr;
879 word FCTL3_val = SegmentInfoAKey;
911 for (i = 0; i < Length; i++, addr += 2)
957 word
WriteFLASHallSections(
const unsigned int *data,
const unsigned long *address,
const unsigned long *length_of_sections,
const unsigned long sections)
961 for(i = 0; i < sections; i++)
964 WriteFLASH(address[i], length_of_sections[i], (word*)&data[init-1]);
965 if (!
VerifyMem(address[i], length_of_sections[i], (word*)&data[init-1]))
969 init += length_of_sections[i];
988 if (Format == F_WORD)
1005 return(Format == F_WORD ? TDOword : TDOword & 0x00FF);
1026 for (i = 0; i < Length; i++)
1036 #ifdef SPYBIWIRE_MODE
1047 word StrobeAmount = 9628;
1050 word StrobeAmount = 4820;
1052 word i, loopcount = 1;
1053 word FCTL3_val = SegmentInfoAKey;
1060 StrobeAmount = 10600;
1064 StrobeAmount = 5300;
1070 for (i = loopcount; i > 0; i--)
1105 TCLKstrobes(StrobeAmount);
1132 void EraseFLASH(word EraseMode, word EraseAddr)
1135 word StrobeAmount = 9628;
1138 word StrobeAmount = 4820;
1140 word i, loopcount = 1;
1141 word FCTL3_val = SegmentInfoAKey;
1148 StrobeAmount = 10600;
1152 StrobeAmount = 5300;
1158 for (i = loopcount; i > 0; i--)
1193 TCLKstrobes(StrobeAmount);
1222 return (VerifyPSA(StartAddr, Length, 0));
1232 word
VerifyMem(word StartAddr, word Length, word *DataArray)
1234 return (VerifyPSA(StartAddr, Length, DataArray));
1242 #ifdef SPYBIWIRE_MODE
1294 for (i = 3; i > 0; i--)
1309 SegmentInfoAKey = 0xA540;
void UnlockInfoA(void)
This Function unlocks segment A of the InfoMemory (Flash)
word ReadMem(word Format, word Addr)
This function reads one byte/word from a given address in memory.
word BlowFuse(void)
This function blows the security fuse.
void WriteMem(word Format, word Addr, word Data)
This function writes one byte/word at a given address ( <0xA00)
void ReleaseCPU(void)
Function to release the target CPU from the controlled stop state.
void SetPC(word Addr)
Load a given address into the target CPU's program counter (PC).
#define VPP_ON_TEST
Fuse blow voltage is supplied via the TEST pin.
word Shift(word Format, word Data)
Shift a value into TDI (MSB first) and simultaneously shift out a value from TDO (MSB first)...
#define IR_DATA_16BIT
Set the MSP430 MDB to a specific 16-bit value with the next 16-bit data access.
word IsFuseBlown(void)
This function checks if the JTAG access security fuse is blown.
void ReadMemQuick(word StartAddr, word Length, word *DataArray)
This function reads an array of words from the memory.
#define IR_DATA_PSA
Switch JTAG data register to PSA mode.
#define ClrSBWTCK()
SBW macro: clear TCK signal.
void HaltCPU(void)
Function to set the CPU into a controlled stop state.
JTAG Function Prototypes and Definitions.
word EraseCheck(word StartAddr, word Length)
This function performs an Erase Check over the given memory range.
#define SetTST()
JTAG macro: set TST signal.
Device Function Prototypes and Definitions for FLASH programming.
#define SetSBWTDIO()
SBW macro: set TDIO signal.
#define VPP_ON_TDI
Fuse blow voltage is supplied via the TDI pin.
void ReleaseDevice(word Addr)
Function to release the target device from JTAG control.
word ExecutePOR(void)
Function to execute a Power-On Reset (POR) using JTAG CNTRL SIG register.
#define SetTMS()
JTAG macro: set TMS signal.
void DrvSignals(void)
Set up I/O pins for JTAG communication.
void TMSH_TDIH(void)
Combination of SBW macros: TMS high, TDI high, no TDO read.
bool DeviceHas_FastFlash(void)
Function to check if current device supports FastFlash.
void IR_Ex_Blow_SBW_Shift(void)
Provide JTAG fuse blow instruction.
#define STATUS_FUSEBLOWN
GetDevice returns this if the security fuse is blown.
void ReleaseTarget(void)
Release Target Board (switch voltages off, JTAG pins are HI-Z)
#define STATUS_ERROR
return 0 = error
#define SPYBIWIREJTAG_IF
JTAG interface on a device that supports JTAG and SBW.
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...
#define ClrRST()
JTAG macro: clear RST signal.
void MsDelay(word milliseconds)
Delay function (resolution is 1 ms)
#define ClrTMS()
JTAG macro: clear TMS signal.
void TDOisInput(void)
This function switches TDO to Input (used for fuse blowing)
#define SetSBWTCK()
SBW macro: set TCK signal.
#define ClrTCK()
JTAG macro: clear TCK signal.
#define INTERFACE
Select the interface to be used to communicate with the device.
#define ClrTCLK()
SBW macro: clear TCLK signal.
#define SPYBIWIRE_IF
Spy-Bi-Wire interface.
#define IR_DATA_QUICK
Set the MSP430 MDB to a specific 16-bit value (RAM only)
#define JTAG_ID
JTAG identification value for MSP430 architecture devices.
#define VPPon(x)
Supply fuse blow voltage based on TEST or TDI pin (based on input: x(.
bool DeviceHas_TestPin(void)
Function to check if current device has a test pin.
void TMSL_TDIH(void)
Combination of SBW macros: TMS low, TDI high, no TDO read.
#define SBWDATO
JTAG data_out pin in SBW mode -separate pin in MSP430F5437 - common IO translator.
#define IR_ADDR_16BIT
Set the MSP430 MAB to a specific 16-bit value.
word SetInstrFetch(void)
Function to set target CPU JTAG FSM into the instruction fetch state.
#define IR_SHIFT_OUT_PSA
Shift out the PSA pattern generated by IR_DATA_PSA.
#define IR_ADDR_CAPTURE
Read out the MAB data on the next 16/20-bit data access.
word DR_Shift16(word data)
Function for shifting a given 16-bit word into the JTAG data register through TDI.
#define JTAGOUT
JTAG output register.
void InitTarget(void)
Initialization of the Target Board (switch voltages on, preset JTAG pins)
void usDelay(word microseconds)
Delay function (resolution is ~1 us)
#define ClrTST()
JTAG macro: clear TST signal.
void ResetTAP(void)
Reset target JTAG interface and perform fuse-HW check.
#define STATUS_OK
return 1 = no error
#define ERASE_MASS
Constant for flash erase: main & info of SELECTED mem arrays.
byte TCLK_saved
Holds the last value of TCLK before entering a JTAG sequence.
word VerifyMem(word StartAddr, word Length, word *DataArray)
This function performs a Verification over the given memory range.
void WriteMemQuick(word StartAddr, word Length, word *DataArray)
This function writes an array of words into the target memory.
#define IR_EX_BLOW
Perform JTAG fuse blow.
#define SetTCLK()
SBW macro: set TCLK signal.
#define IR_CNTRL_SIG_16BIT
Set the JTAG control signal register.
#define IR_CNTRL_SIG_RELEASE
Release the CPU from JTAG control.
bool DeviceHas_EnhVerify(void)
Function to check if current device supports EnhVerify.
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...
#define ERASE_MAIN
Constant for flash erase: main of SELECTED mem arrays.
#define SetRST()
JTAG macro: set RST signal.
#define IR_DATA_TO_ADDR
Set the MSP430 MDB with a specific 16-bit value and write it to the memory address which is currently...
#define IR_PREPARE_BLOW
Prepare for JTAG fuse blow.
#define SetTCK()
JTAG macro: set TCK signal.
void SetDevice(word wDeviceId)
This function accepts a Device ID and extracts the corresponding device information from the sDeviceF...
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...
word GetDevice(void)
Function to take target device under JTAG control. Disables the target watchdog. Sets the global DEVI...
void RlsSignals(void)
Release I/O pins.
#define IR_BYPASS
Bypass instruction - TDI input is shifted to TDO as an output.
#define MAX_ENTRY_TRY
Maximum number of tries for the determination of the core identification info.
word IR_Shift(byte instruction)
Function for shifting a new instruction into the JTAG instruction register through TDI (MSB first...
#define SetTDI()
JTAG macro: set TDI signal.
#define IR_CNTRL_SIG_CAPTURE
Read out the JTAG control signal register.
Low Level function prototypes, macros, and pin-to-signal assignments regarding to user's hardware...
void TMSH_TDIL(void)
Combination of SBW macros: TMS high, TDI low, no TDO read.