[an error occurred while processing this directive]
У меня Мега 16 пример программы из CodeVision см. ниже.
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

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

Отправлено ilychoff 27 февраля 2006 г. 13:48
В ответ на: Если реально и I2С программный отправлено Лагунов 27 февраля 2006 г. 13:20

#include
/* 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 ;PORTB
.equ __sda_bit=0
.equ __scl_bit=1

#endasm

/* include the DS1621 Functions */

#include
#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;

/* 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 */
#pragma rl+
lcd_putsf("Готовность");
delay_ms(1000);
lcd_clear();
#pragma rl-

while (1)
{

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

/* prepare the displayed temperatures */
/* in the display_buffer */
sprintf(display_buffer,
"t0=%-i.%-u%cC\n",
t0/10,abs(t0%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