type TForm2 = class(TForm)
ListBox1: TListBox;
RadioGroup1: TRadioGroup;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
CheckBox1: TCheckBox;
Label1: TLabel;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
ComboBox1: TComboBox;
Label5: TLabel;
Label6: TLabel;
MaskEdit1: TMaskEdit;
Label2: TLabel;
MaskEdit2: TMaskEdit;
MaskEdit3: TMaskEdit;
Label3: TLabel;
Label4: TLabel;
MaskEdit4: TMaskEdit;
MaskEdit5: TMaskEdit;
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure ListBoxClick(Sender: TObject);
procedure Form2Create(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure MaskEdit1KeyPress(Sender: TObject; var Key: Char);
procedure MaskEdit1Change(Sender: TObject);
procedure MaskEdit2KeyPress(Sender: TObject; var Key: Char);
procedure MaskEdit2Change(Sender: TObject);
procedure MaskEdit3KeyPress(Sender: TObject; var Key: Char);
procedure MaskEdit4KeyPress(Sender: TObject; var Key: Char);
procedure MaskEdit4Change(Sender: TObject);
procedure MaskEdit3Change(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
index:integer;
count:integer;
buf:array[0..1023]of byte;
function StrToHex(str:string):integer;
public
{ Public declarations }
end;
var Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm2.RadioButton1Click(Sender: TObject);
begin
MaskEdit5.Enabled := false;
Label6.Enabled := false;
ComboBox1.Enabled := true;
Label5.Enabled := true;
end;
procedure TForm2.RadioButton2Click(Sender: TObject);
begin
ComboBox1.Enabled := false;
Label5.Enabled := false;
MaskEdit5.Enabled := true;
Label6.Enabled := true;
end;
procedure TForm2.ListBoxClick(Sender: TObject);
var
s:string;
begin
s:=
ListBox1.Items.ValueFromIndex[ListBox1.ItemIndex];
index := ListBox1.ItemIndex;
MaskEdit1.Text := s[4]+s[5];
end;
procedure TForm2.Form2Create(Sender: TObject);
var
i,j:integer;
s,s1:string;
begin
count := 1024;
index := 0;
ListBox1.Clear;
for i := 0 to count-1 do
begin
s := Format('%x',[i]);
for j := 1 to 3-length(s) do
s1 := s1 + '0';
for j := 1 to length(s) do
s1 := s1 + s[j];
ListBox1.Items.Add(s1+':00');
s1 := '';
buf[i] := 0;
end;
end;
procedure TForm2.CheckBox1Click(Sender: TObject);
begin
if (CheckBox1.Checked = True) then
Form1.Visible := true;
end;
procedure TForm2.MaskEdit1KeyPress(Sender: TObject; var Key: Char);
begin
if not(((Key >= '0') and (Key <= '9')) or
((Key >= 'A') and (Key <= 'F')) or
((Key >= 'a') and (Key <= 'f'))) then
Key := ' ';
if (Key >= 'a') and (Key <= 'f') then
Key := UpCase(Key)
end;
procedure TForm2.MaskEdit1Change(Sender: TObject);
var
s,s1,s2:string;
i:byte;
begin
s1 := '';
s := Format('%x',[index]);
for i := 1 to 3-length(s) do
s1 := s1 + '0';
for i := 1 to length(s) do
s1 := s1 + s[i];
s2 := s1 + ':';
s1 := '';
s := Format('%x',[StrToHex(MaskEdit1.Text)]);
for i := 1 to 2-length(s) do
s1 := s1 + '0';
for i := 1 to length(s) do
s1 := s1 + s[i];
buf[index] := StrToHex(MaskEdit1.Text);
s2 := s2 + s1;
ListBox1.Items.Strings[index] := s2;
end;
procedure TForm2.MaskEdit2KeyPress(Sender: TObject; var Key: Char);
var
i,j:integer;
s,s1:string;
begin
if not((Key >= '0') and (Key <= '9') or
(Key = #13)) then
Key := ' ';
if Key = #13 then
begin
ListBox1.Clear;
for i := 0 to count-1 do
begin
s := Format('%x',[i]);
for j := 1 to 3-length(s) do
s1 := s1 + '0';
for j := 1 to length(s) do
s1 := s1 + s[j];
ListBox1.Items.Add(s1+':00');
s1 := '';
end;
end;
end;
procedure TForm2.MaskEdit2Change(Sender: TObject);
var
i:integer;
s,s1:string;
begin
s1 := '';
s := MaskEdit2.Text;
if s <> '' then
for i := 1 to length(s) do
if s[i] <> ' ' then s1 := s1 + s[i];
if s1 <> '' then
begin
if (StrToInt(s1) > 1024) then
begin
MaskEdit2.Text := '1024';
count := 1024;
end;
count := StrToInt(s1);
end;
end;
function TForm2.StrToHex(str:string):integer;
var
i,num:integer;
begin
num := 0;
if (length(str) > 0) and (length(str) < 5) then
for i := length(str) downto 1 do
begin
if ((str[i] >= '0')and(str[i] <= '9')) then
num := num + (byte(str[i])-byte('0'))shl(4*(length(str)-i));
if ((str[i] >= 'A')and(str[i] <= 'F')) then
num := num + (byte(str[i])-byte('A')+10)shl(4*(length(str)-i));
if ((str[i] >= 'a')and(str[i] <= 'f')) then
num := num + (byte(str[i])-byte('a')+10)shl(4*(length(str)-i));
end;
StrToHex := num;
end;
procedure TForm2.MaskEdit3KeyPress(Sender: TObject; var Key: Char);
begin
if not(((Key >= '0') and (Key <= '9')) or
((Key >= 'A') and (Key <= 'F')) or
((Key >= 'a') and (Key <= 'f'))) then
Key := ' ';
if (Key >= 'a') and (Key <= 'f') then
Key := UpCase(Key);
end;
procedure TForm2.MaskEdit4KeyPress(Sender: TObject; var Key: Char);
begin
if not(((Key >= '0') and (Key <= '9')) or
((Key >= 'A') and (Key <= 'F')) or
((Key >= 'a') and (Key <= 'f'))) then
Key := ' ';
if (Key >= 'a') and (Key <= 'f') then
Key := UpCase(Key);
end;
procedure TForm2.MaskEdit4Change(Sender: TObject);
begin
if MaskEdit4.Text <> '' then
begin
if StrToHex(MaskEdit4.Text) > count-1 then
MaskEdit4.Text := Format('%3x', [count-1]);
if StrToHex(MaskEdit4.Text) < StrToHex(MaskEdit3.Text) then
MaskEdit4.Text := MaskEdit3.Text;
end;
end;
procedure TForm2.MaskEdit3Change(Sender: TObject);
begin
if MaskEdit3.Text <> '' then
begin
if StrToHex(MaskEdit3.Text) > count-1 then
MaskEdit3.Text := Format('%3x', [count-1]);
if StrToHex(MaskEdit4.Text) < StrToHex(MaskEdit3.Text) then
MaskEdit3.Text := MaskEdit4.Text;
end;
end;
procedure TForm2.BitBtn1Click(Sender: TObject);
var
i:integer;
//a:array[1..]
begin
BitBtn1.Enabled := False;
BitBtn2.Enabled := True;
//Form1.SerialPortNG1.SendData();
Form1.SerialPortNG1.SendData(@buf[StrToHex(MaskEdit3.Text)],StrToHex(MaskEdit4.Text)-StrToHex(MaskEdit3.Text));
end;
procedure TForm2.BitBtn2Click(Sender: TObject);
begin
BitBtn1.Enabled := True;
BitBtn2.Enabled := False;
end;
end.
Ім’я данного файлу : Unit3.pas
Функціональне призначення : програмне забеспечення ПК, модуль головного вікна ВВК
Файл створений для дипломного проекта захисту кваліфікації фахівця
За фахом : Системне програмування;
Тема проекту : Віртуальний вимірювальний комплекс на базі учбового лабораторного стенду;
Керівник : М.В. Скородєлов, викладач кафедри ОТП;
Розробник : О.О. Ісмаілов, студент групи КІТ-23а;
Рік розробки : 2009.
unit Unit3;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons;
type TForm3 = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
Label1: TLabel;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var Form3: TForm3;
implementation
uses Unit1, Unit2;
{$R *.dfm}
procedure TForm3.BitBtn1Click(Sender: TObject);
begin
Form1.Visible := True;
end;
procedure TForm3.BitBtn2Click(Sender: TObject);
begin
Form2.Visible := true;
end;
end.
Ім’я данного файлу : main.asm
Функціональне призначення : програмне забеспечення ПК, модуль логічного аналізатора
Файл створений для дипломного проекта захисту кваліфікації фахівця
За фахом : Системне програмування;
Тема проекту : Віртуальний вимірювальний комплекс на базі учбового лабораторного стенду;
Керівник : М.В. Скородєлов, викладач кафедри ОТП;
Розробник : О.О. Ісмаілов, студент групи КІТ-23а;
Рік розробки : 2009.
#include <m8515def.inc>
.def tmp = r16
.def tmp1 = r17
.def RX_flag = r18
.def RX_Counter = r19
.def RX_Complete = r20
.def command = r21
.def tmp2 = r22
.def tmp3 = r23
.equ UC_REG = 0xC000
.equ RX_Buffer = 0x7C00
.macro USART_TRANSMITT_M
utm_l0:
wdr
sbis UCSRA, UDRE
rjmp utm_l0
out UDR, tmp
.endm
.macro WAIT_PUSK
mov tmp, command
andi tmp, 0b00010000
brne wp_l5
mov tmp, command
andi tmp, 0b00001110
lsr tmp
ldi tmp1, 1
wp_l0:
cpi tmp, 0
breq wp_l1
lsl tmp1
dec tmp
brne wp_l0
wp_l1:
mov tmp, command
andi tmp, 0b00000001
brne wp_l2
wp_l3:
wdr
in tmp2, PINB
and tmp2, tmp1
brne wp_l3
wp_l4:
wdr
in tmp2, PINB
and tmp2, tmp1
breq wp_l4
rjmp wp_l5
wp_l2:
wdr
in tmp2, PINB
and tmp2, tmp1
breq wp_l2
wp_l6:
wdr
in tmp2, PINB
and tmp2, tmp1
brne wp_l6
wp_l5:
.endm
.macro ANALYZE_CLK_6
ac6_l0:
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
dec tmp3 // 1 cycle
brne ac6_l0 // 2 cycles or
// 1 cycle
dec tmp3 // 1 cycle
ac6_l1:
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
dec tmp3 // 1 cycle
brne ac6_l1 // 2 cycles
dec tmp3
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
.endm
.macro ANALYZE_CLK_8
ac8_l0:
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
nop // +2 cyle
nop
dec tmp3 // 1 cycle
brne ac8_l0 // 2 cycles or
// 1 cycle
dec tmp3 // 1 cycle
ac8_l1:
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
nop // +2 cyle
nop
dec tmp3 // 1 cycle
brne ac8_l1 // 2 cycles
dec tmp3
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
.endm
.macro ANALYZE_CLK_16
ac16_l0:
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
ldi tmp1, 3 // +10 cyle
ac16_l2:
dec tmp1
brne ac16_l2
nop
dec tmp3 // 1 cycle
brne ac16_l0 // 2 cycles or
// 1 cycle
dec tmp3 // 1 cycle
ac16_l1:
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
ldi tmp1, 3 // +10 cyle
ac16_l3:
dec tmp1
brne ac16_l3
nop
dec tmp3 // 1 cycle
brne ac16_l1 // 2 cycles
dec tmp3
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
.endm
.macro ANALYZE_CLK_32
ac32_l0:
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
ldi tmp1, 8 // +26 cyle
ac32_l2:
dec tmp1
brne ac32_l2
nop
nop
dec tmp3 // 1 cycle
brne ac32_l0 // 2 cycles or
// 1 cycle
dec tmp3 // 1 cycle
ac32_l1:
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
ldi tmp1, 8 // +26 cyle
ac32_l3:
dec tmp1
brne ac32_l3
nop
nop
dec tmp3 // 1 cycle
brne ac32_l3 // 2 cycles
dec tmp3
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
.endm
.macro ANALYZE_CLK_64
ac64_l0:
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
ldi tmp1, 19 // +58 cyle
ac64_l2:
dec tmp1
brne ac64_l2
nop
dec tmp3 // 1 cycle
brne ac64_l0 // 2 cycles or
// 1 cycle
dec tmp3 // 1 cycle
ac64_l1:
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
ldi tmp1, 19 // +58 cyle
ac64_l3:
dec tmp1
brne ac64_l3
nop
dec tmp3 // 1 cycle
brne ac64_l1 // 2 cycles
dec tmp3
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
.endm
.macro ANALYZE_CLK_128
ac128_l0:
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
ldi tmp1, 40 // +122 cyle
ac128_l2:
dec tmp1
brne ac128_l2
nop
nop
dec tmp3 // 1 cycle
brne ac128_l0 // 2 cycles or
// 1 cycle
dec tmp3 // 1 cycle
ac128_l1:
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
ldi tmp1, 40 // +122 cyle
ac128_l3:
dec tmp1
brne ac128_l3
nop
nop
dec tmp3 // 1 cycle
brne ac128_l1 // 2 cycles
dec tmp3
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
.endm
.macro ANALYZE_CLK_256
ac256_l0:
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
ldi tmp1, 83 // +250 cyle
ac256_l2:
dec tmp1
brne ac256_l2
nop
dec tmp3 // 1 cycle
brne ac256_l0 // 2 cycles or
// 1 cycle
dec tmp3 // 1 cycle
ac256_l1:
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
ldi tmp1, 83 // +250 cyle
ac256_l3:
dec tmp1
brne ac256_l3
nop
dec tmp3 // 1 cycle
brne ac256_l1 // 2 cycles
dec tmp3
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
.endm
.macro ANALYZE_CLK_VN
acv_l0:
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
dec tmp3 // 1 cycle
brne acv_l0 // 2 cycles or
// 1 cycle
dec tmp3 // 1 cycle
acv_l1:
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
dec tmp3 // 1 cycle
brne acv_l1 // 2 cycles
dec tmp3
in tmp, PINB // 1 cycle
st Y+, tmp // 2 cycle
.endm
.org 0
rjmp RESET
nop;rjmp INT0
nop;rjmp INT1
nop;rjmp TIMER1_CAPT
nop;rjmp TIMER1_COMPA
nop;rjmp TIMER1_COMPB
nop;rjmp TIMER1_OVF
rjmp TIMER0_OVF
nop;rjmp SPI_STC
rjmp USART_RXC
nop;rjmp USART_UDRE
nop;rjmp USART_TXC
nop;rjmp ANA_COMP
nop;rjmp INT2
nop;rjmp TIMER0_COMP
nop;rjmp EE_RDY
nop;rjmp SPM_RDY
RESET:
; set stack pointer to top of RAM
ldi tmp, high(RAMEND)
out SPH, tmp
ldi tmp, low(RAMEND)
out SPL, tmp
; enable WDT with 2,1s timeout
ldi tmp, (1<<WDE)|(7<<WDP0)
out WDTCR, tmp
; enable external SRAM
ldi tmp, (1<<SRE)|(1<<SRW10)