سلام.
از دوستان کسی می دونه ایراد این کد که برای آزمایش تایمر1 و وقفه آن در ccs نوشتم چیه؟
نمی دونم چرا عمل نمی کنه. من می خوام توسط یک کریستال اکسترنال 32.768kHZ که به پایه های t1oso و t1osi متصل کردم زمان دقیق یک ثانیه رو داشته باشم :angry:
از دوستان کسی می دونه ایراد این کد که برای آزمایش تایمر1 و وقفه آن در ccs نوشتم چیه؟
نمی دونم چرا عمل نمی کنه. من می خوام توسط یک کریستال اکسترنال 32.768kHZ که به پایه های t1oso و t1osi متصل کردم زمان دقیق یک ثانیه رو داشته باشم :angry:
#include <18f452.h>
#fuses HS
#use delay(Clock=20000000)
#include <math.h>
#include <stdio.h>
#define LCD_ENABLE_PIN PIN_d3
#define LCD_RS_PIN PIN_d1
#define LCD_RW_PIN PIN_d2
#include <lcd.c>
#int_TIMER1
void TIMER1_isr(void)
{
int8 s,m,h;
s=s+1;
if(s==60){
s=0;
m=m+1;
}
if(m==60){
m=0;
h=h+1;
}
lcd_gotoxy(1,2);
printf(lcd_putc," "
;
lcd_gotoxy(1,2);
printf(lcd_putc,"%u:%u:%u",h,m,s);
}
//-----------------------------------------------------------
void main()
{
lcd_init();
setup_timer_1(T1_EXTERNAL | T1_DIV_BY_1 | T1_CLK_OUT);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
while(true){
set_timer1(32768);
}
}
#fuses HS
#use delay(Clock=20000000)
#include <math.h>
#include <stdio.h>
#define LCD_ENABLE_PIN PIN_d3
#define LCD_RS_PIN PIN_d1
#define LCD_RW_PIN PIN_d2
#include <lcd.c>
#int_TIMER1
void TIMER1_isr(void)
{
int8 s,m,h;
s=s+1;
if(s==60){
s=0;
m=m+1;
}
if(m==60){
m=0;
h=h+1;
}
lcd_gotoxy(1,2);
printf(lcd_putc," "

lcd_gotoxy(1,2);
printf(lcd_putc,"%u:%u:%u",h,m,s);
}
//-----------------------------------------------------------
void main()
{
lcd_init();
setup_timer_1(T1_EXTERNAL | T1_DIV_BY_1 | T1_CLK_OUT);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
while(true){
set_timer1(32768);
}
}
دیدگاه