88 static word DR_Shift16(word data)
129 static unsigned long DR_Shift20(
unsigned long address)
131 #ifdef SPYBIWIRE_MODE
170 static word IR_Shift(byte instruction)
172 #ifdef SPYBIWIRE_MODE
213 static void ResetTAP(
void)
217 #ifdef SPYBIWIRE_MODE
219 for (i = 6; i > 0; i--)
246 for (i = 6; i > 0; i--)
273 static word ExecutePOR_430X(
void)
301 static word SetInstrFetch(
void)
308 for (i = 50; i > 0; i--)
310 if (DR_Shift16(0x0000) & 0x0080)
323 static void SetPC_430X(
unsigned long Addr)
331 DR_Shift16((word)(0x0080 | (((Addr)>>8) & 0x0F00)));
346 static void HaltCPU(
void)
360 static void ReleaseCPU(
void)
378 word
VerifyPSA_430X(
unsigned long StartAddr,
unsigned long Length, word *DataArray)
382 const word POLY = 0x0805;
383 word PSA_CRC = (word)(StartAddr-2);
389 SetPC_430X(StartAddr-4);
393 DR_Shift20(StartAddr-2);
397 SetPC_430X(StartAddr-2);
404 for (i = 0; i < Length; i++)
407 if ((PSA_CRC & 0x8000) == 0x8000)
418 &DataArray[0] == 0 ? (PSA_CRC ^= 0xFFFF) : (PSA_CRC ^= DataArray[i]);
423 #ifdef SPYBIWIRE_MODE
462 TDOword = DR_Shift16(0x0000);
483 static void CheckJtagFuse_SBW(
void)
499 static void CheckJtagFuse_JTAG(
void)
502 SetTMS();_NOP();_NOP();_NOP();
503 ClrTMS();_NOP();_NOP();_NOP();
505 SetTMS();_NOP();_NOP();_NOP();
506 ClrTMS();_NOP();_NOP();_NOP();
508 SetTMS();_NOP();_NOP();_NOP();
513 static void EntrySequences_RstHigh_SBW()
549 static void EntrySequences_RstHigh_JTAG()
582 static word StartJtag(
void)
590 EntrySequences_RstHigh_SBW();
594 EntrySequences_RstHigh_JTAG();
610 CheckJtagFuse_JTAG();
617 static void StopJtag (
void)
634 word i = 0, JtagId = 0;
639 JtagId = StartJtag();
643 if(i >= MAX_ENTRY_TRY)
662 for (i = 50; i > 0; i--)
664 if (DR_Shift16(0x0000) & 0x0200)
667 DeviceId = ReadMem(F_WORD, 0x0FF0);
669 DeviceId = (DeviceId << 8) + (DeviceId >> 8);
682 if (!ExecutePOR_430X())
719 if (Format == F_WORD)
746 SetPC_430X(StartAddr-4);
753 for (i = 0; i < Length; i++)
755 DR_Shift16(DataArray[i]);
771 unsigned long addr = StartAddr;
772 word FCTL3_val = SegmentInfoAKey;
796 DR_Shift16(FCTL3_val);
803 for (i = 0; i < Length; i++, addr += 2)
809 DR_Shift16(DataArray[i]);
832 DR_Shift16(FCTL3_val | 0x0010);
848 word
WriteFLASHallSections_430X(
const unsigned int *data,
const unsigned long *address,
const unsigned long *length_of_sections,
const unsigned long sections)
852 for(i = 0; i < sections; i++)
855 WriteFLASH(address[i], length_of_sections[i], (word*)&data[init-1]);
856 if (!VerifyMem(address[i], length_of_sections[i], (word*)&data[init-1]))
860 init += length_of_sections[i];
879 if (Format == F_WORD)
892 TDOword = DR_Shift16(0x0000);
894 return(Format == F_WORD ? TDOword : TDOword & 0x00FF);
907 SetPC_430X(StartAddr-4);
915 for (i = 0; i < Length; i++)
918 DataArray[i] = DR_Shift16(0x0000);
934 word StrobeAmount = 4820;
935 volatile word i, loopcount = 1;
936 word FCTL3_val = SegmentInfoAKey;
946 StrobeAmount = 10600;
956 for (i = loopcount; i > 0; i--)
964 DR_Shift16(EraseMode);
978 DR_Shift16(FCTL3_val);
983 DR_Shift20(EraseAddr);
1006 DR_Shift16(FCTL3_val | 0x0010);
1040 word mode = VPP_ON_TEST;
1076 for (i = 3; i > 0; i--)
1079 if (DR_Shift16(0xAAAA) == 0x5555)
1091 SegmentInfoAKey = 0xA540;
#define IR_ADDR_CAPTURE
Read out the MAB data on the next 16/20-bit data access.
#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...
void WriteMem_430X(word Format, unsigned long Addr, word Data)
This function writes one byte/word at a given address ( <0xA00)
#define ClrTCLK()
clear the TCLK signal
void WriteMemQuick_430X(unsigned long StartAddr, unsigned long Length, word *DataArray)
This function writes an array of words into the target memory.
#define IR_ADDR_16BIT
Set the MSP430 MAB to a specific 16-bit value.
byte TCLK_saved
Holds the last value of TCLK before entering a JTAG sequence.
unsigned long AllShifts(word Format, unsigned long Data)
Shift a value into TDI (MSB first) and simultaneously shift out a value from TDO (MSB first)...
#define SetTDI()
JTAG macro: set TDI signal.
word EraseCheck_430X(unsigned long StartAddr, unsigned long Length)
This function performs an Erase Check over the given memory range.
JTAG Function Prototypes and Definitions.
void usDelay(word microseconds)
Delay function (resolution is ~1 us)
bool DeviceHas_FastFlash(void)
Function to check if current device supports FastFlash.
word VerifyMem_430X(unsigned long StartAddr, unsigned long Length, word *DataArray)
This function performs a Verification over the given memory range.
#define ClrTMS()
JTAG macro: clear TMS signal.
#define INTERFACE
Select the interface to be used to communicate with the device.
bool DeviceHas_TestPin(void)
Function to check if current device has a test pin.
#define IR_CNTRL_SIG_CAPTURE
Read out the JTAG control signal register.
#define IR_DATA_16BIT
Set the MSP430 MDB to a specific 16-bit value with the next 16-bit data access.
void TDOisInput(void)
This function switches TDO to Input (used for fuse blowing)
#define STATUS_OK
return 1 = no error
#define ClrSBWTCK()
SBW macro: clear TCK signal.
void InitTarget(void)
Initialization of the Target Board (switch voltages on, preset JTAG pins)
#define JTAG_ID
JTAG identification value for 430X architecture devices.
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...
word GetDevice_430X(void)
Function to take target device under JTAG control. Disables the target watchdog. Sets the global DEVI...
#define SetTST()
JTAG macro: set TST signal.
#define SetSBWTCK()
SBW macro: set TCK signal.
void MsDelay(word milliseconds)
Delay function (resolution is 1 ms)
#define IR_CNTRL_SIG_16BIT
Set the JTAG control signal register.
word BlowFuse(void)
This function blows the security fuse.
#define IR_CNTRL_SIG_RELEASE
Release the CPU from JTAG control.
#define IR_DATA_PSA
Switch JTAG data register to PSA mode.
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...
Low Level function prototypes, macros, and pin-to-signal.
void ReleaseDevice_430X(unsigned long Addr)
Function to release the target device from JTAG control.
bool DeviceHas_EnhVerify(void)
Function to check if current device supports EnhVerify.
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...
void DrvSignals(void)
Set up I/O pins for JTAG communication.
#define SPYBIWIRE_IF
Spy-Bi-Wire interface.
#define STATUS_FUSEBLOWN
GetDevice returns this if the security fuse is blown.
Device Function Prototypes and Definitions for FLASH programming.
void ReleaseTarget(void)
Release Target Board (switch voltages off, JTAG pins are HI-Z)
void TCLKstrobes(word Amount)
This function generates Amount strobes with the Flash Timing Generator.
#define ERASE_MAIN
Constant for flash erase: main of SELECTED mem arrays.
#define ERASE_GLOB
Constant for flash erase: main & info of ALL mem arrays.
#define SetTMS()
JTAG macro: set TMS signal.
#define SBWDATO
JTAG data_out pin in SBW mode -separate pin in MSP430F5437 - common IO translator.
#define STATUS_ERROR
return 0 = error
#define ClrTST()
JTAG macro: clear TST signal.
#define ClrRST()
JTAG macro: clear RST signal.
#define ERASE_ALLMAIN
Constant for flash erase: main of ALL mem arrays.
#define SPYBIWIREJTAG_IF
JTAG interface on a device that supports JTAG and SBW.
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...
#define VPPon(x)
Supply fuse blow voltage based on TEST or TDI pin (based on input: x(.
void RlsSignals(void)
Release I/O pins.
#define IR_SHIFT_OUT_PSA
Shift out the PSA pattern generated by IR_DATA_PSA.
#define IR_PREPARE_BLOW
Prepare for JTAG fuse blow.
word IsFuseBlown(void)
This function checks if the JTAG access security fuse is blown.
#define IR_EX_BLOW
Perform JTAG fuse blow.
#define SetRST()
JTAG macro: set RST signal.
word ReadMem_430X(word Format, unsigned long Addr)
This function reads one byte/word from a given address in memory.
#define SetTCLK()
set the TCLK signal
void UnlockInfoA(void)
This function unlocks segment A of the InfoMemory (Flash)
#define ERASE_MASS
Constant for flash erase: main & info of SELECTED mem arrays.
#define MAX_ENTRY_TRY
Maximum number of tries for the determination of the core identification info.
#define IR_BYPASS
Bypass instruction - TDI input is shifted to TDO as an output.
void ReadMemQuick_430X(unsigned long StartAddr, unsigned long Length, word *DataArray)
This function reads an array of words from the memory.
#define SetTCK()
JTAG macro: set TCK signal.
#define ClrTCK()
JTAG macro: clear TCK signal.
void SetDevice(word wDeviceId)
This function accepts a Device ID and extracts the corresponding device information from the sDeviceF...
#define SetSBWTDIO()
SBW macro: set TDIO signal.
#define IR_DATA_QUICK
Set the MSP430 MDB to a specific 16-bit value (RAM only)