پاسخ : مشکل در تولید یک ثانیه با میکرو(محاسبات فرکانس)
سلام
واسه استراحت وقت زیاده فقط مطالعه ! البته به شرط یادگیری
موفق باشی دوست من!
سلام
واسه استراحت وقت زیاده فقط مطالعه ! البته به شرط یادگیری
موفق باشی دوست من!
$regfile = "m16def.dat" $crystal = 8000000 '------------------------------------------------------- Config Lcd = 16 * 2 Config Lcdpin = Pin , Db7 = Portc.7 , Db6 = Portc.6 , Db5 = Portc.5 , _ Db4 = Portc.4 , E = Portc.3 , Rs = Portc.2 '------------------------------------------------------- Dim H As Byte , M As Byte , S As Byte Dim D As Byte , Mo As Byte , Year As word S = 0 : M = 0 : H = 0 : D = 0 : Mo = 0 : Year = 0 '------------------------------------------------------ Config Pina.0 = Input '------------------------------------------------------- Config Timer1 = Timer , Prescale = 1024 Enable Interrupts Enable timer1 Enable Ovf1 On Ovf1 Clock Stop Timer1 Timer1 = 57723 Start Timer1 '---------------------- Cursor Off Cls '------------------------ Do Locate 1 , 1 Lcd H ; ":" ; M ; ":" ; S Locate 2 , 1 Lcd Year ; "/" ; Mo ; "/" ; D Loop End '----------------------------- Clock: '----- INITIAL VALUE --------------- Timer1 = 57723 '-----------SUB RUTIN------------------------ Incr S If S > 59 Then Cls Incr M S = 0 End If If M > 59 Then Incr H M = 0 End If If H > 23 Then Incr D H = 0 End If If D > 29 Then Incr Mo D = 0 End If If Mo > 12 Then Incr Year Mo = 0 End If Return
#include <mega16.h> // Timer1 overflow interrupt service routine interrupt [TIM1_OVF] void timer1_ovf_isr(void) { /*FOR BASE TIME : 5000us*/ static unsigned char i=0; TCNT1=0x3CB0; if(++i==20)PORTC^=1,i=0; } void main(void) { DDRC=(1<<DDC0); TCCR1B=(1<<CS11); TIMSK=(1<<TOIE1); // Global enable interrupts #asm("sei") while (1); }
دیدگاه