سلام و خسته نباشید به همه اساتید
من دارم از کدویژن به انمل استودیو میرم ، یه برنامه ساعت نوشتم با اتمگا8 و کریستال ساعت
پروژه رو که روی بردبرد میبندم اصلا ثانیه افزایش پیدا نمیکنه و فقط روی صفر هستش . یک ال ای دی چشمک زن هم گذاشتم که از کارکرد مدار مطمئن باشم . البته ال ای دی کاری به تایمر نداره.
کدهای پروزه هم میذارم ، ممنون میشم کمکم کنید
من دارم از کدویژن به انمل استودیو میرم ، یه برنامه ساعت نوشتم با اتمگا8 و کریستال ساعت
پروژه رو که روی بردبرد میبندم اصلا ثانیه افزایش پیدا نمیکنه و فقط روی صفر هستش . یک ال ای دی چشمک زن هم گذاشتم که از کارکرد مدار مطمئن باشم . البته ال ای دی کاری به تایمر نداره.
کدهای پروزه هم میذارم ، ممنون میشم کمکم کنید
#define F_CPU 1000000UL
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdio.h>
#include "LCD/CharacterLCDLib.h"
#include <util/delay.h>
char str[16];
char s,m,h;
ISR (TIMER2_OVF_vect)
{
s++;
}
int main(void)
{
DDRB|=0b00000000;
DDRD|=0b00000001;
// Timer/Counter 2 initialization
// Clock source: TOSC1 pin
// Clock value: PCK2/128
// Mode: Normal top=0xFF
// OC2 output: Disconnected
ASSR=0x08;
TCCR2=0x05;
TCNT2=0x00;
OCR2=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x40;
asm("sei");
lcd_init();
lcd_puts("Hello World");
while (1)
{
PORTD|=0b00000001;
_delay_ms (1000);
PORTD&=!0b00000001;
_delay_ms(1000);
sprintf(str,"LCD %d%d",s/10%10,s%10);
lcd_clear();
lcd_gotoxy(2,1);
lcd_puts(str);
if (s>=60)
{
m++;
s=0;
}
else if (m>=60)
{
h++;
m=0;
}
if (h>=24)
{
h=0;
}
}
}
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdio.h>
#include "LCD/CharacterLCDLib.h"
#include <util/delay.h>
char str[16];
char s,m,h;
ISR (TIMER2_OVF_vect)
{
s++;
}
int main(void)
{
DDRB|=0b00000000;
DDRD|=0b00000001;
// Timer/Counter 2 initialization
// Clock source: TOSC1 pin
// Clock value: PCK2/128
// Mode: Normal top=0xFF
// OC2 output: Disconnected
ASSR=0x08;
TCCR2=0x05;
TCNT2=0x00;
OCR2=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x40;
asm("sei");
lcd_init();
lcd_puts("Hello World");
while (1)
{
PORTD|=0b00000001;
_delay_ms (1000);
PORTD&=!0b00000001;
_delay_ms(1000);
sprintf(str,"LCD %d%d",s/10%10,s%10);
lcd_clear();
lcd_gotoxy(2,1);
lcd_puts(str);
if (s>=60)
{
m++;
s=0;
}
else if (m>=60)
{
h++;
m=0;
}
if (h>=24)
{
h=0;
}
}
}
دیدگاه