[an error occurred while processing this directive]
Кто-нибудь работал с DS1621??? Есть вопрос.
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено ilychoff 26 февраля 2006 г. 13:49

Подключил DS1621 к ATMega16. Прога написана в CodeVision там в хелпе пример есть, но почему-то не работает, датчик подключил один, адресные входы на землю посадил, на индикаторе показывает ноль, вроде все правильно перепроверил сто раз может какие грабли есть, подскажите пожалуйста...

/* the DS1621 I2C bus is connected to PORTB */

/* the SDA signal is bit 3 */

/* the SCL signal is bit 4 */

#asm

.equ __i2c_port=0x18

.equ __sda_bit=3

.equ __scl_bit=4

#endasm

/* include the DS1621 Functions */

#include

/* the LCD module is connected to PORTC */

#asm

.equ __lcd_port=0x15

#endasm

/* include the LCD Functions */

#include

/* include the prototype for sprintf */

#include

/* include the prototype for abs */

#include

char display_buffer[33];

void main(void) {

int t0,t1;

/* initialize the LCD, 2 rows by 16 columns */

lcd_init(16);

/* initialize the I2C bus */

i2c_init();

/* initialize the DS1621 sensor with address 0 */

/* tlow=20°C thigh=25°C */

ds1621_init(0,20,25,0);

/* initialize the DS1621 sensor with address 1 */

/* tlow=30°C thigh=35°C */

ds1621_init(1,30,35,0);

/* temperature display loop */

while (1)
{
/* read the temperature of DS1621 #0 *10°C */
t0=ds1621_temperature_10(0);

/* read the temperature of DS1621 #1 *10°C */
t1=ds1621_temperature_10(1);

/* prepare the displayed temperatures */
/* in the display_buffer */
sprintf(display_buffer,
"t0=%-i.%-u%cC\nt1=%-i.%-u%cC",
t0/10,abs(t0%10),0xdf,t1/10,abs(t1%10),0xdf);

/* display the temperatures */
lcd_clear();
lcd_puts(display_buffer);
};
}

Составить ответ  |||  Конференция  |||  Архив

Ответы


Отправка ответа

Имя (обязательно): 
Пароль: 
E-mail: 
NoIX ключ Запомнить

Тема (обязательно):
Сообщение:

Ссылка на URL: 
Название ссылки: 

URL изображения: 


Rambler's Top100 Рейтинг@Mail.ru
Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание

E-mail: info@telesys.ru