[an error occurred while processing this directive] [an error occurred while processing this directive]
Ответ:Извените за язык
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)
[an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive]

Отправлено KOT 30 января 2002 г. 13:35
В ответ на: Код в студию, plz отправлено Vit 30 января 2002 г. 13:31

program tax;

{ $W+ Warnings} {Warnings off}

Device = 90S4434, VCC=5;

Import {SysTick, SerPort,} LCDport;

From System Import LongWord, LongInt,Float;

Define
ProcClock = 7372800; {Hertz}
//SysTick = 10; {msec}
StackSize = $0032, iData;
FrameSize = $0008, iData;
//SerPort = 57600, Stop2; {Baud, StopBits|Parity}
//RxBuffer = 8, iData;
//TxBuffer = 8, iData;
LCDport = PortC;
LCDtype = 66712;//0070;//44780;
LCDrows = 2; {rows}
LCDcolumns = 16; {columns per line}


Implementation

{$IDATA}

{--------------------------------------------------------------}
{ Type Declarations }

type


{--------------------------------------------------------------}
{ Const Declarations }
const
z:byte=2;


{--------------------------------------------------------------}
{ Var Declarations }
{$IDATA}
var

fl_period:float;
dn,dt:float;
uskr:float;
flagperiod:boolean;
nz:byte;
period:longword;
bp0[@period]:byte;
bp1[@period+1]:byte;
bp2[@period+2]:byte;
bp3[@period+3]:byte;
bp2_,bp3_:byte;
n,nbuf:float;
_flags:byte;
wa1,wa2:byte;
{--------------------------------------------------------------}
{ functions }

procedure capture;
begin
flagperiod:=true;
bp0:=ICR1L;
bp1:=ICR1H;
TCNT1H:=$00;
TCNT1L:=$00;
bp2:=bp2_;
bp3:=bp3_;
nz:=1;
end;

interrupt timer1;
begin
//disableints;
// wa2:=TCNT1L;
// wa1:=TCNT1H;
//if wa2<$45 then
// TCNT1H:=$00;
// TCNT1L:=$42;
// endif;
inc(bp2_);
if bp2_=0 then inc(bp3_); endif;
// wa2:=TCNT1L;
// wa1:=TCNT1H;



// setbit(_flags,0,true);
// if bit(TIFR,5) then
// if nz=z then
// capture;
// else
// inc(nz);
// endif;
// setbit(TIFR,5,true);
// endif;
//if tifr<>$18 then wa1:=TIFR; endif; ///
//enableints;
end;

interrupt timer1capt;
begin
if nz=z then
capture;
//setbit (TIFR,2,true);
wa2:=icr1L;
wa1:=icr1H;
else
inc(nz);
endif;
end;



{--------------------------------------------------------------}
{ Main Program }
{$IDATA}

begin
flagperiod:=false;
nbuf:=0;
nz:=0;
TCCR1B:=$C1; ///////////
TIMSK:=$25;
LCDctrl($2f);
LCDctrl($0c);
LCDctrl($01);
LCDctrl($02);
EnableInts;
loop
if flagperiod then
fl_period:=float(period);
n:=$1A5E0000/fl_period;
LCDctrl($02); //inhome
write(lcdOut,floattostr(n:4:0)+' RPM ');
//write(lcdOut,floattostr(fl_period:4:2)+' RPM '+bytetohex(timsk));

dn:=n-nbuf;
dt:=fl_period/$708000;
uskr:=dn/dt;
LCDxy(0,2);
write(lcdOut,bytetohex(bp3)+bytetohex(bp2)+bytetohex(bp1)+bytetohex(bp0)+' '+bytetohex(wa1)+' '+bytetohex(wa2));
// write(lcdOut,floattostr(uskr:7:1)+' RPMPS ');
flagperiod:=false;
nbuf:=n;
period:=0;
bp2_:=0;
bp3_:=0;
// _flags:=0;
endif;
endloop;
end tax.

Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru