Требуется программист в Зеленограде
- обработка данных с датчиков; ColdFire; 40 тыс. e-mail:jobsmp@pochta.ru |
Вот код:
/*****************************************************
This program was produced by the
CodeWizardAVR V1.25.2 Beta1 Standard
Automatic Program Generator
© Copyright 1998-2006 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 06.06.2007
Author : Pavel
Company : Home
Comments:
Chip type : ATmega8
Program type : Application
Clock frequency : 1,000000 MHz
Memory model : Small
External SRAM size : 0
Data Stack size : 256
*****************************************************/
// DS1820 Temperature Sensor functions #include #define MAX_DEVICES 8 /* DS18B20 devices ROM code storage area, 9 bytes are used for each device (see the w1_search function description), but only the first 8 bytes contain the ROM code and CRC */ unsigned char rom_codes[MAX_DEVICES][9]; /* allocate space for ROM codes of the devices which generate an alarm */ unsigned char alarm_rom_codes[MAX_DEVICES][9]; // Declare your global variables here // Port C initialization // Port D initialization // Timer/Counter 0 initialization // Timer/Counter 1 initialization // Timer/Counter 2 initialization // External Interrupt(s) initialization // Timer(s)/Counter(s) Interrupt(s) initialization // Analog Comparator initialization // 1 Wire Bus initialization // LCD module initialization /* detect how many DS18B20 devices are connected to the bus and store their ROM codes in the rom_codes array */ devices=w1_search(0xf0,rom_codes); measurement resolutions for all the devices temp_low=25°C temp_high=35°C resolution 12bits */ for (i=0;i if (ds18b20_init(&rom_codes[i][0],25,35,DS18B20_12BIT_RES)) }; После запуска на дисплее высвечивается "no_way"
#include
#include
// 1 Wire Bus functions
#asm
.equ __w1_port=0x15 ;PORTC
.equ __w1_bit=5
#endasm
#include <1wire.h>
#include
/* include the printf function prototype */
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x18 ;PORTB
#endasm
#include
/* maximum number of DS18B20 connected to the bus */
char buffer2[15];
void main(void)
{
// Declare your local variables here
unsigned char i,devices;
// Input/Output Ports initialization
// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTB=0x00;
DDRB=0x00;
// Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x00;
DDRC=0x00;
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;
// Clock source: System Clock
// Clock value: Timer 0 Stopped
TCCR0=0x00;
TCNT0=0x00;
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
// INT0: Off
// INT1: Off
MCUCR=0x00;
TIMSK=0x00;
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
//w1_init();
lcd_init(16);
lcd_gotoxy(0,0);
lcd_putsf("test1");
delay_ms(100);
if(devices==1)
{
lcd_gotoxy(0,0);
lcd_putsf("d18b20");
}
else
{
lcd_gotoxy(0,0);
lcd_putsf("no_way");
}
/* set the temperature alarms & temperature
sprintf(buffer2,"ID #%-c" ,i+1);
lcd_clear();
lcd_gotoxy(0,0);
lcd_puts(buffer2);
delay_ms(1000);
// printf("INITIALIZING DEVICE #%-u ",i+1);
{
lcd_clear();
lcd_gotoxy(0,0);
putsf("OK");
}
else
{
lcd_clear();
lcd_gotoxy(0,0);
putsf("ERROR");
}
while (1)
{
};
}
В чём прикол?
Ответы