Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/07/01 09:52
Read: times


 
#13882 - RE: A/D PCF8591
Hi Paco,

I've done routines reading a PCF 8591 for a number of applications. Here is the code I'm using:

;DEFINITIONS:

DAT .EQU 08h ;R0 Databuffer (read and write)
IC_Adr .EQU 09h ;R1 actual IC-Address

;MAIN PROGRAM:

MOV IC_Adr,#154
MOV DAT,#0 ; A/D channel 0
MOV UBat, DAT ; save somewhere


;SUBROUTINES:

Read_AD: ; reads one A/D-channels into DAT
; INPUT: Device address in IC_Adr
; channel number 0..3 in DAT
; OUTPUT: A/D value in DAT
ORL DAT,#64 ; add config byte to channel number
ACALL Put_I2C_Byte ; send it
ACALL Get_I2C_Byte ; first a dummy read (= previous channel)
ACALL Get_I2C_Byte ; then a real read
RET

Note the ORL #64 means read one channel and do not auto-increment the channel. I do not like Philips' idea of this autoincrement. Instead, you still have to perform a 'dummy' read, since the conversion only starts at the end of a communication.

The other routines (Put_I2C_Byte and Get_I2C_Byte) are standard routines, see e.g. this site.

Good luck and have fun

Juergen

List of 5 messages in thread
TopicAuthorDate
A/D PCF8591            01/01/70 00:00      
RE: A/D PCF8591            01/01/70 00:00      
RE: A/D PCF8591            01/01/70 00:00      
RE: A/D PCF8591            01/01/70 00:00      
RE: A/D PCF8591            01/01/70 00:00      

Back to Subject List