كعادتك اخي حيدر ماشاء الله تبارك الله عندي ملاحظتيين:
1- البرنامج شغال 100% بالفواصل مع موجة مربعة اما اذا ادخلنا اشارة تناظرية يعطي صفر على طول
2-ياليت اخي حيدر تغير لي الكود اللي وضعتة انا بحيث يقرأ float لاني حاولت لكن يعطي خطأ لما اعمل رن للبرنامج الميكروسي.
كود:
sbit LCD_RS at RC4_bit;
sbit LCD_EN at RC5_bit;
sbit LCD_D4 at RC0_bit;
sbit LCD_D5 at RC1_bit;
sbit LCD_D6 at RC2_bit;
sbit LCD_D7 at RC3_bit;
sbit LCD_RS_Direction at TRISC4_bit;
sbit LCD_EN_Direction at TRISC5_bit;
sbit LCD_D4_Direction at TRISC0_bit;
sbit LCD_D5_Direction at TRISC1_bit;
sbit LCD_D6_Direction at TRISC2_bit;
sbit LCD_D7_Direction at TRISC3_bit;
// End LCD module connections
// Define Messages
char message1[] = "F= Hz";
char *freq = "00.0";
//float freq=0.00;
//float y[12];
void Display_Freq(unsigned int freq2write) {
freq[0] = (freq2write/10)%10 + 48; // Extract tens digit
freq[1] = freq2write%10 + 48; // Extract ones digit
// Display Frequency on LCD
//FloatToStr(freq,y);
//lcd_out(1,5,y);
Lcd_Out(1, 5, freq);
}
void main() {
CMCON0 = 0x07; // Disable Comparators
ANSEL = 0x00; // Disable analog channels
TRISC = 0x00; // PORTC O/P
TRISA = 0b00001100; // RA2/T0CKI input, RA3 is I/P only
OPTION_REG = 0b00101000; // Prescaler (1:1), TOCS =1 for counter mode
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // CLEAR display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,(message1)); // Write message1 in 1st row
do {
TMR0=0;
Delay_ms(1000); // Delay 1 Sec
Display_Freq(TMR0);
} while(1); // Infinite loop
}