| Микроконтролери и електроника http://mcu-bg.com/mcu_site/ |
|
| Помощ за ds1302 http://mcu-bg.com/mcu_site/viewtopic.php?f=3&t=2480 |
Страница 1 от 1 |
| Автор: | gosho [ Чет Юни 08, 2006 8:39 pm ] |
| Заглавие: | Помощ за ds1302 |
Мъча се да подкарам една Atmega16 и ds1302, но нещо не се получава. Аз съм начинаещ и се надявам да помогнете. Сигурно нещо в програмата бъркам Ето и кода ================================================================== #include <mega16.h> // DS1302 Real Time Clock functions #asm .equ __ds1302_port=0x18 ;PORTB .equ __ds1302_io=3 .equ __ds1302_sclk=4 .equ __ds1302_rst=5 #endasm // DS1820 Temperature Sensor functions #include <ds1820.h> #include <ds1302.h> #include<lcdm.h> #include<delay.h> #include<stdio.h> // Declare your global variables here unsigned char buff[33]; void main(void) { // Declare your local variables here unsigned char hrs, mins, secs; unsigned char date, month, year; // Input/Output Ports initialization // Port A 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 PORTA=0x00; DDRA=0x00; // 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=0x08; // Port C initialization // Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out // State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0 PORTC=0x00; DDRC=0xff; // Port D 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 PORTD=0x00; DDRD=0x00; // // DS1302 Real Time Clock initialization // Trickle charger: Off rtc_init(0,0,0); lcd_init(16); rtc_set_time(2,12,12); rtc_set_date(1,2,3); while (1) { rtc_get_time(&hrs,&mins,&secs); rtc_get_date(&date,&month,&year); date=12; mins=56; sprintf(buff, "Time :%02d:%02d:%02d", date, month, year); lcd_puts(buff); sprintf(buff, "Date :%02d:%02d:%02d", hrs, mins, secs); lcd_gotoxy(0,1); lcd_puts(buff); delay_ms(500); lcd_clear(); // Place your code here }; } =============================================================== |
|
| Автор: | TheHungry [ Пет Юни 09, 2006 4:51 pm ] |
| Заглавие: | |
sck и reset не трябва ли да са изходи ? |
|
| Автор: | paregov [ Пет Юни 09, 2006 5:18 pm ] | |||||||||
| Заглавие: | Re: Помощ за ds1302 | |||||||||
Кое по-точно не се получава? Не показва на LCD-то нищо или не показва вярната информация. lcd_clear(); - защо ти е да изчистваш дисплея след като си изпратил информацията към него? На каква честота ти работи контролера? Може да изпращаш прекалено бързо команди към LCD-то и да се обърква. |
||||||||||
| Автор: | gosho [ Пет Юни 09, 2006 8:19 pm ] |
| Заглавие: | |
Процесора работи на 8 Mhz ,а на LCD-то ми показва само нули. sck и reset са изходи но пак не ще |
|
| Страница 1 от 1 | Часовете са според зоната UTC + 2 часа [ DST ] |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|