TMProgramByte Overview Group

The TMProgramByte API call writes a byte to an EPROM device DS1982, DS1985, DS1986 or DS2407. The byte to write 'write_byte', the location (address 'address' and status/regular space designator 'page_type') and the number of bits 'bits' to program at a time are specified to the function. If the number of bits to program at a time is not successful then the function will automatically fall back to a lower value. To not waste time on the next call to TMProgramByte the number of bits per pass is returned. If the function is forced to fall back to a lower value then use this value on subsequent calls to the function. Note that the ROM pattern for the desired 1-Wire device must already be in the internal eight-byte buffer before this function is called. This can be accomplished by direct writing to the internal buffer using the API call TMRom or by use a network API call TMFirst, TMNext, TMFirstAlarmor TMNextAlarm. This constraint enables this function to be multi-drop compatible with other EPROM devices on the 1-Wire network. It is the responsibility of the calling program to make sure that there are no non-EPROM devices on the 1-Wire network at the time of programming. A non-EPROM device can be damaged from the programming pulse. The page type 'page_type' is as follows:

0 :  regular memory page
1 :  status memory page

The valid values for the number of bits to program at each pass 'bits' is 2,4 or 8. The 'zeros' flag indicates:

0 : 'write_byte' must be written exactly as indicated
1 : only the 0 bits must be programmed correctly (used in individual bit programming application)

short far pascal TMProgramByte(

long session_handle,     // session handle for the desired 1-Wire network
void far *state_buffer,  // state buffer provided for the 1-Wire network session
short write_byte,        // byte to program into the device
short address,           // address in (status or regular) memory to write
short page_type,         // indicates status or regular page space
short far *bits,         // pointer to the number of bits to program at a time
short zeros              // flag to indicate if extra zeros are to be ignored
);

For a description of the above types, see the TMEX Type Descriptions.

Parameters

session_handle

Specifies the session handle returned from the API function TMExtendedStartSession that specifies the desired 1-Wire network port. This parameter is required by most TMEX API functions.

state_buffer

Specifies a pointer to a memory location that TMEX keeps all of the state information for the 1-Wire networks. This parameter is required by most TMEX API functions.

write_byte

Specifies the byte to write to the 1-Wire device.

address

Specifies the address of the byte to write. This address could be in status or regular memory space specified by ‘page_type’.

page_type

Specifies the page type. 0 indicates regular data space and 1 indicates status data space. Note that not all 1-Wire devices have status memory.

bits

Specifies a pointer to the number of bits to program at a time. Depending on the programming hardware type, multiple bits may not be programmed at a time. The valid values for ‘bits’ is 2, 4 or 8. The number of bits is automatically reduced by TMProgramByte until a successful program is achieved.

zeros

Specifies whether the byte to program must match the byte on the 1-Wire device exactly (0) or it can have extra zeros (1).

Return Value

1 => byte written successfully

<0 => TMEX Transport Error Return Code

Code Example

See Also

TMProgramBlock, TMDoProgramJob