
|
INFO - FAQ - CC2-Forum - CCPro-Forum |
|
||
|
Hallo I use the under mentioned programm. for reading of the temperature. This works great But the program give a lot of IIC ERROR:DS1612 not found What is going wrong? And how can I connect a second DS16219 and showed in the program On the second line of the display. I hope that someone can help me with this. Hans . '----------------------------------------------------------------------------------------------------' '********************************************************' '* WINDT SYSTEMS *' '* DS1621 IIC TEMP READ v1.1 for CCIUM2.0 with CCIAB2.0 *' '* 2005/ H.J. WINDT *' '********************************************************' '----------------------------------------------------------------------------------------------------' 'This softare, with the C-Control I Unit M2.0 mounted on the C-Control I Application Board 2.0,' 'will read the DS1621 9 bit Temperature and display the data on the LCD as °C and °F.' 'Communication with the DS1621 is via the IIC bus.' 'Feel free to use and share this software!' 'DS1621 -->> DALLAS SEMICONDUCTOR Digital Thermometer and Thermostat' '**************** I/O PORTS ****************' define lcd_backlight_off port[16] '*******************************************' '**************** VARIABLES ****************' define configuration byte[1] define iic_nack bit[7] define iic_nack_count byte[2] define iic_byte byte[3] define ds1621_status byte[4] define temp_c word[3] define temp_f word[4] '*******************************************' '**************** CONSTANTS ****************' define ds1621_iic_address &h90 '*******************************************' '****************** SETUP ******************' put 0 print"#ON_LCD#";:print"#INIT#";:print"#CLR#";:lcd_backlight_off = 0:print"#OFF#"; '*******************************************' '***************** PROGRAM *****************' #start gosub get_ds1621_temperature print"#ON_LCD#"; print"#L101#";:print"Temp. = ";temp_c/10;",";abs(temp_c-temp_c/10*10);:put&hdf:print"C "; print"#L201#";:print"Temp. = ";temp_f/10;",";abs(temp_f-temp_f/10*10);:put&hdf:print"F "; print"#OFF#"; goto start '*******************************************' '*************** SUBROUTINES ***************' #get_ds1621_temperature #ds1621_start_convert print"#ON_IIC#"; print"#START#"; put ds1621_iic_address put &hee print"#STOP#"; print"#OFF#"; gosub check_iic_nack if iic_nack_count > 6 then gosub no_ack_from_ds1621 if iic_nack then goto ds1621_start_convert #ds1621_check_conversion_done print"#ON_IIC#"; print"#START#"; put ds1621_iic_address put &hac print"#STOP#"; print"#OFF#"; gosub check_iic_nack if iic_nack then goto ds1621_pass_check_conversion_done print"#ON_IIC#"; print"#START#"; put ds1621_iic_address+1 get ds1621_status print"#STOP#"; print"#OFF#"; gosub check_iic_nack #ds1621_pass_check_conversion_done if iic_nack_count > 9 then gosub no_ack_from_ds1621 if iic_nack then goto ds1621_check_conversion_done if (ds1621_status and 1) = 1 then if (ds1621_status and 128) = 0 then goto ds1621_check_conversion_done #ds1621_read_temp print"#ON_IIC#"; print"#START#"; put ds1621_iic_address put &haa print"#STOP#"; print"#OFF#"; gosub check_iic_nack if iic_nack then goto pass_ds1621_read_temp print"#ON_IIC#"; print"#START#"; put ds1621_iic_address+1 get iic_byte if iic_byte > 127 then temp_c = &hff00 + iic_byte else temp_c = iic_byte temp_c = temp_c * 10 get iic_byte if (iic_byte and 128) = 128 then temp_c = temp_c + 5 temp_f = (temp_c*10/5*9+3200)/10 print"#STOP#"; print"#OFF#"; gosub check_iic_nack #pass_ds1621_read_temp if iic_nack_count > 9 then gosub no_ack_from_ds1621 if iic_nack then goto ds1621_read_temp if temp_c = -600 then goto ds1621_start_convert return #check_iic_nack print"#ON_CONFIG#"; get configuration if not iic_nack then goto pass_iic_nack_clear iic_nack = 0 put configuration iic_nack = 1 iic_nack_count = iic_nack_count + 1 print"#OFF#"; return #pass_iic_nack_clear iic_nack_count = 0 print"#OFF#"; return '*******************************************' '******* INITIALIZATION SUBROUTINES ********' '*******************************************' '****************** DATA *******************' '*******************************************' '************* ERROR MESSAGES **************' #no_ack_from_ds1621 beep 1,1,1:beep 10,1,1:beep 1,1,1:beep 10,1,1 print"#ON_LCD#"; print"#CLR#"; print"IIC ERROR:"; print"#L201#"; print"DS1621 not found"; pause 300 print"#CLR#"; print"#OFF#"; return '******************************************* |
| Antwort schreiben |