??? 08/13/05 14:53 Read: times |
#99339 - AT89S8252 COUNTER PROGRAM IS NOT WORKI |
I Have written a program for my project digital amperehour meter using AT*89s8252 . the main aim of this project is to count the pulses on pin 1.3 for 1 second and display it on 16x1 lcd.
i have written a program but it is going into indefinite loop when i compiled it using kiel micro vision. the code i have written is:::: #include<AT898252.h> void DELAY_HARDWARE_One_Second(void); void DELAY_HARDWARE_50ms(void); void main(void) { P1 = 0xAA; while(1) { TH1 = 0x00; TL1 = 0x00; DELAY_HARDWARE_One_Second(); P1 =~ 0xAA; TR1 = 1; ACC =TL1; B = TH1; lcd_write(1,B); lcd_write(1,ACC); /* i have to iclude the file lcdacess.c which is working. don't mind this 2 statements/* } } /*-------------------------------------------------------------*- DELAY_HARDWARE_One_Second() Hardware delay of 1000 ms. *** Assumes 12MHz (12 osc cycles) *** -*-------------------------------------------------------------*/ void DELAY_HARDWARE_One_Second() { char d; /* Call DELAY_HARDWARE_50ms() twenty times */ TMOD &= 0x0F; /* Clear all T1 bits (T0 left unchanged) */ TMOD |= 0x50; /* Set required T0 bitsTMOD=0101 (T0 left unchanged) */ TR1 = 1; for (d = 0; d < 20; d++) { DELAY_HARDWARE_50ms(); } } /*-------------------------------------------------------------*- DELAY_HARDWARE_50ms() *** Assumes 12MHz (12 osc cycles) *** -*-------------------------------------------------------------*/ void DELAY_HARDWARE_50ms() { /* Configure Timer 0 as a 16-bit timer */ TMOD &= 0xF0; /* Clear all T0 bits (T1 left unchanged) */ TMOD |= 0x01; /* Set required T0 bits (T1 left unchanged) */ /* Values for 50 ms delay */ TH0 = 0x3C; /* Timer 0 initial value (High Byte) */ TL0 = 0xB0; /* Timer 0 initial value (Low Byte) */ TF0 = 0; /* Clear overflow flag */ ET0 = 1; EA = 1; TR0 = 1; /* Start timer 0 */ while(1) { if(flag) P3 = 0x00; else P3 = 0xFF; } } void Timer0_ISR(void) interrupt 1 { TR0 = 0; flag = !flag; TH0 = 0x00; TL0 = 0x01; } please take time and help me out of this...... |
Topic | Author | Date |
AT89S8252 COUNTER PROGRAM IS NOT WORKI | 01/01/70 00:00 | |
Reformat using [pre][/pre] html tags!!! | 01/01/70 00:00 | |
counter program | 01/01/70 00:00 | |
It looks obvious to me....![]() | 01/01/70 00:00 |