ataka
Joined: 19 Oct 2006 Posts: 2
|
probelems with ds1307 and lcd |
Posted: Thu Nov 09, 2006 4:59 am |
|
|
hi..
i made a program for ds1307 whit 18f452 and it is functional,for display i use port serial (rs232),the program is ok
BUT when i use the lcd display ???, i don't know what is the problem but the program is freezen
program no 1,this is ok:
void main()
{
BYTE sec;
BYTE min;
BYTE hrs;
BYTE day;
BYTE month;
BYTE yr;
BYTE dow;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_oscillator(False);
ext_int_edge(H_TO_L);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
ds1307_init();
//lcd_init();
// Set date for -> 15 June 2005 Tuesday
// Set time for -> 15:20:55
//ds1307_set_date_time(8,11,6,3,15,8,55);
while(1)
{
delay_ms(1000);
ds1307_get_date(day,month,yr,dow);
ds1307_get_time(hrs,min,sec);
printf("\f\%02d/\%02d/\%02d\r\n",day,month,yr);
printf("\%02d:\%02d:\%02d", hrs,min,sec);
/*lcd_gotoxy(1,1);
printf(lcd_putc,"Time : %02d:%02d:%02d",hrs,min,sec);
lcd_gotoxy(1,2);
printf(lcd_putc,"Data : %02d:%02d:%02d",day,month,yr);*/
}
}
program no 2 i init the lcd and it isn't functional:
void main()
{
BYTE sec;
BYTE min;
BYTE hrs;
BYTE day;
BYTE month;
BYTE yr;
BYTE dow;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_oscillator(False);
ext_int_edge(H_TO_L);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
ds1307_init();
lcd_init();
// Set date for -> 15 June 2005 Tuesday
// Set time for -> 15:20:55
//ds1307_set_date_time(8,11,6,3,15,8,55);
while(1)
{
delay_ms(1000);
ds1307_get_date(day,month,yr,dow);
ds1307_get_time(hrs,min,sec);
/*printf("\f\%02d/\%02d/\%02d\r\n",day,month,yr);
printf("\%02d:\%02d:\%02d", hrs,min,sec);*/
lcd_gotoxy(1,1);
printf(lcd_putc,"Time : %02d:%02d:%02d",hrs,min,sec);
lcd_gotoxy(1,2);
printf(lcd_putc,"Data : %02d:%02d:%02d",day,month,yr);
}
} |
|