slau358q.pdf - 第78页

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

100%1 / 142
77
SLAU358QSeptember 2011Revised October 2019
Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
Dynamic Link Library for MSP-GANG Programmer
Chapter 4
SLAU358Q September 2011 Revised October 2019
Dynamic Link Library for MSP-GANG Programmer
4.1 Gang430.dll Wrapper Description
The Gang430.dll wrapper allows application software prepared for the old MSP430 Gang programmer to
control the new MSP-GANG programmer through the MSP-GANG.dll. Because the newer MSP-GANG
programmer has different functionality and features than the old MSP430 Gang Programmer, not all
features provided in the old programmer are supported in the same way by the MSP-GANG programmer.
The Gang430.dll wrapper allows an easy transition to the new programmer when using an old application,
but TI recommends using MSP-GANG.dll for remote control of the MSP-GANG programmer to have
access to all features provided by the programmer.
When Gang430.dll is used, the following files must be located in the same directory where the application
software is located:
Gang430.dll DLL wrapper with the same name as the previous Gang430.dll
Gang430.ini Initialization file for compatibility with the old structure
MSP-GANG.dll New DLL that has access to MSP-GANG Programmer
Examples of using the GANG430.dll as a wrapper around the new MSP-Gang.dll are provided and can be
found in these locations (if the default installation directory was used):
C:\Program Files\Texas Instruments\MSP-GANG\Examples\C_Applications_Wrapper
and
C:\Program Files\Texas Instruments\MSP-GANG\Examples\Cpp_Applications_Wrapper
To use these examples, also copy the MSG-Gang.dll into the working directory.
Limitation
The MSP-GANG works in interactive mode. The image is not saved in the memory; however, the save
image option must be used as it is in the old Gang430.dll. An image is saved inside the DLL only (very
fast) and used when the Start command is executed. If USB communication is used, then programming is
fast. RS-232 communication is, of course, slower than USB, but it is still faster than the previous MSP430
Gang Programmer.
See the MSP430 Gang Programmer (MSP-GANG430) User's Guide (SLAU101) for list of commands used
in Gang430.dll.
4.2 MSP-GANG.dll Description
MSP-GANG.dll is a Dynamic Link Library (DLL) that provides functions for controlling the MSP-GANG
Programmer. The MSP-GANG.dll controls the Gang Programmer through the RS-232 or USB (VCP)
interface. The MSP-GANG.dll greatly simplifies the control of the MSP-GANG Programmer, because the
user is isolated from the complexities of the communication through the USB or RS-232 interface protocol.
Together with the MSP-GANG.dll are provided two more files that should be used during the compilation
process.
MSP-GANG.h: This file is the header file for the MSP-GANG.dll, and provides the function prototypes,
typedefs, #defines, and data structures for the functions of the MSP-GANG.dll. This file is normally
located in the same directory as the application source file and should be included by the application
source files. This file is used during compile time.
MSP-GANG.lib: This file is the library file for the MSP-GANG.dll and is required to access the DLL
functions. This file is normally located in the same directory as the application source file and should
be added to the Linker Object, Library Modules list of the application. This file is used during link time.
MSP-GANG.dll Description
www.ti.com
78
SLAU358QSeptember 2011Revised October 2019
Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
Dynamic Link Library for MSP-GANG Programmer
All MSP-GANG DLL functions have the same "MSPGANG_" prefix in the function name. It is easy in the
application software determine what functions are used with the MSP-GANG.dll. The following sections
describe each function.
Examples of using the new MSP-Gang.dll are provided and can be found in these locations (if the default
installation directory was used):
C:\Program Files\Texas Instruments\MSP-GANG\Examples\C_Applications_MSP_DLL
and
C:\Program Files\Texas Instruments\MSP-GANG\Examples\Cpp_Applications_MSP_DLL
These examples show how to configure the MSP-Gang Programmer to the desired target device type,
select code, and subsequently program connected devices. In addition, the examples also show how to
write a serial number into a custom memory location. To use these examples copy the MSG-Gang.dll into
the working directory.
4.2.1 MSPGANG_GetDataBuffers_ptr
MSPGANG_GetDataBuffers_ptr gives access to the internal data buffers that provide code contents, data
to be programmed, and buffers of data that was read from each target device with following structure.
LONG WINAPI MSPGANG_GetDataBuffers_ptr( void ** x );
#define DBUFFER_SIZE 0x210000
#define JTAG_PASSW_LEN 0x80
#define BSL_PASSW_LEN 0x20 //MSP430
#define ARM_BSL_PASSW_LEN 0x100 //MSP432
#define MAX_BSL_PASSW_LEN 0x100 //max from (ARM_BSL_PASSW_LEN,
BSL_PASSW_LEN)
#define MAX_PASSW_LEN 0x100 //max from (ARM_BSL_PASSW_LEN,
BSL_PASSW_LEN, JTAG_PASSW_LEN )
#define FLASH_END_ADDR (DBUFFER_SIZE-1)
#define FLASH_BUF_LEN DBUFFER_SIZE
#define GANG_SIZE 8
typedef struct
{
BYTE SourceCode[DBUFFER_SIZE]; //source code from the file
BYTE UsedCode[DBUFFER_SIZE]; //combined data (source code,
serialization etc)
BYTE GangRx[DBUFFER_SIZE][GANG_SIZE]; //data read from all targets
BYTE Tmp[DBUFFER_SIZE]; //used for second file cmp
BYTE Flag_ScrCode[DBUFFER_SIZE]; //0 - empty 1-Code1, 2-Code2, 4-
Appended Code in SourceCode[x];
#define CODE1_FLAG 1
#define CODE2_FLAG 2
#define APPEND_CODE_FLAG 4
BYTE Flag_UsedCode[DBUFFER_SIZE]; //0 - empty 1-
valid data in UsedCode[x];
BYTE Flag_WrEn[DBUFFER_SIZE]; //0 - none 1-
write/verify enable in FlashMem[x]
BYTE Flag_EraseEn[DBUFFER_SIZE]; //0 - none 1-
erase enable in FlashMem[x]
BYTE Flag_RdEn[DBUFFER_SIZE]; //0 - none 1-
read enable in FlashMem[x]
BYTE Flag_Sp3[DBUFFER_SIZE]; //used internally
BYTE JTAG_Passsword[2][JTAG_PASSW_LEN];
BYTE BSL_Passsword[2][MAX_BSL_PASSW_LEN];
BYTE Flag_JTAG_Passw[2][JTAG_PASSW_LEN]; // [0][..]-
password from code file; [1][..]-password from password file
BYTE Flag_BSL_Passw[2][MAX_BSL_PASSW_LEN]; // [0][..]-
password from code file; [1][..]-password from password file
} DATA_BUFFERS;
www.ti.com
MSP-GANG.dll Description
79
SLAU358QSeptember 2011Revised October 2019
Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
Dynamic Link Library for MSP-GANG Programmer
extern DATA_BUFFERS dat;
Syntax
LONG MSPGANG_GetDataBuffers_ptr(void ** x)
In the application software, the pointer to the data buffer can be initialized as follows.
DATA_BUFFERS *DBuf;
void *temp;
MSPGANG_GetDataBuffers_ptr((&temp));
DBuf = (DATA_BUFFERS *)temp;
Example
Check if the code contents is specified at the MCU location and get the code contents at that location.
int get_code_content( long MCU_addr, BYTE *data )
{
long baddr, MCU_addr;
BYTE data, used_code;
baddr = MSPGANG_Convert_Address( MCU_TO_DATABUF, MCU_addr );
if( baddr >= 0 )
{
if( DBuf->Flag_ScrCode[ baddr ] )
{
*data = DBuf->SourceCode[ baddr ];
return(SUCCESS):
}
else
return(EMPTY_DATA):
}
return(WRONG_MCV_ADDR);
}
4.2.2 MSPGANG_SetGangBuffer, MSPGANG_GetGangBuffer
The MSP-GANG Programmer contains a temporary data buffer that can be used for writing and reading
data to each target device. Buffer size is 128 bytes for each target device when used it for data and 16
bytes when used for serialization.
Buffer[8] [128];
MSPGANG_SetGangBuffer writes data to selected Buffer. MSPGANG_GetGangBuffer reads contents
from the selected buffer.
Syntax
LONG MSPGANG_SetGangBuffer(BYTE target, BYTE size, BYTE *data)
LONG MSPGANG_GetGangBuffer(BYTE target, BYTE size, BYTE *data)
Arguments
#define GANG_DATA_BUF_SIZE 128
#define SN_GANG_BUF_SIZE SN_DATA_MAX_SIZE
#define TARGET_MASK 0x1F
#define SN_DATA_FLAG 0x40
If used for data:
BYTE target Target number (1 to 8)
BYTE size Size of data (1 to 128)
If used for serialization: