User manual

MCP9800 Temperature Data Logger Demo Board 2 User’s Guide
DS22027A-page 12 © 2007 Microchip Technology Inc.
Output: None.
Return Value: 0
Code Example:
call BSTOP ; Generate Stop
SEND_ACK
Description: Generate an I
2
C bus Acknowledge condition.
Arguments: None.
Output: None.
Return Value: 0
Code Example:
call SEND_ACK ; Send ACK to continue reading
SEND_NACK
Description: Generate an I
2
C bus Not Acknowledge condition.
Arguments: None.
Output: None.
Return Value: 0
Code Example:
call SEND_NACK ; Send NACK to end operation
BYTEOUT
Description: Output an entire byte to the I
2
C bus.
Arguments: WREG
Data byte to be transmitted to the I
2
C bus.
pollflag<0>
Flag indicating whether or not currently polling (1 if polling, 0 otherwise).
Output: None.
Return Value: 0 if an Acknowledge was received.
-1 if an Acknowledge was not received and pollflag<0> is set.
Remarks: If an Acknowledge was not received and pollflag<0> is cleared, this sub-
routine sets the current state to ERR1_STATE and goes to sleep. This
state is used to indicate that an Acknowledge error occurred.
Code Example:
movlw 0x7F ; Load 0x7F into WREG
call BYTEOUT ; Output byte
BYTEIN
Description: Input an entire byte from the I
2
C bus.
Arguments: None.
Output: buffer
Data byte read from the I
2
C bus.
Return Value: 0
Code Example:
call BYTEIN ; Input byte
call SEND_NACK ; Send NACK to end operation
movfw buffer ; Copy data to WREG
BSTOP