1 |
{$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,R+,S+,V+,X-} |
1 |
{$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,R+,S+,V+,X-} |
2 |
{$M 16384,0,655360} |
2 |
{$M 16384,0,655360} |
3 |
|
3 |
|
4 |
program PicPgr(Input,Output); |
4 |
program PicPgr(Input,Output); |
5 |
|
5 |
|
6 |
{=============================================================} |
6 |
{=============================================================} |
7 |
{== Program pro programovani ruznych PICu ( FLASH i EPROM ) ==} |
7 |
{== Program pro programovani ruznych PICu ( FLASH i EPROM ) ==} |
8 |
{=============================================================} |
8 |
{=============================================================} |
9 |
|
9 |
|
10 |
uses DELAY, { casova spozdeni } |
10 |
uses DELAY, { casova spozdeni } |
11 |
PP_PGMHW, { ovladani hardwaru programatoru } |
11 |
PP_PGMHW, { ovladani hardwaru programatoru } |
12 |
PP_COMON, { pomocne funkce } |
12 |
PP_COMON, { pomocne funkce } |
13 |
PP_DEFS, { defince procesorove zavislych parametru } |
13 |
PP_DEFS, { defince procesorove zavislych parametru } |
14 |
PP_DATA, { ulozeni dat v pameti } |
14 |
PP_DATA, { ulozeni dat v pameti } |
15 |
PP_IO; { import a export dat z/do souboru } |
15 |
PP_IO; { import a export dat z/do souboru } |
16 |
|
16 |
|
17 |
const ver : string[4] = '4.12'; { vzdy 4 znaky } |
17 |
const ver : string[4] = '4.12'; { vzdy 4 znaky } |
18 |
date : string[4] = '2004'; { vzdy 4 znaky } |
18 |
date : string[4] = '2004'; { vzdy 4 znaky } |
19 |
|
19 |
|
20 |
{=============================================================} |
20 |
{=============================================================} |
21 |
{ Zmeny: } |
21 |
{ Zmeny: } |
22 |
{ 2.01 - vychozi verze pro tuto verzi } |
22 |
{ 2.01 - vychozi verze pro tuto verzi } |
23 |
{ 3.00 - predelana kompletne vrstva pro ovladani HW ( moznost } |
23 |
{ 3.00 - predelana kompletne vrstva pro ovladani HW ( moznost } |
24 |
{ popdory vice programatoru ) } |
24 |
{ popdory vice programatoru ) } |
25 |
{ 3.01 - finalni verze s podporou programovani pres LPT port } |
25 |
{ 3.01 - finalni verze s podporou programovani pres LPT port } |
26 |
{ a na programatoru ALL03 } |
26 |
{ a na programatoru ALL03 } |
27 |
{ 3.10 - pridana informace o zdoji dat pri vystupu v TXT } |
27 |
{ 3.10 - pridana informace o zdoji dat pri vystupu v TXT } |
28 |
{ formatu } |
28 |
{ formatu } |
29 |
{ - cislovani radek pri vypisu chyby ve vstupnich datech } |
29 |
{ - cislovani radek pri vypisu chyby ve vstupnich datech } |
30 |
{ - odstranena chyba exportu dat v HEX formatu } |
30 |
{ - odstranena chyba exportu dat v HEX formatu } |
31 |
{ - dodelana kontrola kontrolniho souctu HEX formatu } |
31 |
{ - dodelana kontrola kontrolniho souctu HEX formatu } |
32 |
{ - znovu zprovozneny prikazy RUN, STOP, RESET } |
32 |
{ - znovu zprovozneny prikazy RUN, STOP, RESET } |
33 |
{ - zmena default obsahu pri konverzi z 0 na 3FFF } |
33 |
{ - zmena default obsahu pri konverzi z 0 na 3FFF } |
34 |
{ 3.11 - cisla ve zdrojaku nahrazena konstantami } |
34 |
{ 3.11 - cisla ve zdrojaku nahrazena konstantami } |
35 |
{ 4.00 - velmi rozsahle zmeny ve strukture } |
35 |
{ 4.00 - velmi rozsahle zmeny ve strukture } |
36 |
{ - prepinani parametru podle typu soucastky } |
36 |
{ - prepinani parametru podle typu soucastky } |
37 |
{ - zmena Vpp z 12.0V na 13.0V } |
37 |
{ - zmena Vpp z 12.0V na 13.0V } |
38 |
{ - doplneno zpozdeni po zapnuti napajeni } |
38 |
{ - doplneno zpozdeni po zapnuti napajeni } |
39 |
{ - zmena programovacich casu u C/F84 (20ms na 10ms) } |
39 |
{ - zmena programovacich casu u C/F84 (20ms na 10ms) } |
40 |
{ - podpora ErrorLevel pri programovani a verifikaci } |
40 |
{ - podpora ErrorLevel pri programovani a verifikaci } |
41 |
{ 4.01 - prvni realese verze z rady 4.x } |
41 |
{ 4.01 - prvni realese verze z rady 4.x } |
42 |
{ 4.02 - doplnena podpora algoritmu EEPROM1 PEFI } |
42 |
{ 4.02 - doplnena podpora algoritmu EEPROM1 PEFI } |
43 |
{ 4.10 - doplnena podpora PIC16F87xA (novy algoritmus EE3 } |
43 |
{ 4.10 - doplnena podpora PIC16F87xA (novy algoritmus EE3 } |
44 |
{ a nove prepinace, neni dodelana veririkace !) } |
44 |
{ a nove prepinace, neni dodelana veririkace !) } |
45 |
{ 4.11 - doplnena podpora PIC16F627A/628A/648A (novy alg EE4) } |
45 |
{ 4.11 - doplnena podpora PIC16F627A/628A/648A (novy alg EE4) } |
46 |
{ doplnena podpora PIC16F818/819 (novy alg EE5) } |
46 |
{ doplnena podpora PIC16F818/819 (novy alg EE5) } |
47 |
{ dodelana podpora PIC16F87xA (EE3) } |
47 |
{ dodelana podpora PIC16F87xA (EE3) } |
48 |
{ 4.12 - kosmeticke upravy } |
48 |
{ 4.12 - kosmeticke upravy } |
49 |
{ Chybi: } |
49 |
{ Chybi: } |
50 |
{ - podpora algoritmu EPROM3 } |
50 |
{ - podpora algoritmu EPROM3 } |
51 |
{ - zpracovani prepinacu pro Cfg slovo jinych nez PIC16F } |
51 |
{ - zpracovani prepinacu pro Cfg slovo jinych nez PIC16F } |
52 |
{ - export jen platnych dat ( HEX i TXT ) } |
52 |
{ - export jen platnych dat ( HEX i TXT ) } |
53 |
{=============================================================} |
53 |
{=============================================================} |
54 |
|
54 |
|
55 |
|
55 |
|
56 |
{====== Rizeni programatoru - propojeni s HW ======} |
56 |
{====== Rizeni programatoru - propojeni s HW ======} |
57 |
|
57 |
|
58 |
const P:PGM_p = nil; { Inicializovana promenna } |
58 |
const P:PGM_p = nil; { Inicializovana promenna } |
59 |
|
59 |
|
60 |
procedure InitHW(Port:word); |
60 |
procedure InitHW(Port:word); |
61 |
{== Procedura inicializuje propojeni s HW ==} |
61 |
{== Procedura inicializuje propojeni s HW ==} |
62 |
begin if port<4 then P:=new(PGM_LPT_p,Init(Port)) |
62 |
begin if port<4 then P:=new(PGM_LPT_p,Init(Port)) |
63 |
else P:=new(PGM_ALL_P,Init(Port)); |
63 |
else P:=new(PGM_ALL_P,Init(Port)); |
64 |
if P=nil then Error('Unable Init HW',0); |
64 |
if P=nil then Error('Unable Init HW',0); |
65 |
end; {InitHW} |
65 |
end; {InitHW} |
66 |
|
66 |
|
67 |
const StartPICStat:boolean=false; { true po dobu programovani } |
67 |
const StartPICStat:boolean=false; { true po dobu programovani } |
68 |
{ Tuto promennou nastavuje procedura StartPIC a vypina procedura } |
68 |
{ Tuto promennou nastavuje procedura StartPIC a vypina procedura } |
69 |
{ StopPIC. Je tedy aktivni zejmena po dobu programovani a slouzi } |
69 |
{ StopPIC. Je tedy aktivni zejmena po dobu programovani a slouzi } |
70 |
{ pro zajisteni vypnuti programovaciho napeti v pripade } |
70 |
{ pro zajisteni vypnuti programovaciho napeti v pripade } |
71 |
{ ze program skonci predcasne. } |
71 |
{ ze program skonci predcasne. } |
72 |
|
72 |
|
73 |
procedure StartPIC(Voltage:real); |
73 |
procedure StartPIC(Voltage:real); |
74 |
{== Zapnuti PIC pro programovani, cteni, verifikaci ==} |
74 |
{== Zapnuti PIC pro programovani, cteni, verifikaci ==} |
75 |
{ Voltage udava pracovni napajeci napeti } |
75 |
{ Voltage udava pracovni napajeci napeti } |
76 |
begin StartPICStat:=true; { true znamena programovani } |
76 |
begin StartPICStat:=true; { true znamena programovani } |
77 |
{-- nastav definovany stav signalu --} |
77 |
{-- nastav definovany stav signalu --} |
78 |
P^.SetReset(zero); { aktivuj reset } |
78 |
P^.SetReset(zero); { aktivuj reset } |
79 |
P^.SetVcc(Voltage); { zapni napajeni } |
79 |
P^.SetVcc(Voltage); { zapni napajeni } |
80 |
P^.SetData(zero); { otevri budice } |
80 |
P^.SetData(zero); { otevri budice } |
81 |
P^.SetClock(zero); |
81 |
P^.SetClock(zero); |
82 |
xDelay(50); { ustaleni napeti } |
82 |
xDelay(50); { ustaleni napeti } |
83 |
P^.SetReset(one); { ukonci reset } |
83 |
P^.SetReset(one); { ukonci reset } |
84 |
P^.SetVpp(13.0); { zapni Vpp } |
84 |
P^.SetVpp(13.0); { zapni Vpp } |
85 |
|
85 |
|
86 |
xDelay(50); { ustaleni napeti } |
86 |
xDelay(50); { ustaleni napeti } |
87 |
end; {StartPIC} |
87 |
end; {StartPIC} |
88 |
|
88 |
|
89 |
procedure EndPIC; |
89 |
procedure EndPIC; |
90 |
{== Vypnuti PIC po programovani ==} |
90 |
{== Vypnuti PIC po programovani ==} |
91 |
begin P^.SetData(tristate); { odpoj vystupy } |
91 |
begin P^.SetData(tristate); { odpoj vystupy } |
92 |
P^.SetClock(tristate); |
92 |
P^.SetClock(tristate); |
93 |
P^.SetVpp(0); { odpoj Vpp } |
93 |
P^.SetVpp(0); { odpoj Vpp } |
94 |
P^.SetReset(zero); { aktivuj reset } |
94 |
P^.SetReset(zero); { aktivuj reset } |
95 |
P^.SetVcc(0); { vypni Vcc } |
95 |
P^.SetVcc(0); { vypni Vcc } |
96 |
xDelay(50); { pockej } |
96 |
xDelay(50); { pockej } |
97 |
P^.SetReset(one); { a odpoj i reset ( pokud je napajeni zvenku ) } |
97 |
P^.SetReset(one); { a odpoj i reset ( pokud je napajeni zvenku ) } |
98 |
{ tak se to rozbehne } |
98 |
{ tak se to rozbehne } |
99 |
StartPICStat:=false; { false znamena konec programovani } |
99 |
StartPICStat:=false; { false znamena konec programovani } |
100 |
end; {EndPIC} |
100 |
end; {EndPIC} |
101 |
|
101 |
|
102 |
{====== Posilani prikazu a dat do a z procesoru ======} |
102 |
{====== Posilani prikazu a dat do a z procesoru ======} |
103 |
|
103 |
|
104 |
procedure OutCommandPIC(Command:word); |
104 |
procedure OutCommandPIC(Command:word); |
105 |
{== Zapise prikaz ( bez dat ) do PIC ==} |
105 |
{== Zapise prikaz ( bez dat ) do PIC ==} |
106 |
var i:integer; |
106 |
var i:integer; |
107 |
begin for i:=1 to 6 do |
107 |
begin for i:=1 to 6 do |
108 |
begin if (Command and 1)=1 then P^.SetData(one) |
108 |
begin if (Command and 1)=1 then P^.SetData(one) |
109 |
else P^.SetData(zero); |
109 |
else P^.SetData(zero); |
110 |
P^.SetClock(one); |
110 |
P^.SetClock(one); |
111 |
P^.SetClock(zero); |
111 |
P^.SetClock(zero); |
112 |
Command:=Command shr 1; |
112 |
Command:=Command shr 1; |
113 |
end; |
113 |
end; |
114 |
P^.SetData(tristate); { odpoj datovy vystup } |
114 |
P^.SetData(tristate); { odpoj datovy vystup } |
115 |
end; {OutCommandPIC} |
115 |
end; {OutCommandPIC} |
116 |
|
116 |
|
117 |
procedure OutputDataPIC(Bits:word; Command:word; Data:word); |
117 |
procedure OutputDataPIC(Bits:word; Command:word; Data:word); |
118 |
{== Zapise prikaz a data do PIC ==} |
118 |
{== Zapise prikaz a data do PIC ==} |
119 |
{ Prenasi se bud 14 ( obvody 12 nebo 14 bitu core ) nebo 16 ( soucastky } |
119 |
{ Prenasi se bud 14 ( obvody 12 nebo 14 bitu core ) nebo 16 ( soucastky } |
120 |
{ s paritou pameti programu ) bitu } |
120 |
{ s paritou pameti programu ) bitu } |
121 |
var i:integer; |
121 |
var i:integer; |
122 |
begin OutCommandPIC(Command); |
122 |
begin OutCommandPIC(Command); |
123 |
P^.SetData(zero); { start bit 0 } |
123 |
P^.SetData(zero); { start bit 0 } |
124 |
P^.SetClock(one); |
124 |
P^.SetClock(one); |
125 |
P^.SetClock(zero); |
125 |
P^.SetClock(zero); |
126 |
for i:=1 to Bits do |
126 |
for i:=1 to Bits do |
127 |
begin if (Data and 1)=1 then P^.SetData(one) { data bit } |
127 |
begin if (Data and 1)=1 then P^.SetData(one) { data bit } |
128 |
else P^.SetData(zero); |
128 |
else P^.SetData(zero); |
129 |
P^.SetClock(one); |
129 |
P^.SetClock(one); |
130 |
P^.SetClock(zero); |
130 |
P^.SetClock(zero); |
131 |
Data:=Data shr 1; |
131 |
Data:=Data shr 1; |
132 |
end; |
132 |
end; |
133 |
P^.SetData(zero); { stop bit 0 } |
133 |
P^.SetData(zero); { stop bit 0 } |
134 |
P^.SetClock(one); |
134 |
P^.SetClock(one); |
135 |
P^.SetClock(zero); |
135 |
P^.SetClock(zero); |
136 |
end; {OutputDataPIC} |
136 |
end; {OutputDataPIC} |
137 |
|
137 |
|
138 |
function InputDataPIC(Bits:word; Command:word):word; |
138 |
function InputDataPIC(Bits:word; Command:word):word; |
139 |
{== Posli prikaz a vrat odpoved z PIC ==} |
139 |
{== Posli prikaz a vrat odpoved z PIC ==} |
140 |
{ Precte zadany pocet bitu dat. Tento pocet nemusi } |
140 |
{ Precte zadany pocet bitu dat. Tento pocet nemusi } |
141 |
{ nutne souhlasit s poctem platnych bitu dat } |
141 |
{ nutne souhlasit s poctem platnych bitu dat } |
142 |
{ ( napriklad u souvasti s delkou slova 12 bitu ). } |
142 |
{ ( napriklad u souvasti s delkou slova 12 bitu ). } |
143 |
var Data:word; |
143 |
var Data:word; |
144 |
i:integer; |
144 |
i:integer; |
145 |
b:word; |
145 |
b:word; |
146 |
begin OutCommandPIC(Command); { zanecha DATA jako vstup } |
146 |
begin OutCommandPIC(Command); { zanecha DATA jako vstup } |
147 |
Data:=0; |
147 |
Data:=0; |
148 |
b:=1; { bitova maska } |
148 |
b:=1; { bitova maska } |
149 |
P^.SetClock(one); { start bit } |
149 |
P^.SetClock(one); { start bit } |
150 |
P^.SetClock(zero); |
150 |
P^.SetClock(zero); |
151 |
for i:=1 to Bits do |
151 |
for i:=1 to Bits do |
152 |
begin P^.SetClock(one); |
152 |
begin P^.SetClock(one); |
153 |
P^.SetClock(zero); |
153 |
P^.SetClock(zero); |
154 |
if P^.GetData then Data:=Data or b; { byla datova 1 } |
154 |
if P^.GetData then Data:=Data or b; { byla datova 1 } |
155 |
b:=b shl 1; { posun masku } |
155 |
b:=b shl 1; { posun masku } |
156 |
end; |
156 |
end; |
157 |
P^.SetClock(one); { stop bit } |
157 |
P^.SetClock(one); { stop bit } |
158 |
P^.SetClock(zero); |
158 |
P^.SetClock(zero); |
159 |
InputDataPIC:=Data; |
159 |
InputDataPIC:=Data; |
160 |
end; {InputDataPIC} |
160 |
end; {InputDataPIC} |
161 |
|
161 |
|
162 |
{====== Programovaci prikazy pro PIC ======} |
162 |
{====== Programovaci prikazy pro PIC ======} |
163 |
|
163 |
|
164 |
const LoadConfiguration_00 = $00; { nastav PC na 2000H } |
164 |
const LoadConfiguration_00 = $00; { nastav PC na 2000H } |
165 |
LoadDataPM_02 = $02; { predej data pro PM } |
165 |
LoadDataPM_02 = $02; { predej data pro PM } |
166 |
ReadDataPM_04 = $04; { precti data z PM } |
166 |
ReadDataPM_04 = $04; { precti data z PM } |
167 |
IncrementAddress_06 = $06; { posun PC o 1 } |
167 |
IncrementAddress_06 = $06; { posun PC o 1 } |
168 |
BeginProgramming_08 = $08; { zahaj programovani, u nekterych clenu i mazani radky } |
168 |
BeginProgramming_08 = $08; { zahaj programovani, u nekterych clenu i mazani radky } |
169 |
BeginProgrammingOnlyCycle_18 = $18; { zacni zapisovat, obvykle bez mazani } |
169 |
BeginProgrammingOnlyCycle_18 = $18; { zacni zapisovat, obvykle bez mazani } |
170 |
LoadDataDM_03 = $03; { predej data pro DM } |
170 |
LoadDataDM_03 = $03; { predej data pro DM } |
171 |
ReadDataDM_05 = $05; { precti data z DM } |
171 |
ReadDataDM_05 = $05; { precti data z DM } |
172 |
BulkErasePM_09 = $09; { smaz celou PM (pokud neni zamcena) } |
172 |
BulkErasePM_09 = $09; { smaz celou PM (pokud neni zamcena) } |
173 |
BulkEraseDM_0B = $0B; { smaz celou DM (pokud neni zamcena) } |
173 |
BulkEraseDM_0B = $0B; { smaz celou DM (pokud neni zamcena) } |
174 |
EndProgramming_0E = $0E; { _EPROMx_ - jen pro EPROM verze } |
174 |
EndProgramming_0E = $0E; { _EPROMx_ - jen pro EPROM verze } |
175 |
EndProgramming_17 = $17; { _EE5_ ukonci programovani } |
175 |
EndProgramming_17 = $17; { _EE5_ ukonci programovani } |
176 |
Dis1_01 = $01; { _EEx_ - jen pro odstraneni code } |
176 |
Dis1_01 = $01; { _EEx_ - jen pro odstraneni code } |
177 |
Dis2_07 = $07; { protection } |
177 |
Dis2_07 = $07; { protection } |
178 |
ChipErase_1F = $1F; { smaz celou soucastku (u nekterych na to staci BulkErasePM pokud je PC 2007) } |
178 |
ChipErase_1F = $1F; { smaz celou soucastku (u nekterych na to staci BulkErasePM pokud je PC 2007) } |
179 |
|
179 |
|
180 |
{====== Zpracovani parametru ======} |
180 |
{====== Zpracovani parametru ======} |
181 |
|
181 |
|
182 |
const Port : integer = -1; { Cislo portu pro komunikaci } |
182 |
const Port : integer = -1; { Cislo portu pro komunikaci } |
183 |
FileFormat: IO_t = _NIL_; { Format datoveho souboru } |
183 |
FileFormat: IO_t = _NIL_; { Format datoveho souboru } |
184 |
CfgString : string = ''; { Sem si zapamatuji Cfg retezec } |
184 |
CfgString : string = ''; { Sem si zapamatuji Cfg retezec } |
185 |
{ Nenastaveny ( nepouzity ) prepinac je -1 } |
185 |
{ Nenastaveny ( nepouzity ) prepinac je -1 } |
186 |
|
186 |
|
187 |
{====== Zpracovani prepinacu ======} |
187 |
{====== Zpracovani prepinacu ======} |
188 |
|
188 |
|
189 |
function TestSwitch(var s:string; sw:string):boolean; |
189 |
function TestSwitch(var s:string; sw:string):boolean; |
190 |
{== Pokud je sw soucasti retezce s vraci true a odstrani sw z retezce s ==} |
190 |
{== Pokud je sw soucasti retezce s vraci true a odstrani sw z retezce s ==} |
191 |
var i:integer; |
191 |
var i:integer; |
192 |
begin TestSwitch:=false; |
192 |
begin TestSwitch:=false; |
193 |
{-- test --} |
193 |
{-- test --} |
194 |
i:=pos(sw+' ',s+' '); |
194 |
i:=pos(sw+' ',s+' '); |
195 |
if i=0 then exit; { nenalezen } |
195 |
if i=0 then exit; { nenalezen } |
196 |
{-- nalezen --} |
196 |
{-- nalezen --} |
197 |
s:=copy(s,1,i-1)+copy(s,i+length(sw)+1,255); |
197 |
s:=copy(s,1,i-1)+copy(s,i+length(sw)+1,255); |
198 |
TestSwitch:=true; |
198 |
TestSwitch:=true; |
199 |
end; {TestSwitch} |
199 |
end; {TestSwitch} |
200 |
|
200 |
|
201 |
{====== Zpracovani Cfg parametru ======} |
201 |
{====== Zpracovani Cfg parametru ======} |
202 |
|
202 |
|
203 |
procedure CfgSwitches( var s:string; Ostre:boolean; |
203 |
procedure CfgSwitches( var s:string; Ostre:boolean; |
204 |
var Cfg:word; var CfgStat:boolean |
204 |
var Cfg:word; var CfgStat:boolean |
205 |
); |
205 |
); |
206 |
{== Zpracuje prepinace konfiguracniho slova, pokud je predano true ==} |
206 |
{== Zpracuje prepinace konfiguracniho slova, pokud je predano true ==} |
207 |
{ tak upravi hodnotu predaneho parametru. Uzere z retezce s } |
207 |
{ tak upravi hodnotu predaneho parametru. Uzere z retezce s } |
208 |
{ prepinace, ktere zpracovala } |
208 |
{ prepinace, ktere zpracovala } |
209 |
{ } |
209 |
{ } |
210 |
{ s retezec s parametry, zpracovane casti se uzerou } |
210 |
{ s retezec s parametry, zpracovane casti se uzerou } |
211 |
{ Ostre true znamena, ze se maji data aktualizovat } |
211 |
{ Ostre true znamena, ze se maji data aktualizovat } |
212 |
{ Cfg config data } |
212 |
{ Cfg config data } |
213 |
{ CfgStat priznak platnosti dat v poli Cfg } |
213 |
{ CfgStat priznak platnosti dat v poli Cfg } |
214 |
{ } |
214 |
{ } |
215 |
begin {-- dle typu procesoru preda konkretni procedure --} |
215 |
begin {-- dle typu procesoru preda konkretni procedure --} |
216 |
|
216 |
|
217 |
end; {CfgSwitches} |
217 |
end; {CfgSwitches} |
218 |
|
218 |
|
219 |
procedure DisplayConfigWord(Cfg:word; Cfg_Stat:boolean); |
219 |
procedure DisplayConfigWord(Cfg:word; Cfg_Stat:boolean); |
220 |
begin if Cfg_Stat |
220 |
begin if Cfg_Stat |
221 |
then begin write('Config Word: '); |
221 |
then begin write('Config Word: '); |
222 |
HexWord(output,Cfg); |
222 |
HexWord(output,Cfg); |
223 |
writeln; |
223 |
writeln; |
224 |
end |
224 |
end |
225 |
else begin writeln('Config Word: none'); |
225 |
else begin writeln('Config Word: none'); |
226 |
end; |
226 |
end; |
227 |
end; {DisplayConfigWord} |
227 |
end; {DisplayConfigWord} |
228 |
|
228 |
|
229 |
procedure Switches(s:string; var Data:PicData_t); |
229 |
procedure Switches(s:string; var Data:PicData_t); |
230 |
{== Zpracovani prepinacu, volba typu soucastky, init datoveho objektu ==} |
230 |
{== Zpracovani prepinacu, volba typu soucastky, init datoveho objektu ==} |
231 |
var ix:integer; { index do tabulky CfgDefAll} |
231 |
var ix:integer; { index do tabulky CfgDefAll} |
232 |
Proc:ProcInfo_t; { informace o vybrane procesoru } |
232 |
Proc:ProcInfo_t; { informace o vybrane procesoru } |
233 |
begin s:=UpStr(s); |
233 |
begin s:=UpStr(s); |
234 |
{-- adresa portu --} |
234 |
{-- adresa portu --} |
235 |
if TestSwitch(s,'LPT3' ) then Port := 3; { Z BIOS tabulky } |
235 |
if TestSwitch(s,'LPT3' ) then Port := 3; { Z BIOS tabulky } |
236 |
if TestSwitch(s,'LPT2' ) then Port := 2; |
236 |
if TestSwitch(s,'LPT2' ) then Port := 2; |
237 |
if TestSwitch(s,'LPT1' ) then Port := 1; |
237 |
if TestSwitch(s,'LPT1' ) then Port := 1; |
238 |
if TestSwitch(s,'ALL03') then Port := $2E0; { ALL03 porty } |
238 |
if TestSwitch(s,'ALL03') then Port := $2E0; { ALL03 porty } |
239 |
{-- typ souboru --} |
239 |
{-- typ souboru --} |
240 |
if TestSwitch(s,'HEX' ) then FileFormat:= _HEX_; { Moje cislovani filtru } |
240 |
if TestSwitch(s,'HEX' ) then FileFormat:= _HEX_; { Moje cislovani filtru } |
241 |
if TestSwitch(s,'TEXT' ) then FileFormat:= _TXT_; |
241 |
if TestSwitch(s,'TEXT' ) then FileFormat:= _TXT_; |
242 |
if TestSwitch(s,'TXT' ) then FileFormat:= _TXT_; |
242 |
if TestSwitch(s,'TXT' ) then FileFormat:= _TXT_; |
243 |
{-- Default hodnoty --} |
243 |
{-- Default hodnoty --} |
244 |
if Port = -1 then Port := 1; |
244 |
if Port = -1 then Port := 1; |
245 |
if FileFormat = _NIL_ then FileFormat := _TXT_; |
245 |
if FileFormat = _NIL_ then FileFormat := _TXT_; |
246 |
{-- typ a parametry soucastky --} |
246 |
{-- typ a parametry soucastky --} |
247 |
ProcFind(s,Proc); |
247 |
ProcFind(s,Proc); |
248 |
|
248 |
|
249 |
if Proc.Name='' |
249 |
if Proc.Name='' |
250 |
then begin (* Volba default procesoru je zamerne zaslapnuta protoze mate uzivatele |
250 |
then begin (* Volba default procesoru je zamerne zaslapnuta protoze mate uzivatele |
251 |
ProcFind('PIC16F84',Proc); { Default hodnota } |
251 |
ProcFind('PIC16F84',Proc); { Default hodnota } |
252 |
*) |
252 |
*) |
253 |
end |
253 |
end |
254 |
else if TestSwitch(s,Proc.Name) then; { Sezer pouzitou hodnotu } |
254 |
else if TestSwitch(s,Proc.Name) then; { Sezer pouzitou hodnotu } |
255 |
Data.Init(Proc); |
255 |
Data.Init(Proc); |
256 |
{-- prislusnost soucastky do skupiny pro Cfg prepinace --} |
256 |
{-- prislusnost soucastky do skupiny pro Cfg prepinace --} |
257 |
ix:=CfgFindProcGroup(Proc.Cfg,CfgDefAll); { i je index do konstanty CfgDefAll } |
257 |
ix:=CfgFindProcGroup(Proc.Cfg,CfgDefAll); { i je index do konstanty CfgDefAll } |
258 |
{-- zpracovani prepinacu specifickych pro Cfg slovo --} |
258 |
{-- zpracovani prepinacu specifickych pro Cfg slovo --} |
259 |
{ s ... retezec s prepinacema, ktere jeste nebyly zpracovany } |
259 |
{ s ... retezec s prepinacema, ktere jeste nebyly zpracovany } |
260 |
{ ix ... index do tabulky CfgDefAll s informacemi o prepinacich skupiny } |
260 |
{ ix ... index do tabulky CfgDefAll s informacemi o prepinacich skupiny } |
261 |
CfgString:=CfgX; { prazdny ( sama 'X' Cfg retezec } |
261 |
CfgString:=CfgX; { prazdny ( sama 'X' Cfg retezec } |
262 |
if ix>0 then |
262 |
if ix>0 then |
263 |
begin CfgString:=CfgTestKeyMultiple(s,CfgDefAll[ix]); |
263 |
begin CfgString:=CfgTestKeyMultiple(s,CfgDefAll[ix]); |
264 |
if CfgString='' then Error('Konflicting Cfg switch '+GetWord(s),0); |
264 |
if CfgString='' then Error('Konflicting Cfg switch '+GetWord(s),0); |
265 |
end; |
265 |
end; |
266 |
if s<>'' then Error('Unrecognized switches: '+s,0); |
266 |
if s<>'' then Error('Unrecognized switches: '+s,0); |
267 |
end; {Switches} |
267 |
end; {Switches} |
268 |
|
268 |
|
269 |
{====== Hlavni cinnosti ( akce ) programu ======} |
269 |
{====== Hlavni cinnosti ( akce ) programu ======} |
270 |
|
270 |
|
271 |
procedure Help; |
271 |
procedure Help; |
272 |
{== Vypise navod k pouziti ==} |
272 |
{== Vypise navod k pouziti ==} |
273 |
var i:integer; |
273 |
var i:integer; |
274 |
Proc:ProcInfo_t; |
274 |
Proc:ProcInfo_t; |
275 |
begin writeln('Usage: PICPGR <what_to_do> [<file_name>] [switches]'); |
275 |
begin writeln('Usage: PICPGR <what_to_do> [<file_name>] [switches]'); |
276 |
writeln; |
276 |
writeln; |
277 |
writeln('PICPGR READ <file_name> <procesor> [switches]'); |
277 |
writeln('PICPGR READ <file_name> <procesor> [switches]'); |
278 |
writeln('PICPGR PROGRAM <file_name> <procesor> [switches]'); |
278 |
writeln('PICPGR PROGRAM <file_name> <procesor> [switches]'); |
279 |
writeln('PICPGR VERIFY <file_name> <procesor> [switches]'); |
279 |
writeln('PICPGR VERIFY <file_name> <procesor> [switches]'); |
280 |
writeln('PICPGR ERASE <procesor> [switches]'); |
280 |
writeln('PICPGR ERASE <procesor> [switches]'); |
281 |
writeln('PICPGR RUN [switches]'); |
281 |
writeln('PICPGR RUN [switches]'); |
282 |
writeln('PICPGR STOP [switches]'); |
282 |
writeln('PICPGR STOP [switches]'); |
283 |
writeln('PICPGR RESET [switches]'); |
283 |
writeln('PICPGR RESET [switches]'); |
284 |
writeln('PICPGR CONVERT <file_in> <file_out> [switches]'); |
284 |
writeln('PICPGR CONVERT <file_in> <file_out> [switches]'); |
285 |
writeln; |
285 |
writeln; |
286 |
writeln('Exit: 0 O.K.'); |
286 |
writeln('Exit: 0 O.K.'); |
287 |
writeln(' 1 Generic Error'); |
287 |
writeln(' 1 Generic Error'); |
288 |
writeln(' 100 Program or Verify Error'); |
288 |
writeln(' 100 Program or Verify Error'); |
289 |
writeln; |
289 |
writeln; |
290 |
writeln('Switches: LPT1*, LPT2, LPT3 Development Programmer via LPT'); |
290 |
writeln('Switches: LPT1*, LPT2, LPT3 Development Programmer via LPT'); |
291 |
writeln('*=default ALL03 HI-LO Programmer'); |
291 |
writeln('*=default ALL03 HI-LO Programmer'); |
292 |
writeln(' TXT*, HEX Data File Format'); |
292 |
writeln(' TXT*, HEX Data File Format'); |
293 |
writeln; |
293 |
writeln; |
294 |
PressEnter; |
294 |
PressEnter; |
295 |
writeln('Note: Processor groups can have their own set of switches'); |
295 |
writeln('Note: Processor groups can have their own set of switches'); |
296 |
writeln(' for overiding of Config Word settins.'); |
296 |
writeln(' for overiding of Config Word settins.'); |
297 |
writeln; |
297 |
writeln; |
298 |
writeln(' Boolean type: CP, CP_ON, CP_OFF'); |
298 |
writeln(' Boolean type: CP, CP_ON, CP_OFF'); |
299 |
writeln(' ( CP is CP_ON )'); |
299 |
writeln(' ( CP is CP_ON )'); |
300 |
writeln; |
300 |
writeln; |
301 |
writeln(' Binary string: CP_101'); |
301 |
writeln(' Binary string: CP_101'); |
302 |
writeln(' ( binary digit string must'); |
302 |
writeln(' ( binary digit string must'); |
303 |
writeln(' have corect length )'); |
303 |
writeln(' have corect length )'); |
304 |
writeln; |
304 |
writeln; |
305 |
writeln('Help function:'); |
305 |
writeln('Help function:'); |
306 |
writeln; |
306 |
writeln; |
307 |
writeln('PICPGR Long help - all processors)'); |
307 |
writeln('PICPGR Long help - all processors)'); |
308 |
writeln('PICPGR <proc_name> Short help - particular processor'); |
308 |
writeln('PICPGR <proc_name> Short help - particular processor'); |
309 |
writeln; |
309 |
writeln; |
310 |
{-- varianta podle toho, zda mne zajima konkretni procesor --} |
310 |
{-- varianta podle toho, zda mne zajima konkretni procesor --} |
311 |
ProcFind(GetParamLine(1),Proc); |
311 |
ProcFind(GetParamLine(1),Proc); |
312 |
if Proc.Name<>'' |
312 |
if Proc.Name<>'' |
313 |
then begin {-- konkretni procesor --} |
313 |
then begin {-- konkretni procesor --} |
314 |
ProcDisplayInfo(Proc); { zobraz co je vybrane } |
314 |
ProcDisplayInfo(Proc); { zobraz co je vybrane } |
315 |
i:=CfgFindProcGroup(Proc.Cfg,CfgDefAll); |
315 |
i:=CfgFindProcGroup(Proc.Cfg,CfgDefAll); |
316 |
if i>0 then |
316 |
if i>0 then |
317 |
begin writeln(Proc.Name+' specific switches for Config Word overiding:'); |
317 |
begin writeln(Proc.Name+' specific switches for Config Word overiding:'); |
318 |
writeln; |
318 |
writeln; |
319 |
CfgDisplayHelp(CfgDefAll[i]); |
319 |
CfgDisplayHelp(CfgDefAll[i]); |
320 |
end; |
320 |
end; |
321 |
end |
321 |
end |
322 |
else begin {-- neni konkretni procesor - zobraz vsechno --} |
322 |
else begin {-- neni konkretni procesor - zobraz vsechno --} |
323 |
PressEnter; |
323 |
PressEnter; |
324 |
CfgDisplayHelpAll(CfgDefAll); |
324 |
CfgDisplayHelpAll(CfgDefAll); |
325 |
PressEnter; |
325 |
PressEnter; |
326 |
ProcDisplayInfoAll; |
326 |
ProcDisplayInfoAll; |
327 |
end; |
327 |
end; |
328 |
halt(1); |
328 |
halt(1); |
329 |
end; {Help} |
329 |
end; {Help} |
330 |
|
330 |
|
331 |
var Data:PicDataIo_t; { globalni promenna pro ulozeni dat } |
331 |
var Data:PicDataIo_t; { globalni promenna pro ulozeni dat } |
332 |
{ globalni je proto, protoze se neda } |
332 |
{ globalni je proto, protoze se neda } |
333 |
{ pouzit lokalni ( nevejde se na zasobnik ) } |
333 |
{ pouzit lokalni ( nevejde se na zasobnik ) } |
334 |
|
334 |
|
335 |
procedure ToDoRead; |
335 |
procedure ToDoRead; |
336 |
{== Bude se cist ==} |
336 |
{== Bude se cist ==} |
337 |
{ Precte obsah soucastky do pametovych bufferu } |
337 |
{ Precte obsah soucastky do pametovych bufferu } |
338 |
var i:integer; |
338 |
var i:integer; |
339 |
j:integer; |
339 |
j:integer; |
340 |
Proc:ProcInfo_t; |
340 |
Proc:ProcInfo_t; |
341 |
begin {-- Zpracovani parametru --} |
341 |
begin {-- Zpracovani parametru --} |
342 |
if paramcount<2 then Help; { chybi jmeno souboru } |
342 |
if paramcount<2 then Help; { chybi jmeno souboru } |
343 |
Switches(GetParamLine(3),Data); { typ procesoru, init Data } |
343 |
Switches(GetParamLine(3),Data); { typ procesoru, init Data } |
344 |
Data.GetProcInfo(Proc); { vytahni info o procesoru } |
344 |
Data.GetProcInfo(Proc); { vytahni info o procesoru } |
345 |
if Proc.Name='' then Error('Processor type missing',0); |
345 |
if Proc.Name='' then Error('Processor type missing',0); |
346 |
ProcDisplayInfo(Proc); { zobraz } |
346 |
ProcDisplayInfo(Proc); { zobraz } |
347 |
{-- Cteni --} |
347 |
{-- Cteni --} |
348 |
InitHW(Port); |
348 |
InitHW(Port); |
349 |
writeln('Reading data from PIC ...'); |
349 |
writeln('Reading data from PIC ...'); |
350 |
StartPIC(5.0); |
350 |
StartPIC(5.0); |
351 |
case Proc.Alg of |
351 |
case Proc.Alg of |
352 |
_EPROM1_: |
352 |
_EPROM1_: |
353 |
begin {-- Read Program Memory --} |
353 |
begin {-- Read Program Memory --} |
354 |
OutCommandPIC(IncrementAddress_06); {preskoc konfiguracni slovo} |
354 |
OutCommandPIC(IncrementAddress_06); {preskoc konfiguracni slovo} |
355 |
if Proc.PM_Len>0 then |
355 |
if Proc.PM_Len>0 then |
356 |
for i:=Proc.PM_Base to Proc.PM_Base+Proc.PM_Len-1 do |
356 |
for i:=Proc.PM_Base to Proc.PM_Base+Proc.PM_Len-1 do |
357 |
begin Data.StoreProc( i, |
357 |
begin Data.StoreProc( i, |
358 |
InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.PM_Mask |
358 |
InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.PM_Mask |
359 |
); |
359 |
); |
360 |
OutCommandPIC(IncrementAddress_06); |
360 |
OutCommandPIC(IncrementAddress_06); |
361 |
end; |
361 |
end; |
362 |
{-- Read Config Memory --} |
362 |
{-- Read Config Memory --} |
363 |
if Proc.CM_Len>0 then |
363 |
if Proc.CM_Len>0 then |
364 |
for i:=Proc.CM_Base to Proc.CM_Base+Proc.CM_Len-1 do |
364 |
for i:=Proc.CM_Base to Proc.CM_Base+Proc.CM_Len-1 do |
365 |
begin Data.StoreProc( i, |
365 |
begin Data.StoreProc( i, |
366 |
InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.CM_Mask |
366 |
InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.CM_Mask |
367 |
); |
367 |
); |
368 |
OutCommandPIC(IncrementAddress_06); |
368 |
OutCommandPIC(IncrementAddress_06); |
369 |
end; |
369 |
end; |
370 |
{--- Read Config Word ---} |
370 |
{--- Read Config Word ---} |
371 |
EndPIC; |
371 |
EndPIC; |
372 |
StartPIC(5.0); |
372 |
StartPIC(5.0); |
373 |
Data.StoreProc( Proc.Cfg_Base, |
373 |
Data.StoreProc( Proc.Cfg_Base, |
374 |
InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.Cfg_Mask |
374 |
InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.Cfg_Mask |
375 |
); |
375 |
); |
376 |
end; |
376 |
end; |
377 |
_EPROM2_, |
377 |
_EPROM2_, |
378 |
_EE1_, |
378 |
_EE1_, |
379 |
_EE2_, |
379 |
_EE2_, |
380 |
_EE3_, |
380 |
_EE3_, |
381 |
_EE4_, |
381 |
_EE4_, |
382 |
_EE5_ : |
382 |
_EE5_ : |
383 |
begin {-- Read Program Memory --} |
383 |
begin {-- Read Program Memory --} |
384 |
if Proc.PM_Len>0 then |
384 |
if Proc.PM_Len>0 then |
385 |
for i:=Proc.PM_Base to Proc.PM_Base+Proc.PM_Len-1 do |
385 |
for i:=Proc.PM_Base to Proc.PM_Base+Proc.PM_Len-1 do |
386 |
begin Data.StoreProc( i, |
386 |
begin Data.StoreProc( i, |
387 |
InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.PM_Mask |
387 |
InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.PM_Mask |
388 |
); |
388 |
); |
389 |
OutCommandPIC(IncrementAddress_06); |
389 |
OutCommandPIC(IncrementAddress_06); |
390 |
end; |
390 |
end; |
391 |
{-- Read Data Memory --} |
391 |
{-- Read Data Memory --} |
392 |
if Proc.DM_Len>0 then |
392 |
if Proc.DM_Len>0 then |
393 |
for i:=Proc.DM_Base to Proc.DM_Base+Proc.DM_Len-1 do |
393 |
for i:=Proc.DM_Base to Proc.DM_Base+Proc.DM_Len-1 do |
394 |
begin Data.StoreProc( i, |
394 |
begin Data.StoreProc( i, |
395 |
InputDataPIC(Proc.Bits,ReadDataDM_05) and Proc.DM_Mask |
395 |
InputDataPIC(Proc.Bits,ReadDataDM_05) and Proc.DM_Mask |
396 |
); |
396 |
); |
397 |
OutCommandPIC(IncrementAddress_06); |
397 |
OutCommandPIC(IncrementAddress_06); |
398 |
end; |
398 |
end; |
399 |
{-- Read Config Memory --} |
399 |
{-- Read Config Memory --} |
400 |
OutputDataPIC(Proc.Bits,LoadConfiguration_00,$FFFF); |
400 |
OutputDataPIC(Proc.Bits,LoadConfiguration_00,$FFFF); |
401 |
if Proc.CM_Len>0 then |
401 |
if Proc.CM_Len>0 then |
402 |
for i:=Proc.CM_Base to Proc.CM_Base+Proc.CM_Len-1 do |
402 |
for i:=Proc.CM_Base to Proc.CM_Base+Proc.CM_Len-1 do |
403 |
begin Data.StoreProc( i, |
403 |
begin Data.StoreProc( i, |
404 |
InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.CM_Mask |
404 |
InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.CM_Mask |
405 |
); |
405 |
); |
406 |
OutCommandPIC(IncrementAddress_06); |
406 |
OutCommandPIC(IncrementAddress_06); |
407 |
end; |
407 |
end; |
408 |
end; |
408 |
end; |
409 |
_EPROM3_: |
409 |
_EPROM3_: |
410 |
begin Error('Algorithm EPROM3 not yet supported',0); |
410 |
begin Error('Algorithm EPROM3 not yet supported',0); |
411 |
end; |
411 |
end; |
412 |
else Error('Algorithm not supported',0); |
412 |
else Error('Algorithm not supported',0); |
413 |
end; {case} |
413 |
end; {case} |
414 |
EndPIC; |
414 |
EndPIC; |
415 |
{-- Vystup vysledku --} |
415 |
{-- Vystup vysledku --} |
416 |
Data.Export(paramstr(2),FileFormat,';Directly read from '+Proc.Name); |
416 |
Data.Export(paramstr(2),FileFormat,';Directly read from '+Proc.Name); |
417 |
writeln('... Done'); |
417 |
writeln('... Done'); |
418 |
end; {ToDoRead} |
418 |
end; {ToDoRead} |
419 |
|
419 |
|
420 |
procedure Delta(adr,data1,data2:word); |
420 |
procedure Delta(adr,data1,data2:word); |
421 |
{== Vypis info o rozdilu ==} |
421 |
{== Vypis info o rozdilu ==} |
422 |
begin HexWord(output,adr); |
422 |
begin HexWord(output,adr); |
423 |
write(': '); |
423 |
write(': '); |
424 |
HexWord(output,data1); |
424 |
HexWord(output,data1); |
425 |
write('-'); |
425 |
write('-'); |
426 |
HexWord(output,data2); |
426 |
HexWord(output,data2); |
427 |
writeln; |
427 |
writeln; |
428 |
end; {Delta} |
428 |
end; {Delta} |
429 |
|
429 |
|
430 |
procedure ToDoProgram; |
430 |
procedure ToDoProgram; |
431 |
{== Bude se programovat ==} |
431 |
{== Bude se programovat ==} |
432 |
var i:integer; |
432 |
var i:integer; |
433 |
err,count:integer; |
433 |
err,count:integer; |
434 |
data_wr:word; { data, ktera se maji zapsat } |
434 |
data_wr:word; { data, ktera se maji zapsat } |
435 |
data_rd:word; { data z kontrolniho cteni } |
435 |
data_rd:word; { data z kontrolniho cteni } |
436 |
n:integer; |
436 |
n:integer; |
437 |
Proc:ProcInfo_t; |
437 |
Proc:ProcInfo_t; |
438 |
CfgStringTmp:string; |
438 |
CfgStringTmp:string; |
439 |
begin {-- Zpracovani parametru --} |
439 |
begin {-- Zpracovani parametru --} |
440 |
if paramcount<2 then Help; { chybi jmeno souboru } |
440 |
if paramcount<2 then Help; { chybi jmeno souboru } |
441 |
Switches(GetParamLine(3),Data); { typ procesoru, init Data } |
441 |
Switches(GetParamLine(3),Data); { typ procesoru, init Data } |
442 |
Data.GetProcInfo(Proc); { vytahni info o procesoru } |
442 |
Data.GetProcInfo(Proc); { vytahni info o procesoru } |
443 |
if Proc.Name='' then Error('Processor type missing',0); |
443 |
if Proc.Name='' then Error('Processor type missing',0); |
444 |
ProcDisplayInfo(Proc); { zobraz } |
444 |
ProcDisplayInfo(Proc); { zobraz } |
445 |
InitHW(Port); |
445 |
InitHW(Port); |
446 |
{-- Vstup dat --} |
446 |
{-- Vstup dat --} |
447 |
Data.Import(paramstr(2),FileFormat); |
447 |
Data.Import(paramstr(2),FileFormat); |
448 |
{-- Program --} |
448 |
{-- Program --} |
449 |
writeln('Programming data to PIC ...'); |
449 |
writeln('Programming data to PIC ...'); |
450 |
err:=0; |
450 |
err:=0; |
451 |
count:=0; |
451 |
count:=0; |
452 |
StartPIC(5.0); |
452 |
StartPIC(5.0); |
453 |
{-- Program Program Memory --} |
453 |
{-- Program Program Memory --} |
454 |
if Proc.PM_Len>0 then |
454 |
if Proc.PM_Len>0 then |
455 |
begin |
455 |
begin |
456 |
if Proc.Alg=_EPROM1_ then OutCommandPIC(IncrementAddress_06); {preskoc konfiguracni slovo} |
456 |
if Proc.Alg=_EPROM1_ then OutCommandPIC(IncrementAddress_06); {preskoc konfiguracni slovo} |
457 |
for i:=Proc.PM_Base to Proc.PM_Base+Proc.PM_Len-1 do |
457 |
for i:=Proc.PM_Base to Proc.PM_Base+Proc.PM_Len-1 do |
458 |
begin |
458 |
begin |
459 |
if Data.GetStat(i) then { platna data ? } |
459 |
if Data.GetStat(i) then { platna data ? } |
460 |
begin |
460 |
begin |
461 |
data_wr:=Data.GetData(i); { vezmi data } |
461 |
data_wr:=Data.GetData(i); { vezmi data } |
462 |
case Proc.Alg of |
462 |
case Proc.Alg of |
463 |
_EPROM1_ : |
463 |
_EPROM1_ : |
464 |
begin |
464 |
begin |
465 |
n:=0; |
465 |
n:=0; |
466 |
repeat |
466 |
repeat |
467 |
OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
467 |
OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
468 |
OutCommandPIC(BeginProgramming_08); |
468 |
OutCommandPIC(BeginProgramming_08); |
469 |
xDelayMicro(Proc.Tprog); |
469 |
xDelayMicro(Proc.Tprog); |
470 |
OutCommandPIC(EndProgramming_0E); |
470 |
OutCommandPIC(EndProgramming_0E); |
471 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.PM_Mask; |
471 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.PM_Mask; |
472 |
inc(n); |
472 |
inc(n); |
473 |
until (n>8) or (data_rd=data_wr); |
473 |
until (n>8) or (data_rd=data_wr); |
474 |
if data_rd<>data_wr |
474 |
if data_rd<>data_wr |
475 |
then begin Delta(i,data_wr,data_rd); |
475 |
then begin Delta(i,data_wr,data_rd); |
476 |
inc(err); |
476 |
inc(err); |
477 |
end |
477 |
end |
478 |
else for n:=n*11 downto 0 do |
478 |
else for n:=n*11 downto 0 do |
479 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
479 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
480 |
OutCommandPIC(BeginProgramming_08); |
480 |
OutCommandPIC(BeginProgramming_08); |
481 |
xDelayMicro(Proc.Tprog); |
481 |
xDelayMicro(Proc.Tprog); |
482 |
OutCommandPIC(EndProgramming_0E); |
482 |
OutCommandPIC(EndProgramming_0E); |
483 |
end; |
483 |
end; |
484 |
inc(count); |
484 |
inc(count); |
485 |
end; |
485 |
end; |
486 |
_EPROM2_ : |
486 |
_EPROM2_ : |
487 |
begin |
487 |
begin |
488 |
n:=0; |
488 |
n:=0; |
489 |
repeat |
489 |
repeat |
490 |
OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
490 |
OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
491 |
OutCommandPIC(BeginProgramming_08); |
491 |
OutCommandPIC(BeginProgramming_08); |
492 |
xDelayMicro(Proc.Tprog); |
492 |
xDelayMicro(Proc.Tprog); |
493 |
OutCommandPIC(EndProgramming_0E); |
493 |
OutCommandPIC(EndProgramming_0E); |
494 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.PM_Mask; |
494 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.PM_Mask; |
495 |
inc(n); |
495 |
inc(n); |
496 |
until (n>25) or (data_rd=data_wr); |
496 |
until (n>25) or (data_rd=data_wr); |
497 |
if data_rd<>data_wr |
497 |
if data_rd<>data_wr |
498 |
then begin Delta(i,data_wr,data_rd); |
498 |
then begin Delta(i,data_wr,data_rd); |
499 |
inc(err); |
499 |
inc(err); |
500 |
end |
500 |
end |
501 |
else for n:=3*n downto 0 do |
501 |
else for n:=3*n downto 0 do |
502 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
502 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
503 |
OutCommandPIC(BeginProgramming_08); |
503 |
OutCommandPIC(BeginProgramming_08); |
504 |
xDelayMicro(Proc.Tprog); |
504 |
xDelayMicro(Proc.Tprog); |
505 |
OutCommandPIC(EndProgramming_0E); |
505 |
OutCommandPIC(EndProgramming_0E); |
506 |
end; |
506 |
end; |
507 |
inc(count); |
507 |
inc(count); |
508 |
end; |
508 |
end; |
509 |
_EPROM3_ : |
509 |
_EPROM3_ : |
510 |
begin Error('Algorithm EPROM3 not yet supported',0); |
510 |
begin Error('Algorithm EPROM3 not yet supported',0); |
511 |
end; |
511 |
end; |
512 |
_EE1_, |
512 |
_EE1_, |
513 |
_EE2_, |
513 |
_EE2_, |
514 |
_EE4_ : |
514 |
_EE4_ : |
515 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
515 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
516 |
OutCommandPIC(BeginProgramming_08); |
516 |
OutCommandPIC(BeginProgramming_08); |
517 |
xDelayMicro(Proc.Tprog); |
517 |
xDelayMicro(Proc.Tprog); |
518 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.PM_Mask; |
518 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.PM_Mask; |
519 |
if data_rd <> data_wr |
519 |
if data_rd <> data_wr |
520 |
then begin Delta(i,data_wr,data_rd); |
520 |
then begin Delta(i,data_wr,data_rd); |
521 |
inc(err); |
521 |
inc(err); |
522 |
end; |
522 |
end; |
523 |
inc(count); |
523 |
inc(count); |
524 |
end; |
524 |
end; |
525 |
_EE3_, |
525 |
_EE3_, |
526 |
_EE5_ : |
526 |
_EE5_ : |
527 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
527 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
528 |
OutCommandPIC(BeginProgrammingOnlyCycle_18); |
528 |
OutCommandPIC(BeginProgrammingOnlyCycle_18); |
529 |
xDelayMicro(Proc.Tprog); |
529 |
xDelayMicro(Proc.Tprog); |
530 |
OutCommandPIC(EndProgramming_17); |
530 |
OutCommandPIC(EndProgramming_17); |
531 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.PM_Mask; |
531 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.PM_Mask; |
532 |
if data_rd <> data_wr |
532 |
if data_rd <> data_wr |
533 |
then begin Delta(i,data_wr,data_rd); |
533 |
then begin Delta(i,data_wr,data_rd); |
534 |
inc(err); |
534 |
inc(err); |
535 |
end; |
535 |
end; |
536 |
inc(count); |
536 |
inc(count); |
537 |
end; |
537 |
end; |
538 |
else Error('Algorithm not supported',0); |
538 |
else Error('Algorithm not supported',0); |
539 |
end; {case} |
539 |
end; {case} |
540 |
end; {od if testujicich platnost dat} |
540 |
end; {od if testujicich platnost dat} |
541 |
OutCommandPIC(IncrementAddress_06); { dalsi adresa PM } |
541 |
OutCommandPIC(IncrementAddress_06); { dalsi adresa PM } |
542 |
end; {od cyklu for pres vsechny adresy} |
542 |
end; {od cyklu for pres vsechny adresy} |
543 |
|
543 |
|
544 |
(* |
544 |
(* |
545 |
{-- Verify Programm Memory --} |
545 |
{-- Verify Programm Memory --} |
546 |
{ Dela se jen u algoritmu, ktere nemohou verifikovat } |
546 |
{ Dela se jen u algoritmu, ktere nemohou verifikovat } |
547 |
{ prubezne pri programovani (tedy ty, ktere pregramuji } |
547 |
{ prubezne pri programovani (tedy ty, ktere pregramuji } |
548 |
{ vice slov najednou } |
548 |
{ vice slov najednou } |
549 |
{ Zatim zadne takove algoritmy kde by to neslo po jednotlivych slovech } |
549 |
{ Zatim zadne takove algoritmy kde by to neslo po jednotlivych slovech } |
550 |
{ nemame. } |
550 |
{ nemame. } |
551 |
case Proc.Alg of |
551 |
case Proc.Alg of |
552 |
_EE3_ : |
552 |
_EE3_ : |
553 |
begin {-- Dodatecna verifikace --} |
553 |
begin {-- Dodatecna verifikace --} |
554 |
{!!!!!!!!!!!! asi bude treba reset citace } |
554 |
{!!!!!!!!!!!! asi bude treba reset citace } |
555 |
write('... Verify Program Memory ...'); |
555 |
write('... Verify Program Memory ...'); |
556 |
if Proc.PM_Len>0 then |
556 |
if Proc.PM_Len>0 then |
557 |
for i:=Proc.PM_Base to Proc.PM_Base+Proc.PM_Len-1 do |
557 |
for i:=Proc.PM_Base to Proc.PM_Base+Proc.PM_Len-1 do |
558 |
begin |
558 |
begin |
559 |
if Data.GetStat(i) { platna data } |
559 |
if Data.GetStat(i) { platna data } |
560 |
then begin data_wr:=Data.GetData(i); |
560 |
then begin data_wr:=Data.GetData(i); |
561 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.PM_Mask; |
561 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.PM_Mask; |
562 |
if data_wr <> data_rd |
562 |
if data_wr <> data_rd |
563 |
then begin Delta(i,data_wr,data_rd); |
563 |
then begin Delta(i,data_wr,data_rd); |
564 |
inc(err); |
564 |
inc(err); |
565 |
end; |
565 |
end; |
566 |
inc(count); |
566 |
inc(count); |
567 |
end; |
567 |
end; |
568 |
OutCommandPIC(IncrementAddress_06); |
568 |
OutCommandPIC(IncrementAddress_06); |
569 |
end; |
569 |
end; |
570 |
end; |
570 |
end; |
571 |
end; {case} |
571 |
end; {case} |
572 |
*) |
572 |
*) |
573 |
|
573 |
|
574 |
{-- Program Data Memory --} |
574 |
{-- Program Data Memory --} |
575 |
if Proc.DM_Len>0 then |
575 |
if Proc.DM_Len>0 then |
576 |
for i:=Proc.DM_Base to Proc.DM_Base+Proc.DM_Len-1 do |
576 |
for i:=Proc.DM_Base to Proc.DM_Base+Proc.DM_Len-1 do |
577 |
begin |
577 |
begin |
578 |
if Data.GetStat(i) |
578 |
if Data.GetStat(i) |
579 |
then |
579 |
then |
580 |
begin data_wr:=Data.GetData(i); |
580 |
begin data_wr:=Data.GetData(i); |
581 |
case Proc.Alg of |
581 |
case Proc.Alg of |
582 |
_EPROM1_, |
582 |
_EPROM1_, |
583 |
_EPROM2_, |
583 |
_EPROM2_, |
584 |
_EPROM3_ : |
584 |
_EPROM3_ : |
585 |
begin Error('Internal Error: Algorithm EPROMx does not know Data Memory',0); |
585 |
begin Error('Internal Error: Algorithm EPROMx does not know Data Memory',0); |
586 |
end; |
586 |
end; |
587 |
_EE1_, |
587 |
_EE1_, |
588 |
_EE2_, |
588 |
_EE2_, |
589 |
_EE3_, |
589 |
_EE3_, |
590 |
_EE4_ : |
590 |
_EE4_ : |
591 |
begin OutputDataPIC(Proc.Bits,LoadDataDM_03,data_wr); |
591 |
begin OutputDataPIC(Proc.Bits,LoadDataDM_03,data_wr); |
592 |
OutCommandPIC(BeginProgramming_08); |
592 |
OutCommandPIC(BeginProgramming_08); |
593 |
xDelayMicro(Proc.Tprog); |
593 |
xDelayMicro(Proc.Tprog); |
594 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataDM_05) and Proc.DM_Mask; |
594 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataDM_05) and Proc.DM_Mask; |
595 |
if data_rd <> data_wr |
595 |
if data_rd <> data_wr |
596 |
then begin Delta(i,data_wr,data_rd); |
596 |
then begin Delta(i,data_wr,data_rd); |
597 |
inc(err); |
597 |
inc(err); |
598 |
end; |
598 |
end; |
599 |
inc(count); |
599 |
inc(count); |
600 |
end; |
600 |
end; |
601 |
_EE5_ : |
601 |
_EE5_ : |
602 |
begin OutputDataPIC(Proc.Bits,LoadDataDM_03,data_wr); |
602 |
begin OutputDataPIC(Proc.Bits,LoadDataDM_03,data_wr); |
603 |
OutCommandPIC(BeginProgrammingOnlyCycle_18); |
603 |
OutCommandPIC(BeginProgrammingOnlyCycle_18); |
604 |
xDelayMicro(Proc.Tprog); |
604 |
xDelayMicro(Proc.Tprog); |
605 |
OutCommandPIC(EndProgramming_17); |
605 |
OutCommandPIC(EndProgramming_17); |
606 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataDM_05) and Proc.DM_Mask; |
606 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataDM_05) and Proc.DM_Mask; |
607 |
if data_rd <> data_wr |
607 |
if data_rd <> data_wr |
608 |
then begin Delta(i,data_wr,data_rd); |
608 |
then begin Delta(i,data_wr,data_rd); |
609 |
inc(err); |
609 |
inc(err); |
610 |
end; |
610 |
end; |
611 |
inc(count); |
611 |
inc(count); |
612 |
end; |
612 |
end; |
613 |
else Error('Algorithm not supported',0); |
613 |
else Error('Algorithm not supported',0); |
614 |
end; {case} |
614 |
end; {case} |
615 |
end; |
615 |
end; |
616 |
OutCommandPIC(IncrementAddress_06); |
616 |
OutCommandPIC(IncrementAddress_06); |
617 |
end; |
617 |
end; |
618 |
|
618 |
|
619 |
{-- priprav Config Word --} |
619 |
{-- priprav Config Word --} |
620 |
if (CfgString<>'') and (CfgString<>CfgX) |
620 |
if (CfgString<>'') and (CfgString<>CfgX) |
621 |
then begin {-- prepinaci zmeneno Cfg slovo --} |
621 |
then begin {-- prepinaci zmeneno Cfg slovo --} |
622 |
writeln('Required Config Word: ',CfgString); |
622 |
writeln('Required Config Word: ',CfgString); |
623 |
if Data.GetStat(Proc.Cfg_Base) |
623 |
if Data.GetStat(Proc.Cfg_Base) |
624 |
then begin {-- Cfg slovo bylo v datovem souboru --} |
624 |
then begin {-- Cfg slovo bylo v datovem souboru --} |
625 |
CfgStringTmp:=Word2Str(Data.GetData(Proc.Cfg_Base)); |
625 |
CfgStringTmp:=Word2Str(Data.GetData(Proc.Cfg_Base)); |
626 |
writeln('Config Word from data file: ',CfgStringTmp); |
626 |
writeln('Config Word from data file: ',CfgStringTmp); |
627 |
end |
627 |
end |
628 |
else begin {-- Cfg slovo nebylo v datovem souboru --} |
628 |
else begin {-- Cfg slovo nebylo v datovem souboru --} |
629 |
CfgStringTmp:=CfgX; { prazdne slovo ( sama X ) } |
629 |
CfgStringTmp:=CfgX; { prazdne slovo ( sama X ) } |
630 |
end; |
630 |
end; |
631 |
{-- sloz slovo ze souboru a z prepinacu --} |
631 |
{-- sloz slovo ze souboru a z prepinacu --} |
632 |
CfgString:=CfgOverride(CfgStringTmp,CfgString); |
632 |
CfgString:=CfgOverride(CfgStringTmp,CfgString); |
633 |
writeln('Result: ',CfgString); |
633 |
writeln('Result: ',CfgString); |
634 |
{-- uloz slozene slovo do datoveho pole --} |
634 |
{-- uloz slozene slovo do datoveho pole --} |
635 |
Data.StoreProc(Proc.Cfg_Base,Str2Word(CfgString)); |
635 |
Data.StoreProc(Proc.Cfg_Base,Str2Word(CfgString)); |
636 |
end; |
636 |
end; |
637 |
|
637 |
|
638 |
{-- Program Config Memory --} |
638 |
{-- Program Config Memory --} |
639 |
{--- algoritmus _EPROM1_ prikaz Load Configuration nezna} |
639 |
{--- algoritmus _EPROM1_ prikaz Load Configuration nezna} |
640 |
if Proc.Alg<>_EPROM1_ then OutputDataPIC(Proc.Bits,LoadConfiguration_00,$FFFF); |
640 |
if Proc.Alg<>_EPROM1_ then OutputDataPIC(Proc.Bits,LoadConfiguration_00,$FFFF); |
641 |
if Proc.CM_Len>0 then |
641 |
if Proc.CM_Len>0 then |
642 |
for i:=Proc.CM_Base to Proc.CM_Base+Proc.CM_Len-1 do |
642 |
for i:=Proc.CM_Base to Proc.CM_Base+Proc.CM_Len-1 do |
643 |
begin |
643 |
begin |
644 |
if Data.GetStat(i) |
644 |
if Data.GetStat(i) |
645 |
then |
645 |
then |
646 |
begin data_wr:=Data.GetData(i); |
646 |
begin data_wr:=Data.GetData(i); |
647 |
case Proc.Alg of |
647 |
case Proc.Alg of |
648 |
_EPROM1_ : |
648 |
_EPROM1_ : |
649 |
begin |
649 |
begin |
650 |
n:=0; |
650 |
n:=0; |
651 |
repeat |
651 |
repeat |
652 |
OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
652 |
OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
653 |
OutCommandPIC(BeginProgramming_08); |
653 |
OutCommandPIC(BeginProgramming_08); |
654 |
xDelayMicro(Proc.Tprog); |
654 |
xDelayMicro(Proc.Tprog); |
655 |
OutCommandPIC(EndProgramming_0E); |
655 |
OutCommandPIC(EndProgramming_0E); |
656 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.CM_Mask; |
656 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.CM_Mask; |
657 |
inc(n); |
657 |
inc(n); |
658 |
until (n>8) or (data_wr=data_rd); |
658 |
until (n>8) or (data_wr=data_rd); |
659 |
if data_rd <> data_wr |
659 |
if data_rd <> data_wr |
660 |
then begin Delta(i,data_wr,data_rd); |
660 |
then begin Delta(i,data_wr,data_rd); |
661 |
inc(err); |
661 |
inc(err); |
662 |
end |
662 |
end |
663 |
else for n:=11*n downto 0 do |
663 |
else for n:=11*n downto 0 do |
664 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
664 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
665 |
OutCommandPIC(BeginProgramming_08); |
665 |
OutCommandPIC(BeginProgramming_08); |
666 |
xDelayMicro(Proc.Tprog); |
666 |
xDelayMicro(Proc.Tprog); |
667 |
OutCommandPIC(EndProgramming_0E); |
667 |
OutCommandPIC(EndProgramming_0E); |
668 |
end; |
668 |
end; |
669 |
end; |
669 |
end; |
670 |
_EPROM2_ : |
670 |
_EPROM2_ : |
671 |
begin |
671 |
begin |
672 |
n:=0; |
672 |
n:=0; |
673 |
repeat |
673 |
repeat |
674 |
OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
674 |
OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
675 |
OutCommandPIC(BeginProgramming_08); |
675 |
OutCommandPIC(BeginProgramming_08); |
676 |
xDelayMicro(Proc.Tprog); |
676 |
xDelayMicro(Proc.Tprog); |
677 |
OutCommandPIC(EndProgramming_0E); |
677 |
OutCommandPIC(EndProgramming_0E); |
678 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.CM_Mask; |
678 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.CM_Mask; |
679 |
inc(n); |
679 |
inc(n); |
680 |
until (n>25) or (data_wr=data_rd); |
680 |
until (n>25) or (data_wr=data_rd); |
681 |
if data_rd <> data_wr |
681 |
if data_rd <> data_wr |
682 |
then begin Delta(i,data_wr,data_rd); |
682 |
then begin Delta(i,data_wr,data_rd); |
683 |
inc(err); |
683 |
inc(err); |
684 |
end |
684 |
end |
685 |
else for n:=3*n downto 0 do |
685 |
else for n:=3*n downto 0 do |
686 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
686 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
687 |
OutCommandPIC(BeginProgramming_08); |
687 |
OutCommandPIC(BeginProgramming_08); |
688 |
xDelayMicro(Proc.Tprog); |
688 |
xDelayMicro(Proc.Tprog); |
689 |
OutCommandPIC(EndProgramming_0E); |
689 |
OutCommandPIC(EndProgramming_0E); |
690 |
end; |
690 |
end; |
691 |
end; |
691 |
end; |
692 |
_EPROM3_ : |
692 |
_EPROM3_ : |
693 |
begin Error('Algorithm EPROM3 not yet supported',0); |
693 |
begin Error('Algorithm EPROM3 not yet supported',0); |
694 |
end; |
694 |
end; |
695 |
_EE1_, |
695 |
_EE1_, |
696 |
_EE2_, |
696 |
_EE2_, |
697 |
_EE4_ : |
697 |
_EE4_ : |
698 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
698 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
699 |
OutCommandPIC(BeginProgramming_08); |
699 |
OutCommandPIC(BeginProgramming_08); |
700 |
xDelayMicro(Proc.Tprog); |
700 |
xDelayMicro(Proc.Tprog); |
701 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.CM_Mask; |
701 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.CM_Mask; |
702 |
if i=Proc.Cfg_Base |
702 |
if i=Proc.Cfg_Base |
703 |
then begin {-- Cfg bunka - maskuj --} |
703 |
then begin {-- Cfg bunka - maskuj --} |
704 |
if ( ( data_wr xor data_rd ) and Proc.Cfg_Mask ) <> 0 |
704 |
if ( ( data_wr xor data_rd ) and Proc.Cfg_Mask ) <> 0 |
705 |
then begin Delta(i,data_wr,data_rd); |
705 |
then begin Delta(i,data_wr,data_rd); |
706 |
inc(err); |
706 |
inc(err); |
707 |
end; |
707 |
end; |
708 |
end |
708 |
end |
709 |
else begin if data_wr <> data_rd |
709 |
else begin if data_wr <> data_rd |
710 |
then begin Delta(i,data_wr,data_rd); |
710 |
then begin Delta(i,data_wr,data_rd); |
711 |
inc(err); |
711 |
inc(err); |
712 |
end; |
712 |
end; |
713 |
end; |
713 |
end; |
714 |
inc(count); |
714 |
inc(count); |
715 |
end; |
715 |
end; |
716 |
_EE3_, |
716 |
_EE3_, |
717 |
_EE5_ : |
717 |
_EE5_ : |
718 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
718 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
719 |
if (Proc.Alg=_EE3_) and (i=Proc.Cfg_Base) |
719 |
if (Proc.Alg=_EE3_) and (i=Proc.Cfg_Base) |
720 |
then begin {-- CFG slovo i algoritmu EE3 nejde preogramovat po jednotlivych slovech --} |
720 |
then begin {-- CFG slovo i algoritmu EE3 nejde preogramovat po jednotlivych slovech --} |
721 |
OutCommandPIC(BeginProgramming_08); |
721 |
OutCommandPIC(BeginProgramming_08); |
722 |
xDelayMicro(Proc.Tprog); |
722 |
xDelayMicro(Proc.Tprog); |
723 |
end |
723 |
end |
724 |
else begin OutCommandPIC(BeginProgrammingOnlyCycle_18); |
724 |
else begin OutCommandPIC(BeginProgrammingOnlyCycle_18); |
725 |
xDelayMicro(Proc.Tprog); |
725 |
xDelayMicro(Proc.Tprog); |
726 |
OutCommandPIC(EndProgramming_17); |
726 |
OutCommandPIC(EndProgramming_17); |
727 |
end; |
727 |
end; |
728 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.CM_Mask; |
728 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.CM_Mask; |
729 |
if i=Proc.Cfg_Base |
729 |
if i=Proc.Cfg_Base |
730 |
then begin {-- Cfg bunka - maskuj --} |
730 |
then begin {-- Cfg bunka - maskuj --} |
731 |
if ( ( data_wr xor data_rd ) and Proc.Cfg_Mask ) <> 0 |
731 |
if ( ( data_wr xor data_rd ) and Proc.Cfg_Mask ) <> 0 |
732 |
then begin Delta(i,data_wr,data_rd); |
732 |
then begin Delta(i,data_wr,data_rd); |
733 |
inc(err); |
733 |
inc(err); |
734 |
end; |
734 |
end; |
735 |
end |
735 |
end |
736 |
else begin if data_wr <> data_rd |
736 |
else begin if data_wr <> data_rd |
737 |
then begin Delta(i,data_wr,data_rd); |
737 |
then begin Delta(i,data_wr,data_rd); |
738 |
inc(err); |
738 |
inc(err); |
739 |
end; |
739 |
end; |
740 |
end; |
740 |
end; |
741 |
inc(count); |
741 |
inc(count); |
742 |
end; |
742 |
end; |
743 |
else Error('Algorithm not supported',0); |
743 |
else Error('Algorithm not supported',0); |
744 |
end; {case} |
744 |
end; {case} |
745 |
end; |
745 |
end; |
746 |
OutCommandPIC(IncrementAddress_06); |
746 |
OutCommandPIC(IncrementAddress_06); |
747 |
end; |
747 |
end; |
748 |
|
748 |
|
749 |
{--- u algoritmu _EPROM1_ se konfiguracni slovo programuje zvlast} |
749 |
{--- u algoritmu _EPROM1_ se konfiguracni slovo programuje zvlast} |
750 |
if Proc.Alg=_EPROM1_ then |
750 |
if Proc.Alg=_EPROM1_ then |
751 |
if Data.GetStat(Proc.Cfg_Base) then |
751 |
if Data.GetStat(Proc.Cfg_Base) then |
752 |
begin |
752 |
begin |
753 |
{--- toto zajisti prechod na konfig. bunku} |
753 |
{--- toto zajisti prechod na konfig. bunku} |
754 |
EndPIC; |
754 |
EndPIC; |
755 |
StartPIC(5.0); |
755 |
StartPIC(5.0); |
756 |
data_wr:=Data.GetData(Proc.Cfg_Base); |
756 |
data_wr:=Data.GetData(Proc.Cfg_Base); |
757 |
n:=0; |
757 |
n:=0; |
758 |
repeat |
758 |
repeat |
759 |
OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
759 |
OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
760 |
OutCommandPIC(BeginProgramming_08); |
760 |
OutCommandPIC(BeginProgramming_08); |
761 |
xDelayMicro(Proc.Tprog); |
761 |
xDelayMicro(Proc.Tprog); |
762 |
OutCommandPIC(EndProgramming_0E); |
762 |
OutCommandPIC(EndProgramming_0E); |
763 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.Cfg_Mask; |
763 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.Cfg_Mask; |
764 |
inc(n); |
764 |
inc(n); |
765 |
until (n>8) or (data_rd=data_wr); |
765 |
until (n>8) or (data_rd=data_wr); |
766 |
if data_rd<>data_wr |
766 |
if data_rd<>data_wr |
767 |
then begin Delta(Proc.Cfg_Mask,data_wr,data_rd); |
767 |
then begin Delta(Proc.Cfg_Mask,data_wr,data_rd); |
768 |
inc(err); |
768 |
inc(err); |
769 |
end |
769 |
end |
770 |
else for n:=n*11 downto 0 do |
770 |
else for n:=n*11 downto 0 do |
771 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
771 |
begin OutputDataPIC(Proc.Bits,LoadDataPM_02,data_wr); |
772 |
OutCommandPIC(BeginProgramming_08); |
772 |
OutCommandPIC(BeginProgramming_08); |
773 |
xDelayMicro(Proc.Tprog); |
773 |
xDelayMicro(Proc.Tprog); |
774 |
OutCommandPIC(EndProgramming_0E); |
774 |
OutCommandPIC(EndProgramming_0E); |
775 |
end; |
775 |
end; |
776 |
inc(count); |
776 |
inc(count); |
777 |
end; |
777 |
end; |
778 |
end; |
778 |
end; |
779 |
EndPIC; |
779 |
EndPIC; |
780 |
writeln('... Done'); |
780 |
writeln('... Done'); |
781 |
write('Programmed ',count,' Data Words, '); |
781 |
write('Programmed ',count,' Data Words, '); |
782 |
case err of |
782 |
case err of |
783 |
0 : writeln('No diferences found'); |
783 |
0 : writeln('No diferences found'); |
784 |
1 : writeln(err,' diference found'); |
784 |
1 : writeln(err,' diference found'); |
785 |
else writeln(err,' diferences found'); |
785 |
else writeln(err,' diferences found'); |
786 |
end;{case} |
786 |
end;{case} |
787 |
if err<>0 then exitcode:=100; { Jako by bylo halt(100) } |
787 |
if err<>0 then exitcode:=100; { Jako by bylo halt(100) } |
788 |
end; {ToDoProgram} |
788 |
end; {ToDoProgram} |
789 |
|
789 |
|
790 |
procedure ToDoVerify; |
790 |
procedure ToDoVerify; |
791 |
{== Porovnani obsahu soucastky se souborem ==} |
791 |
{== Porovnani obsahu soucastky se souborem ==} |
792 |
var i:integer; |
792 |
var i:integer; |
793 |
data_fi:word; { data z objektu } |
793 |
data_fi:word; { data z objektu } |
794 |
data_rd:word; { data prectena ze soucastky } |
794 |
data_rd:word; { data prectena ze soucastky } |
795 |
err,count:integer; |
795 |
err,count:integer; |
796 |
Proc:ProcInfo_t; |
796 |
Proc:ProcInfo_t; |
797 |
begin {-- Zpracovani parametru --} |
797 |
begin {-- Zpracovani parametru --} |
798 |
if paramcount<2 then Help; { chybi jmeno souboru } |
798 |
if paramcount<2 then Help; { chybi jmeno souboru } |
799 |
Switches(GetParamLine(3),Data); { typ procesoru, init Data } |
799 |
Switches(GetParamLine(3),Data); { typ procesoru, init Data } |
800 |
Data.GetProcInfo(Proc); { vytahni info o procesoru } |
800 |
Data.GetProcInfo(Proc); { vytahni info o procesoru } |
801 |
if Proc.Name='' then Error('Processor type missing',0); |
801 |
if Proc.Name='' then Error('Processor type missing',0); |
802 |
ProcDisplayInfo(Proc); { zobraz } |
802 |
ProcDisplayInfo(Proc); { zobraz } |
803 |
InitHW(Port); |
803 |
InitHW(Port); |
804 |
{-- Vstup dat --} |
804 |
{-- Vstup dat --} |
805 |
Data.Import(paramstr(2),FileFormat); |
805 |
Data.Import(paramstr(2),FileFormat); |
806 |
{-- Verify --} |
806 |
{-- Verify --} |
807 |
writeln('Verifying ...'); |
807 |
writeln('Verifying ...'); |
808 |
err:=0; |
808 |
err:=0; |
809 |
count:=0; |
809 |
count:=0; |
810 |
StartPIC(5.0); |
810 |
StartPIC(5.0); |
811 |
case Proc.Alg of { toto je jen test na podporovane algoritmy } |
811 |
case Proc.Alg of { toto je jen test na podporovane algoritmy } |
812 |
_EPROM1_, |
812 |
_EPROM1_, |
813 |
_EPROM2_, |
813 |
_EPROM2_, |
814 |
_EE1_, |
814 |
_EE1_, |
815 |
_EE2_, |
815 |
_EE2_, |
816 |
_EE3_, |
816 |
_EE3_, |
817 |
_EE4_, |
817 |
_EE4_, |
818 |
_EE5_ : |
818 |
_EE5_ : |
819 |
begin {-- Verify Program Memory --} |
819 |
begin {-- Verify Program Memory --} |
820 |
if Proc.PM_Len>0 then |
820 |
if Proc.PM_Len>0 then |
821 |
for i:=Proc.PM_Base to Proc.PM_Base+Proc.PM_Len-1 do |
821 |
for i:=Proc.PM_Base to Proc.PM_Base+Proc.PM_Len-1 do |
822 |
begin |
822 |
begin |
823 |
if Data.GetStat(i) { platna data } |
823 |
if Data.GetStat(i) { platna data } |
824 |
then begin data_fi:=Data.GetData(i); |
824 |
then begin data_fi:=Data.GetData(i); |
825 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.PM_Mask; |
825 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.PM_Mask; |
826 |
if data_fi <> data_rd |
826 |
if data_fi <> data_rd |
827 |
then begin Delta(i,data_fi,data_rd); |
827 |
then begin Delta(i,data_fi,data_rd); |
828 |
inc(err); |
828 |
inc(err); |
829 |
end; |
829 |
end; |
830 |
inc(count); |
830 |
inc(count); |
831 |
end; |
831 |
end; |
832 |
OutCommandPIC(IncrementAddress_06); |
832 |
OutCommandPIC(IncrementAddress_06); |
833 |
end; |
833 |
end; |
834 |
{-- Verify Data Memory --} |
834 |
{-- Verify Data Memory --} |
835 |
if Proc.DM_Len>0 then |
835 |
if Proc.DM_Len>0 then |
836 |
for i:=Proc.DM_Base to Proc.DM_Base+Proc.DM_Len-1 do |
836 |
for i:=Proc.DM_Base to Proc.DM_Base+Proc.DM_Len-1 do |
837 |
begin |
837 |
begin |
838 |
if Data.GetStat(i) { platna data } |
838 |
if Data.GetStat(i) { platna data } |
839 |
then begin data_fi:=Data.GetData(i); |
839 |
then begin data_fi:=Data.GetData(i); |
840 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataDM_05) and Proc.DM_Mask; |
840 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataDM_05) and Proc.DM_Mask; |
841 |
if data_rd <> data_fi |
841 |
if data_rd <> data_fi |
842 |
then begin Delta(i,data_fi,data_rd); |
842 |
then begin Delta(i,data_fi,data_rd); |
843 |
inc(err); |
843 |
inc(err); |
844 |
end; |
844 |
end; |
845 |
inc(count); |
845 |
inc(count); |
846 |
end; |
846 |
end; |
847 |
OutCommandPIC(IncrementAddress_06); |
847 |
OutCommandPIC(IncrementAddress_06); |
848 |
end; |
848 |
end; |
849 |
{-- Verify Config Memory --} |
849 |
{-- Verify Config Memory --} |
850 |
OutputDataPIC(Proc.Bits,LoadConfiguration_00,$FFFF); |
850 |
OutputDataPIC(Proc.Bits,LoadConfiguration_00,$FFFF); |
851 |
if Proc.CM_Len>0 then |
851 |
if Proc.CM_Len>0 then |
852 |
for i:=Proc.CM_Base to Proc.CM_Base+Proc.CM_Len-1 do |
852 |
for i:=Proc.CM_Base to Proc.CM_Base+Proc.CM_Len-1 do |
853 |
begin |
853 |
begin |
854 |
if Data.GetStat(i) |
854 |
if Data.GetStat(i) |
855 |
then begin data_fi:=Data.GetData(i); |
855 |
then begin data_fi:=Data.GetData(i); |
856 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.CM_Mask; |
856 |
data_rd:=InputDataPIC(Proc.Bits,ReadDataPM_04) and Proc.CM_Mask; |
857 |
if i=Proc.Cfg_Base |
857 |
if i=Proc.Cfg_Base |
858 |
then begin {-- Cfg bunka - maskuj --} |
858 |
then begin {-- Cfg bunka - maskuj --} |
859 |
if ( ( data_fi xor data_rd ) and Proc.Cfg_Mask ) <> 0 |
859 |
if ( ( data_fi xor data_rd ) and Proc.Cfg_Mask ) <> 0 |
860 |
then begin Delta(i,data_fi,data_rd); |
860 |
then begin Delta(i,data_fi,data_rd); |
861 |
inc(err); |
861 |
inc(err); |
862 |
end; |
862 |
end; |
863 |
end |
863 |
end |
864 |
else begin if data_fi <> data_rd |
864 |
else begin if data_fi <> data_rd |
865 |
then begin Delta(i,data_fi,data_rd); |
865 |
then begin Delta(i,data_fi,data_rd); |
866 |
inc(err); |
866 |
inc(err); |
867 |
end; |
867 |
end; |
868 |
end; |
868 |
end; |
869 |
inc(count); |
869 |
inc(count); |
870 |
end; |
870 |
end; |
871 |
OutCommandPIC(IncrementAddress_06); |
871 |
OutCommandPIC(IncrementAddress_06); |
872 |
end; |
872 |
end; |
873 |
end; |
873 |
end; |
874 |
_EPROM3_: |
874 |
_EPROM3_: |
875 |
begin Error('Algorithm EPROM3 not yet supported',0); |
875 |
begin Error('Algorithm EPROM3 not yet supported',0); |
876 |
end; |
876 |
end; |
877 |
else Error('Algorithm not supported',0); |
877 |
else Error('Algorithm not supported',0); |
878 |
end; {case} |
878 |
end; {case} |
879 |
EndPIC; |
879 |
EndPIC; |
880 |
writeln('... Done'); |
880 |
writeln('... Done'); |
881 |
write('Compared ',count,' Data Words, '); |
881 |
write('Compared ',count,' Data Words, '); |
882 |
case err of |
882 |
case err of |
883 |
0 : writeln('No diferences found'); |
883 |
0 : writeln('No diferences found'); |
884 |
1 : writeln(err,' diference found'); |
884 |
1 : writeln(err,' diference found'); |
885 |
else writeln(err,' diferences found'); |
885 |
else writeln(err,' diferences found'); |
886 |
end;{case} |
886 |
end;{case} |
887 |
if err<>0 then exitcode:=100; { Jako by bylo halt(100) } |
887 |
if err<>0 then exitcode:=100; { Jako by bylo halt(100) } |
888 |
end; {ToDoVerify} |
888 |
end; {ToDoVerify} |
889 |
|
889 |
|
890 |
procedure ToDoErase; |
890 |
procedure ToDoErase; |
891 |
{== Bude se pouze mazat ==} |
891 |
{== Bude se pouze mazat ==} |
892 |
var i:integer; |
892 |
var i:integer; |
893 |
Proc:ProcInfo_t; |
893 |
Proc:ProcInfo_t; |
894 |
begin {-- Zpracovani parametru --} |
894 |
begin {-- Zpracovani parametru --} |
895 |
Switches(GetParamLine(2),Data); { typ procesoru, init Data } |
895 |
Switches(GetParamLine(2),Data); { typ procesoru, init Data } |
896 |
Data.GetProcInfo(Proc); { vytahni info o procesoru } |
896 |
Data.GetProcInfo(Proc); { vytahni info o procesoru } |
897 |
if Proc.Name='' then Error('Processor type missing',0); |
897 |
if Proc.Name='' then Error('Processor type missing',0); |
898 |
ProcDisplayInfo(Proc); { zobraz } |
898 |
ProcDisplayInfo(Proc); { zobraz } |
899 |
{-- Erase --} |
899 |
{-- Erase --} |
900 |
case Proc.Alg of |
900 |
case Proc.Alg of |
901 |
_EPROM1_, |
901 |
_EPROM1_, |
902 |
_EPROM2_, |
902 |
_EPROM2_, |
903 |
_EPROM3_ : |
903 |
_EPROM3_ : |
904 |
begin Error('Use UV light to erase EPROM processor!',0) |
904 |
begin Error('Use UV light to erase EPROM processor!',0) |
905 |
end; |
905 |
end; |
906 |
_EE1_, |
906 |
_EE1_, |
907 |
_EE2_ : |
907 |
_EE2_ : |
908 |
begin InitHW(Port); |
908 |
begin InitHW(Port); |
909 |
writeln('Erasing PIC'); |
909 |
writeln('Erasing PIC'); |
910 |
StartPIC(5.0); |
910 |
StartPIC(5.0); |
911 |
{-- postup pro odblokovani CP soucastky --} |
911 |
{-- postup pro odblokovani CP soucastky --} |
912 |
OutputDataPIC(Proc.Bits,LoadConfiguration_00,$FFFF); |
912 |
OutputDataPIC(Proc.Bits,LoadConfiguration_00,$FFFF); |
913 |
for i:=1 to Proc.CM_Len-1 do OutCommandPIC(IncrementAddress_06); |
913 |
for i:=1 to Proc.CM_Len-1 do OutCommandPIC(IncrementAddress_06); |
914 |
OutCommandPIC(Dis1_01); |
914 |
OutCommandPIC(Dis1_01); |
915 |
OutCommandPIC(Dis2_07); |
915 |
OutCommandPIC(Dis2_07); |
916 |
OutCommandPIC(BeginProgramming_08); |
916 |
OutCommandPIC(BeginProgramming_08); |
917 |
xDelayMicro(12000); |
917 |
xDelayMicro(12000); |
918 |
OutCommandPIC(Dis1_01); |
918 |
OutCommandPIC(Dis1_01); |
919 |
OutCommandPIC(Dis2_07); |
919 |
OutCommandPIC(Dis2_07); |
920 |
{-- Mazani datove pameti --} |
920 |
{-- Mazani datove pameti --} |
921 |
{ Funguje na C84/F84/F877 ale postup je uveden jen } |
921 |
{ Funguje na C84/F84/F877 ale postup je uveden jen } |
922 |
{ u obvodu F84. Obvod C84 potrebuje stejny postup. } |
922 |
{ u obvodu F84. Obvod C84 potrebuje stejny postup. } |
923 |
OutputDataPIC(Proc.Bits,LoadDataDM_03,$FFFF); |
923 |
OutputDataPIC(Proc.Bits,LoadDataDM_03,$FFFF); |
924 |
OutCommandPIC(Dis1_01); |
924 |
OutCommandPIC(Dis1_01); |
925 |
OutCommandPIC(Dis2_07); |
925 |
OutCommandPIC(Dis2_07); |
926 |
OutCommandPIC(BeginProgramming_08); |
926 |
OutCommandPIC(BeginProgramming_08); |
927 |
xDelayMicro(10000); |
927 |
xDelayMicro(10000); |
928 |
OutCommandPIC(Dis1_01); |
928 |
OutCommandPIC(Dis1_01); |
929 |
OutCommandPIC(Dis2_07); |
929 |
OutCommandPIC(Dis2_07); |
930 |
EndPIC; |
930 |
EndPIC; |
931 |
end; |
931 |
end; |
932 |
_EE3_, |
932 |
_EE3_, |
933 |
_EE5_ : |
933 |
_EE5_ : |
934 |
begin InitHW(Port); |
934 |
begin InitHW(Port); |
935 |
writeln('Erasing PIC'); |
935 |
writeln('Erasing PIC'); |
936 |
StartPIC(5.0); |
936 |
StartPIC(5.0); |
937 |
{-- mazani cele soucastky jednim povelem --} |
937 |
{-- mazani cele soucastky jednim povelem --} |
938 |
OutputDataPIC(Proc.Bits,LoadConfiguration_00,$FFFF); {oblast konfig bitu aby se smazala i tato oblast } |
938 |
OutputDataPIC(Proc.Bits,LoadConfiguration_00,$FFFF); {oblast konfig bitu aby se smazala i tato oblast } |
939 |
OutCommandPIC(ChipErase_1F); |
939 |
OutCommandPIC(ChipErase_1F); |
940 |
xDelayMicro(8000); |
940 |
xDelayMicro(8000); |
941 |
EndPIC; |
941 |
EndPIC; |
942 |
end; |
942 |
end; |
943 |
_EE4_ : |
943 |
_EE4_ : |
944 |
begin InitHW(Port); |
944 |
begin InitHW(Port); |
945 |
writeln('Erasing PIC'); |
945 |
writeln('Erasing PIC'); |
946 |
StartPIC(5.0); |
946 |
StartPIC(5.0); |
947 |
{-- mazani pameti programu a konfig oblasti --} |
947 |
{-- mazani pameti programu a konfig oblasti --} |
948 |
OutputDataPIC(Proc.Bits,LoadConfiguration_00,$FFFF); {oblast konfig bitu aby se smazala i tato oblast } |
948 |
OutputDataPIC(Proc.Bits,LoadConfiguration_00,$FFFF); {oblast konfig bitu aby se smazala i tato oblast } |
949 |
OutputDataPIC(Proc.Bits,LoadDataPM_02,$FFFF); |
949 |
OutputDataPIC(Proc.Bits,LoadDataPM_02,$FFFF); |
950 |
OutCommandPIC(BulkErasePM_09); |
950 |
OutCommandPIC(BulkErasePM_09); |
951 |
xDelayMicro(5000); |
951 |
xDelayMicro(5000); |
952 |
OutputDataPIC(Proc.Bits,LoadDataDM_03,$FFFF); |
952 |
OutputDataPIC(Proc.Bits,LoadDataDM_03,$FFFF); |
953 |
OutCommandPIC(BulkEraseDM_0B); |
953 |
OutCommandPIC(BulkEraseDM_0B); |
954 |
xDelayMicro(5000); |
954 |
xDelayMicro(5000); |
955 |
EndPIC; |
955 |
EndPIC; |
956 |
end |
956 |
end |
957 |
else Error('Algorithm not supported',0); |
957 |
else Error('Algorithm not supported',0); |
958 |
end; {case} |
958 |
end; {case} |
959 |
end; {ToDoErase} |
959 |
end; {ToDoErase} |
960 |
|
960 |
|
961 |
procedure ToDoRun; |
961 |
procedure ToDoRun; |
962 |
{== Zapne napajeni a spusti program ==} |
962 |
{== Zapne napajeni a spusti program ==} |
963 |
begin Switches(GetParamLine(2),Data); { typ procesoru, init Data } |
963 |
begin Switches(GetParamLine(2),Data); { typ procesoru, init Data } |
964 |
InitHW(Port); |
964 |
InitHW(Port); |
965 |
P^.SetReset(zero); { aktivuj reset } |
965 |
P^.SetReset(zero); { aktivuj reset } |
966 |
P^.SetVcc(5.0); { zapni napajeni } |
966 |
P^.SetVcc(5.0); { zapni napajeni } |
967 |
xDelay(50); { pockej na ustaleni } |
967 |
xDelay(50); { pockej na ustaleni } |
968 |
P^.SetReset(one); { skonci reset } |
968 |
P^.SetReset(one); { skonci reset } |
969 |
writeln('Running ...'); |
969 |
writeln('Running ...'); |
970 |
end; {ToDoRun} |
970 |
end; {ToDoRun} |
971 |
|
971 |
|
972 |
procedure ToDoStop; |
972 |
procedure ToDoStop; |
973 |
{== Vypne napajeni ==} |
973 |
{== Vypne napajeni ==} |
974 |
begin Switches(GetParamLine(2),Data); { typ procesoru, init Data } |
974 |
begin Switches(GetParamLine(2),Data); { typ procesoru, init Data } |
975 |
InitHW(Port); |
975 |
InitHW(Port); |
976 |
P^.SetReset(zero); |
976 |
P^.SetReset(zero); |
977 |
P^.SetVcc(0); |
977 |
P^.SetVcc(0); |
978 |
writeln('... Stoped'); |
978 |
writeln('... Stoped'); |
979 |
end; {ToDoStop} |
979 |
end; {ToDoStop} |
980 |
|
980 |
|
981 |
procedure ToDoReset; |
981 |
procedure ToDoReset; |
982 |
{== Provede Reset bez vypnuti napajeni ==} |
982 |
{== Provede Reset bez vypnuti napajeni ==} |
983 |
begin Switches(GetParamLine(2),Data); { typ procesoru, init Data } |
983 |
begin Switches(GetParamLine(2),Data); { typ procesoru, init Data } |
984 |
InitHW(Port); |
984 |
InitHW(Port); |
985 |
P^.SetReset(zero); |
985 |
P^.SetReset(zero); |
986 |
P^.SetVcc(5.0); |
986 |
P^.SetVcc(5.0); |
987 |
xDelay(50); |
987 |
xDelay(50); |
988 |
P^.SetReset(one); |
988 |
P^.SetReset(one); |
989 |
writeln('... Reset ...'); |
989 |
writeln('... Reset ...'); |
990 |
end; {ToDoReset} |
990 |
end; {ToDoReset} |
991 |
|
991 |
|
992 |
procedure ToDoConvert; |
992 |
procedure ToDoConvert; |
993 |
{== Procedura pro konverzi formatu souboru ==} |
993 |
{== Procedura pro konverzi formatu souboru ==} |
994 |
var s:string; |
994 |
var s:string; |
995 |
i:integer; |
995 |
i:integer; |
996 |
Proc:ProcInfo_t; |
996 |
Proc:ProcInfo_t; |
997 |
begin {-- Zpracovani parametru --} |
997 |
begin {-- Zpracovani parametru --} |
998 |
if paramcount<3 then Help; { chybi jmeno souboru } |
998 |
if paramcount<3 then Help; { chybi jmeno souboru } |
999 |
Switches(GetParamLine(4),Data); { typ procesoru, init Data } |
999 |
Switches(GetParamLine(4),Data); { typ procesoru, init Data } |
1000 |
Data.GetProcInfo(Proc); { vytahni info o procesoru } |
1000 |
Data.GetProcInfo(Proc); { vytahni info o procesoru } |
1001 |
if Proc.Name='' then Error('Processor type missing',0); |
1001 |
if Proc.Name='' then Error('Processor type missing',0); |
1002 |
ProcDisplayInfo(Proc); { zobraz } |
1002 |
ProcDisplayInfo(Proc); { zobraz } |
1003 |
{-- Vstup dat --} |
1003 |
{-- Vstup dat --} |
1004 |
Data.Import(paramstr(2),FileFormat); |
1004 |
Data.Import(paramstr(2),FileFormat); |
1005 |
{-- Vystup dat --} |
1005 |
{-- Vystup dat --} |
1006 |
case FileFormat of |
1006 |
case FileFormat of |
1007 |
_HEX_ : FileFormat:=_TXT_; |
1007 |
_HEX_ : FileFormat:=_TXT_; |
1008 |
_TXT_ : FileFormat:=_HEX_; |
1008 |
_TXT_ : FileFormat:=_HEX_; |
1009 |
end; {case} |
1009 |
end; {case} |
1010 |
Data.Export(paramstr(3),FileFormat,';Converted from file '+paramstr(2)); |
1010 |
Data.Export(paramstr(3),FileFormat,';Converted from file '+paramstr(2)); |
1011 |
writeln('Done'); |
1011 |
writeln('Done'); |
1012 |
end; {ToDoConvert} |
1012 |
end; {ToDoConvert} |
1013 |
|
1013 |
|
1014 |
{====== Hlavni program, Entry a Exit programy ======} |
1014 |
{====== Hlavni program, Entry a Exit programy ======} |
1015 |
|
1015 |
|
1016 |
const OldExitProc:pointer=NIL; { Pro proceduru MyExitProc } |
1016 |
const OldExitProc:pointer=NIL; { Pro proceduru MyExitProc } |
1017 |
|
1017 |
|
1018 |
procedure MyExitProc; |
1018 |
procedure MyExitProc; |
1019 |
{== Ukoncujici procedura pro pripad predcasneho ukonceni programu ==} |
1019 |
{== Ukoncujici procedura pro pripad predcasneho ukonceni programu ==} |
1020 |
{ Tato procedura normalni nic ndela ale pokud je pri ukonceni } |
1020 |
{ Tato procedura normalni nic ndela ale pokud je pri ukonceni } |
1021 |
{ programu nastaven priznak aktivity programovani zavola } |
1021 |
{ programu nastaven priznak aktivity programovani zavola } |
1022 |
{ proceduru StopPIC. } |
1022 |
{ proceduru StopPIC. } |
1023 |
{ Promenne: StartPICStat .. true znamena aktivitu pri programovani } |
1023 |
{ Promenne: StartPICStat .. true znamena aktivitu pri programovani } |
1024 |
{ P .. pointer na objekt zastupujici hardware } |
1024 |
{ P .. pointer na objekt zastupujici hardware } |
1025 |
far; |
1025 |
far; |
1026 |
begin ExitProc:=OldExitProc; |
1026 |
begin ExitProc:=OldExitProc; |
1027 |
if StartPICStat and (P<>nil) then EndPIC; |
1027 |
if StartPICStat and (P<>nil) then EndPIC; |
1028 |
end; {MyExitProc} |
1028 |
end; {MyExitProc} |
1029 |
|
1029 |
|
1030 |
begin assign(output,''); { aby slo vystup presmerovat do souboru } |
1030 |
begin assign(output,''); { aby slo vystup presmerovat do souboru } |
1031 |
rewrite(output); |
1031 |
rewrite(output); |
1032 |
writeln; |
1032 |
writeln; |
1033 |
writeln('PIC Development Programmer'); |
1033 |
writeln('PIC Development Programmer'); |
1034 |
writeln('=========================='); |
1034 |
writeln('=========================='); |
1035 |
writeln('(c) miho ',date,' v ',ver); |
1035 |
writeln('(c) miho ',date,' v ',ver); |
1036 |
writeln; |
1036 |
writeln; |
1037 |
|
1037 |
|
1038 |
{-- test - zadny parametr --} |
1038 |
{-- test - zadny parametr --} |
1039 |
if paramcount=0 then Help; |
1039 |
if paramcount=0 then Help; |
1040 |
{-- zaregistruj ukonceni pro pripad predcasneho skonceni programu --} |
1040 |
{-- zaregistruj ukonceni pro pripad predcasneho skonceni programu --} |
1041 |
OldExitProc:=ExitProc; |
1041 |
OldExitProc:=ExitProc; |
1042 |
ExitProc:=@MyExitProc; |
1042 |
ExitProc:=@MyExitProc; |
1043 |
{-- rozhodni cinnost --} |
1043 |
{-- rozhodni cinnost --} |
1044 |
if UpStr(paramstr(1))='READ' then ToDoRead |
1044 |
if UpStr(paramstr(1))='READ' then ToDoRead |
1045 |
else if UpStr(paramstr(1))='PROGRAM' then ToDoProgram |
1045 |
else if UpStr(paramstr(1))='PROGRAM' then ToDoProgram |
1046 |
else if UpStr(paramstr(1))='VERIFY' then ToDoVerify |
1046 |
else if UpStr(paramstr(1))='VERIFY' then ToDoVerify |
1047 |
else if UpStr(paramstr(1))='ERASE' then ToDoErase |
1047 |
else if UpStr(paramstr(1))='ERASE' then ToDoErase |
1048 |
else if UpStr(paramstr(1))='RUN' then ToDoRun |
1048 |
else if UpStr(paramstr(1))='RUN' then ToDoRun |
1049 |
else if UpStr(paramstr(1))='STOP' then ToDoStop |
1049 |
else if UpStr(paramstr(1))='STOP' then ToDoStop |
1050 |
else if UpStr(paramstr(1))='RESET' then ToDoReset |
1050 |
else if UpStr(paramstr(1))='RESET' then ToDoReset |
1051 |
else if UpStr(paramstr(1))='CONVERT' then ToDoConvert |
1051 |
else if UpStr(paramstr(1))='CONVERT' then ToDoConvert |
1052 |
else if UpStr(paramstr(1))='HELP' then Help |
1052 |
else if UpStr(paramstr(1))='HELP' then Help |
1053 |
else Help; |
1053 |
else Help; |
1054 |
Halt(exitcode); { Exitcode si nastavuji pri chybe pri programovani } |
1054 |
Halt(exitcode); { Exitcode si nastavuji pri chybe pri programovani } |
1055 |
end. { nebo pri verifikaci. Je to treba uvest takto } |
1055 |
end. { nebo pri verifikaci. Je to treba uvest takto } |
1056 |
{ explicitne jinak se provede Halt(0). } |
1056 |
{ explicitne jinak se provede Halt(0). } |