
AN-1138
One Technology Way • P. O . Box 9106 • Norwood, MA 02062-9106, U.S.A. • Tel : 781.329.4700 • Fax: 781.461.3113 • www.analog.com
APPLICATION NOTE
LINB DLL Programmer´s Guide
by Holger Grothe
INTRODUCTION
This application note describes the library functions available in
the LINBWSD.dll library. These functions can be used to create
an USB-to-LIN downloader for integrated battery sensor devices.
LINBWSD.dll uses Protocol 6 for Flash/EE memory programming
via LIN. Protocol 6 is explained in detail in Application Note
AN-946. LINBWSD.dll can be used for LIN programming with
the following IBS devices:
• ADuC7032-8L
• ADuC7033
• ADuC7036DCPZ
• ADuC7039
LIN DOWNLOADER
DISCLAIMER
All LINBWSD library code provided by Analog Devices, Inc.,
including this file, is provided as is without warranty of any
kind, either expressed or implied. Users assume all risk from the
use of this code. It is the responsibility of the user integrating
this code into an application to ensure that the resulting
application performs as required and is safe.
10456-001
Figure 1. LIN Downloader
Rev. 0 | Page 1 of 20

AN-1138 Application Note
TABLE OF CONTENTS
Introduction ...................................................................................... 1
Disclaimer.......................................................................................... 1
LIN Downloader............................................................................... 1
Revision History ............................................................................... 2
Hardware Setup................................................................................. 3
Downloader Jumper Settings...................................................... 3
Download Sequence......................................................................... 4
GetDLLInfo................................................................................... 5
OpenDongle.................................................................................. 6
CloseDongle.................................................................................. 7
GetDongleStatus........................................................................... 8
REVISION HISTORY
1/12—Revision 0: Initial Revision
DoReadDongleIdent.....................................................................9
InitLinKernel............................................................................... 10
ImportHexData .......................................................................... 11
GetImportInfo ............................................................................ 12
DoPageErase ............................................................................... 13
DoDataWrite............................................................................... 14
DoWriteCRC............................................................................... 15
DoResetKernel............................................................................ 16
AssignNAD ................................................................................. 17
ReadByIdentifier......................................................................... 18
Rev. 0 | Page 2 of 20

Application Note AN-1138
HARDWARE SETUP
DOWNLOADER JUMPER SETTINGS
The downloader board allows two interfaces to be connected, LIN and I2C. The LIN functionality of the interface is determined by the
on-board jumper connections, J5 and J6, as shown in Figure 2.
B
AB
J7
J5
J6
LIN
GND
LIN
VBAT
2
C
I
GND
SDA
SCL
VDD
10456-002
USB
J4
U1
ADuC832
J2
A
J8
Figure 2. LIN Downloader Jumper Configuration
Rev. 0 | Page 3 of 20

AN-1138 Application Note
DOWNLOAD SEQUENCE
LINBWSD.dll contains a security sequencer to prevent corruption of the Flash. The normal download sequence using the DLL functions follows:
• OpenDongle();
• GetDongleStatus();
• ReadDongleIdent();
• AssignNAD();
o If no default, NAD should be used
• InitLINkernel();
• ImportHexData();
• GetImportInfo();
• DoPageErase();
o Number of pages get by GetImportInfo();
• DoDataWrite();
o Number of bytes get by GetImportInfo();
• DoWriteCRC();
• DoResetKernel();
o Used if ne cessar y
• CloseDongle();
o If no more CPUs to be programmed
• ReadByIdentifier();
Rev. 0 | Page 4 of 20

Application Note AN-1138
GetDLLInfo
Getting the DLL version information.
void GetDLLInfo (char *pcDLLInfo, BYTE *pusStringLen)
Parameters
Table 1.
Parameter Description
* pcDLLInfo Pointer to a char buffer that contains the version information from the DLL
*pusStringLen Pointer to a variable of type BYTE that receives the length of the ASCII data
Return Value
There is no return value.
Remark
It is necessary that an application close the opened USB port before closing the application. If an error occurs, the DLL opens a
MessageBox.
Example
char *pMessage;
BYTE usStrLen;
BYTE usResult;
CString strMessage;
pMessage = strMessage.GetBuffer(100);
GetDLLInfo(pMessage,&usStrLen);
strMessage.ReleaseBuffer();
strMessage.SetAt(usStrLen,'\0');
MessageBox(strMessage);
Rev. 0 | Page 5 of 20

AN-1138 Application Note
OpenDongle
Opening USB port and looking for LIN-Dongle.
BYTE OpenDongle (char *pcOpenPortError, BYTE *pusStringLen)
Parameters
Table 2.
Parameter Description
*pcOpenPortError Pointer to a char buffer that contains ASCII data
*pusStringLen Pointer to a variable of type BYTE that receives the length of the ASCII data
Return Value
The return values for OpenDongle are as follows:
• 0 = no error.
• 1 = error during opening of USB port or no LIN-Dongle connected.
Remark
If the application tries to open an already open port, the DLL ignores the command.
Example
char *pMessage;
BYTE usStrLen;
BYTE usResult;
CString strMessage;
pMessage = strMessage.GetBuffer(100);
usResult = OpenDongle(pMessage,&usStrLen);
strMessage.ReleaseBuffer();
strMessage.SetAt(usStrLen,'\0');
if(usResult != 0) // Error
{
MessageBox(strMessage);
return;
}
Rev. 0 | Page 6 of 20