Having setup the Multi API-DLL and API-DLL instances for the correct target devices using functions from previous sections. Use the functions in this section to specify what code should be written by each FPA to their target device.
All data coming to and from the target device is saved in temporary buffers located inside each API-DLL instance. In summary, these buffers are the Code Data Buffer, Write Data Buffer, and Read Data Buffer shown below:
During normal programming using Encapsulated Functions, such as F_AutoProgram, the Code Data Buffer is used to program the target device. For custom modifications the Write Data Buffer can be used to write to the target device without disturbing the Code Data Buffer using Sequential Functions, such as F_Copy_Buffer_to_Flash.
The Read Data Buffer is used for reading from the target device by the F_Copy_Flash_to_Buffer and F_Memory_Read functions, the contents of which can be accessed using F_Get_Byte_from_Buffer.
1. F ReadCodeFile
1.1. General Description
Read code from file and store in internal FPA buffer to be used in programming. Only code data that fits within the target MCUs memory space will be read, and the rest will be discarded. Therefore, it is necessary to configure the FPA for the correct MCU first, then load the code file. Unspecified locations within the code file are set to the target MCU’s default empty value (for most MCUs it is 0xFF, for some it is 0x00).
1.2. Syntax
INT_X F_ReadCodeFile( char * FileName )
1.3. Input
char * FileName : path to code file including filename and extension
Select FPA to perform operation on using F Set FPA index, index 1 to 64.Use index 0 to perform operation on all FPAs (if results differ, use F LastStatus to get individual results).
1.4. Output
INT X : result of operation
FALSE (0) : failed
TRUE (1) : succeeded
STATUS OPEN FILE ERROR (535): could not open file
STATUS FILE NAME ERROR (536): format not supported
FPA UNMATCHED RESULTS (-1 or 0xFFFFFFFF) : Result of operation inconsistent across all selected FPAs, refer to F LastStatus
•
FPA INVALID NO (-2 or 0xFFFFFFFE) : FPA not opened with F OpenInstancesAndFPAs or index out of range
•
2. F AppendCodeFile
2.1. General Description
Append code from selected file to internal FPA buffer to be used in programming. Only code data that fits within the target MCUs memory space will be read, and the rest will be discarded.
Already read code data is not overwritten by newly appended file. Existing code data locations that contain the default empty value (for most MCUs it is 0xFF, for some it is 0x00) can be overwritten if the OverwriteEmptyValues option is enabled in the Preferences file, prefer.ini (read from current working directory). By default, no overwrites are performed.
2.2. Syntax
INT_X F_AppendCodeFile( char * FileName )
2.3. Input
char * FileName : path to code file including filename and extension
Select FPA to perform operation on using F Set FPA index, index 1 to 64.Use index 0 to perform operation on all FPAs (if results differ, use F LastStatus to get individual results).
2.4. Output
INT X : result of operation
TRUE (1) : succeeded
STATUS OPEN FILE ERROR (535): could not open file
STATUS MAX FILE COUNT (557): total number of files exceeds MAX FILE INDEX (20)
STATUS DUPLICATE FILE PATH (558): appending already existing file
FPA UNMATCHED RESULTS (-1 or 0xFFFFFFFF) : Result of operation inconsistent across all selected FPAs, refer to F LastStatus
•
FPA INVALID NO (-2 or 0xFFFFFFFE) : FPA not opened with F OpenInstancesAndFPAs or index out of range
•
3. F Get CodeCS
3.1. General Description
Read code from selected buffer and calculate check sum.
3.2. Syntax
INT_X F_Get_CodeCS( INT_X dest )
3.3. Input
INT X dest : choose operation
1 : Calculate checksum of code from internal Code Buffer
2 : Calculate checksum of code used in last F AutoProgram or F Memory Write operation.
3 : Calculate checksum of flash memory read after last F AutoProgram or F Memory Verify operation.
•
Select FPA to perform operation on using F Set FPA index, index 1 to 64.Use index 0 to perform operation on all FPAs (if results differ, use F LastStatus to get individual results).
3.4. Output
INT X : result of operation
FALSE (0) : failed
any : checksum
FPA UNMATCHED RESULTS (-1 or 0xFFFFFFFF) : Result of operation inconsistent across all selected FPAs, refer to F LastStatus(avoid this by not using FPA index 0)
•
FPA INVALID NO (-2 or 0xFFFFFFFE) : FPA not opened with F OpenInstancesAndFPAs or index out of range(avoid this by using F Check FPA index first)
•
F Clr Code Buffer
3.5. General Description
Clear contents of internal code buffer.
3.6. Syntax
INT_X F_Clr_Code_Buffer( void )
3.7. Input
none.
Select FPA to perform operation on using F Set FPA index, index 1 to 64.Use index 0 to perform operation on all FPAs (if results differ, use F LastStatus to get individual results).
3.8. Output
INT X : result of operation
FALSE (0) : failed
TRUE (1) : succeeded
FPA UNMATCHED RESULTS (-1 or 0xFFFFFFFF) : Result of operation inconsistent across all selected FPAs, refer to F LastStatus
•
FPA INVALID NO (-2 or 0xFFFFFFFE) : FPA not opened with F OpenInstancesAndFPAs or index out of range
•
4. F Put Byte to Code Buffer
4.1. General Description
Write to internal code buffer. Can be used instead of or in conjunction with the F ReadCodeFile function. When starting from scratch, use the F Clr Code Buffer function to clear the internal code buffer.
4.2. Syntax
INT_X F_Put_Byte_to_Code_Buffer( INT_X addr, BYTE data )
4.3. Input
INT X addr : valid flash address for target MCU
BYTE data : new byte to be written to internal code buffer
Select FPA to perform operation on using F Set FPA index, index 1 to 64.Use index 0 to perform operation on all FPAs (if results differ, use F LastStatus to get individual results).
4.4. Output
INT X : result of operation
FALSE (0) : failed
TRUE (1) : succeeded
FPA UNMATCHED RESULTS (-1 or 0xFFFFFFFF) : Result of operation inconsistent across all selected FPAs, refer to F LastStatus
•
FPA INVALID NO (-2 or 0xFFFFFFFE) : FPA not opened with F OpenInstancesAndFPAs or index out of range
•
5. F Get Byte from Code Buffer
5.1. General Description
Read from internal code buffer. Can be used in conjunction with F Put Byte to Code Buffer to verify writes to internal code buffer.
5.2. Syntax
INT_XF_Get_Byte_from_Code_Buffer( INT_X addr )
5.3. Input
INT X addr : valid flash address for target MCU
Select FPA to perform operation on using F Set FPA index, index 1 to 64.Use index 0 to perform operation on all FPAs (if results differ, use F LastStatus to get individual results).
5.4. Output
INT X : result of operation
BYTE (0 to 0xFF) : byte from internal code buffer
-1 : addr parameter out of flash range
FPA UNMATCHED RESULTS (-1 or 0xFFFFFFFF) : Result of operation inconsistent across all selected FPAs, refer to F LastStatus
•
FPA INVALID NO (-2 or 0xFFFFFFFE) : FPA not opened with F OpenInstancesAndFPAs or index out of range
•
6. F Put Byte to Buffer
6.1. General Description
Write byte to temporary Write Data Buffer (see Figure 1.2).
6.2. Syntax
INT_X F_Put_Byte_to_Buffer( INT_X addr, BYTE data )
6.3. Input
INT X addr : valid flash address for target MCU
BYTE data : new byte to be written to temporary Write Data Buffer
Select FPA to perform operation on using F Set FPA index, index 1 to 64.Use index 0 to perform operation on all FPAs (if results differ, use F LastStatus to get individual results).
6.4. Output
INT X : result of operation
FALSE (0) : failed
TRUE (1) : succeeded
FPA UNMATCHED RESULTS (-1 or 0xFFFFFFFF) : Result of operation inconsistent across all selected FPAs, refer to F LastStatus
•
FPA INVALID NO (-2 or 0xFFFFFFFE) : FPA not opened with F OpenInstancesAndFPAs or index out of range
•
7. F Get Byte from Buffer
7.1. General Description
Read from temporary Read Data Buffer (see Figure 1.2).
7.2. Syntax
INT_X F_Get_Byte_from_Buffer( INT_X addr )
7.3. Input
INT X addr : valid flash address for target MCU
Select FPA to perform operation on using F Set FPA index, index 1 to 64.Use index 0 to perform operation on all FPAs (if results differ, use F LastStatus to get individual results).
7.4. Output
INT X : result of operation
BYTE (0 to 0xFF) : byte from temporary Write Data Buffer
-1 : addr parameter out of flash range
FPA UNMATCHED RESULTS (-1 or 0xFFFFFFFF) : Result of operation inconsistent across all selected FPAs, refer to F LastStatus
•
FPA INVALID NO (-2 or 0xFFFFFFFE) : FPA not opened with F OpenInstancesAndFPAs or index out of range
•