mcProgram
- Updated2025-09-25
- 2 minute(s) read
Purpose
Programs a memory block on the ECU. Format
| mcTypeStatus |
mcProgram(
|
Input
ECURefNum
ECURefNum is the task reference which links to the selected ECU. This reference is originally returned from .
Address
Configures the target address for the programming operation in the ECU. mcAddress is a C struct consisting of:
Address
Specifies the address part of the programming address.
Extension
Extension contains the extension part of the address.
BlockSize
BlockSize determines the size of the data block which is transferred to the ECU and used for programming from the MTA0 target.
Data
data contains the byte array that is transmitted to the ECU. Output
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means the function executed successfully. A negative value specifies an error, which means the function did not perform the expected behavior. A positive value specifies a warning, which means the function performed as expected, but a condition arose that may require attention.
Use the function of the ECU M&C API to obtain a descriptive string for the return value.
DescriptionIf you are using the CCP protocol, mcProgram implements the CCP command PROGRAM. The command is used to program the specified data into non-volatile ECU memory (Flash, EEPROM, etc.). Programming starts at the selected MTA0 address and extension defined in the Address struct. The mcProgram function auto-increments the ECU MTA0 address.
If you are using the XCP protocol, mcProgram implements the XCP command PROGRAM. The command is used to program a non-volatile memory segment inside the ECU slave. Depending on the access mode (defined by PROGRAM_FORMAT), two different concepts are supported. The end of the memory segment is indicated when BlockSize is set to 0. The end of the overall programming sequence is indicated by a using the command which executes the XCP command PROGRAM_RESET, causing the slave device to move into a disconnected state. Usually a hardware reset of the slave device is executed. This command may support block transfer similar to the commands DOWNLOAD and DOWNLOAD_NEXT. For further information on how to use mcProgram and details on block mode transfers refer to the ASAM XCP Part 2 Protocol Layer Specification.