Hola tengo un codigo escrito en Mikropascal el problema es que no entiendo porque toma la lectura al principio y luego la pone en 0 , no entiendo cual es la variable que hace que la lectura no siga , entiendo que este foro tratan sobre este lenguaje tambien asi que les agradezco su ayuda !
Código Delphi
[-]program Frekvens_taeller;
Var
LCD_RS : sbit at RB4_bit;
LCD_EN : sbit at RB5_bit;
LCD_D4 : sbit at RB0_bit;
LCD_D5 : sbit at RB1_bit;
LCD_D6 : sbit at RB2_bit;
LCD_D7 : sbit at RB3_bit;
LCD_RS_Direction : sbit at TRISB4_bit;
LCD_EN_Direction : sbit at TRISB5_bit;
LCD_D4_Direction : sbit at TRISB0_bit;
LCD_D5_Direction : sbit at TRISB1_bit;
LCD_D6_Direction : sbit at TRISB2_bit;
LCD_D7_Direction : sbit at TRISB3_bit;
int_sec_count: byte; new_second: boolean;
freq: word;
rpm: dword;
txt: array[16] of char;
procedure interrupt;
begin
Dec(int_sec_count);
if int_sec_count=0 then begin
T1CON := 0; Hi(freq) := TMR1H ; Lo(freq) := TMR1L;
TMR1L := 0; TMR1H := 0;
T1CON := %00000011; new_second:=true;
int_sec_count := 125; end;
TMR2IF_bit := 0; end;
Begin
ANSEL := 0; ANSELH := 0;
C1ON_bit := 0; C2ON_bit := 0;
TRISC := %00000001;
TRISB := 0; PORTB := 0xFF; TRISB := 0xFF;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); txt := 'frekvens';
Lcd_Out(1,2,txt); txt := ' & Omdrejtaller ';
Lcd_Out(2,2, txt);
Delay_1sec();
Delay_1sec();
Lcd_Cmd(_LCD_CLEAR);
T1CON := %00000011;
T2CON := %00011111; PR2 := 249; PIE1.TMR2IE := 1; int_sec_count := 125;
INTCON := %11000000;
while true do
begin
if new_second then
begin
new_second := false;
if freq > 65000 then
freq := 65000;
WordToStr(freq,txt);
Lcd_Out(1,8,txt);
txt := 'Hz';
Lcd_Out(1,14,txt);
rpm := (freq * 60);
LongWordToStr(rpm,txt); Lcd_Out(2,2,txt); txt := 'RPM';
Lcd_Out(2,14,txt);
Dec(int_sec_count);
if int_sec_count=0 then begin
T1CON := 0; Hi(freq) := TMR1H ; Lo(freq) := TMR1L;
TMR1L := 0; TMR1H := 0;
T1CON := %00000011; new_second:=true;
int_sec_count := 125; end;
TMR2IF_bit := 0;
end;
end;
end.