slau358q.pdf - 第95页

www.ti.com MSP-GANG.dll Description 95 SLAU358Q – September 2011 – Revised October 2019 Submit Documentation Feedback Copyright © 2011–2019, Texas Instruments Incorporated Dynamic Link Library for MSP-GANG Programmer 4.2…

100%1 / 142
MSP-GANG.dll Description
www.ti.com
94
SLAU358QSeptember 2011Revised October 2019
Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
Dynamic Link Library for MSP-GANG Programmer
4.2.27 MSPGANG_EraseImage
MSPGANG_EraseImage clears (presets with 0xFF) active image memory. Use the
MSPGANG_SelectImage function to select desired image memory.
Syntax
LONG MSPGANG_EraseImage(void)
Result
LONG Error code
4.2.28 MSPGANG_CreateGangImage
MSPGANG_CreateGangImage creates a command script and the data to be written to target devices
according to current MSP-GANG configuration. After the image data is prepared, then it can be saved in
the selected image memory by calling the MSPGANG_LoadImageBlock function.
Syntax
LONG MSPGANG_CreateGangImage(LPTSTR name)
Arguments
LPTSTR name Image name; maximum of 16 characters. Image name is displayed on the LCD display.
Result
LONG Error code
www.ti.com
MSP-GANG.dll Description
95
SLAU358QSeptember 2011Revised October 2019
Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
Dynamic Link Library for MSP-GANG Programmer
4.2.29 MSPGANG_LoadImageBlock
MSPGANG_LoadImageBlock saves the previously prepared image contents into the selected image
memory. The selected image memory is automatically erased first (MSPGANG_EraseImage is called
automatically, your application code does NOT need to call it explicitly). Use the following sequence for
preparing and saving an image into image memory:
MSPGANG_CreateGangImage(name);
MSPGANG_SelectImage(lImage);
MSPGANG_EraseImage();
MSPGANG_LoadImageBlock();
MSPGANG_VerifyPSAImageBlock();
Syntax
LONG MSPGANG_LoadImageBlock(void)
Arguments
None
Result
LONG Error code
NOTE: Do not overwrite images unnecessarily during production
The image flash memory has a specified 10000 endurance cycles. Therefore, over the
lifetime of the product, each image can be reliably reprogrammed 10000 times.
Reprogramming images should be done once per production setup, rather than per
programming run. Reprogramming the image per programming run will quickly exhaust flash
endurance cycles and result in errant behavior.
//Ideally, load image once per setup. Reduce programming time and save flash endurance cycles.
//Loading an image usually takes longer than full target device programming.
MSPGANG_CreateGangImage(...);
MSPGANG_LoadImageBlock();
...
do
{
...
MSPGANG_MainProcess(...);
...
} while(...);
//Avoid loading image inside loop if possible.
//Loading image per programming cycle wastes time and quickly uses up flash endurance cycles.
do
{
MSPGANG_CreateGangImage(...);
MSPGANG_LoadImageBlock();
MSPGANG_MainProcess(...);
} while(...);
MSP-GANG.dll Description
www.ti.com
96
SLAU358QSeptember 2011Revised October 2019
Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
Dynamic Link Library for MSP-GANG Programmer
4.2.30 MSPGANG_VerifyPSAImageBlock
MSPGANG_VerifyPSAImageBlock verifies the checksum of all blocks used in the selected image
memory. The image memory number should be selected first using MSPGANG_SelectImage function.
Syntax
LONG MSPGANG_VerifyPSAImageBlock(void)
Arguments
None
Result
LONG Error code
4.2.31 MSPGANG_ReadImageBlock
MSPGANG_ReadImageBlock reads the header from the selected image memory. A maximum of
254 bytes can be read. Access to the remaining image memory (up to 512KB) is blocked.
Syntax
LONG MSPGANG_ReadImageBlock(LONG addr, LONG size, void *lpData)
Arguments
LONG address
LONG size
void *lpData Pointer to byte buffer where the result is saved
Result
LONG Error code
Data Format
union _IMAGE_HEADER
{
BYTE bytes[IMAGE_HEADER_SIZE];
WORD words[IMAGE_HEADER_SIZE/2];
struct
{
WORD own_PSA;
WORD global_PSA;
BYTE year;
BYTE month;
BYTE day;
BYTE hour;
BYTE min;
BYTE sec;
#define GLOBAL_PSA_START_OFFSET 10
// down - covered by global_PSA ----
#define SHORT_ID_2BYTE_OFFSET 10
WORD shortID;
#define CHUNKS_NO_2BYTE_OFFSET 12
WORD chunks;
#define IMAGE_DATA_2BYTE_OFFSET 14
WORD image_data_offset;
#define GLOBAL_SIZE_4BYTE_OFFSET 16
DWORD size; //global_size;