Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Proteus simulating "pc=54ae9b8 is outside of ROM space

Status
Not open for further replies.

omid_juve

Full Member level 1
Joined
Jul 1, 2007
Messages
97
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,990
i write a program in bascom avr and it is compiled for about 70% . but unfortunately when i have run it in proteus . i got so many error of "pc=54ae9b8 is outside of rom space. plz read my code and tell me what can i do to simplify my code . my code is about reading the turns of the motor through using encoder pulses comes to int0 and save the position of the motor every time in nvram of ds1307 .
i want to know also in real world i will have this issue or not .
Thanks


Code Basic4GL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
$regfile = "m8def.dat" 
$crystal = 8000000 
$hwstack = 64 
$swstack = 64 
$framesize = 40 
 
Cursor Off 
Config Lcdpin = Pin , Db4 = Pinb.2 , Db5 = Pinb.3 , Db6 = Pinb.4 , Db7 = _ 
Pinb.5 , E = Pinb.1 , Rs = Pinb.0 
Config Lcd = 16 * 2 
 
 
Waitms 300 
 
 
Dim A1 As Byte 
Dim W1 As Integer 
Dim Step1 As Integer 
Dim C4 As Integer 
Dim K2 As Integer 
Dim Comp1 As Single 
Dim W2 As Single 
Dim C1 As Single 
Dim W3 As Single 
Dim Ad As Byte 
Dim X As Byte 
Dim Direction As Byte 
Dim Comp As Integer 
Dim Originplace As Byte 
Config Pind.2 = Input 
Config Pind.3 = Input 
Config Pinc.0 = Input 
Config Pinc.1 = Input 
Config Pinc.2 = Input 
Config Pinc.3 = Input 
Config Pind.7 = Input 
Config Pind.6 = Input 
Config Portd.4 = Output 
Config Portd.0 = Output 
Config Portd.1 = Output 
Config Portb.6 = Output 
$lib "I2c_twi.lbx" ' we do not use software emulated I2C but the TWI 
'Config I2cdelay = 10 
 
Config Scl = Portc.5 ' we need to provide the SCL pin name 
Config Sda = Portc.4 ' we need to provide the SDA pin name 
I2cinit 
Config Twi = 100000 ' wanted clock frequency when using $lib "i2c_twi.lbx" 
'will set TWBR and TWSR 
'Twbr = 12 'bit rate register 
'Twsr = 0 'pre scaler bits 
 
Up Alias Pinc.3 
Down Alias Pinc.2 
Zero Alias Pinc.1 
Reset1 Alias Pinc.0 
Ent Alias Pind.7 
Bl Alias Portd.4 
Enk1 Alias Pind.2 'Encoder pin A 
Enk2 Alias Pind.3 
Startm Alias Pind.6 
Leftm Alias Portd.0 
Rightm Alias Portd.1 
Status Alias Portb.6 
Const Ccw = 0 
Const Cw = 1 
Const Quarterturn = 25 
Const Fullturn = 100 
Const Dsread = &B11010001 
Const Dswrite = &B11010000 
Declare Sub Writing(byval A As Byte , Byval Address As Byte) 
Declare Sub Entering 
Declare Sub Resetsub 
Declare Sub Origin 
Declare Sub Save1(byval W33 As Integer , Address1 As Byte) 
Declare Sub Reading(a As Byte , Byval Address As Byte) 
 
 
 
Ad = 7 
X = &B00010000 
Call Writing(x , Ad) 
Ad = 0 
Call Reading(x , Ad) 
If X.7 = 1 Then 
Reset X.7 
Ad = 0 
Call Writing(x , Ad) 
End If 
 
 
 
Ad = 9 
Call Reading(x , Ad) 
C4 = X 
Shift C4 , Left , 8 
Decr Ad 
Call Reading(x , Ad) 
C4 = C4 Or X 
 
Ad = 11 
Call Reading(x , Ad) 
W1 = X 
Shift W1 , Left , 8 
Decr Ad 
Call Reading(x , Ad) 
W1 = W1 Or X 
 
Ad = 13 
Call Reading(x , Ad) 
Step1 = X 
Shift Step1 , Left , 8 
Decr Ad 
Call Reading(x , Ad) 
Step1 = Step1 Or X 
Ad = 14 
Call Reading(x , Ad) 
A1 = X 
Ad = 15 
Call Reading(x , Ad) 
Originplace = X 
 
C1 = Step1 / 100 
 
Cls 
 
A1 = 2 
If A1 <> 1 Or A1 <> 0 Then 
Cls 
Lcd "plz set the" 
Locate 2 , 1 
Lcd " turn no.!!!" 
End If 
Waitms 200 
 
 
Config Int0 = Falling 
 
 
Enable Int0 
On Int0 Enkoder_sub 
 
Enable Interrupts 
'The Encoder_sub subroutine is very simple: 
 
 
Do 
 
 
Debounce Ent , 0 , Entering , Sub 
 
 
 
 
Reset Watchdog 
Loop 
 
 
 
 
 
Enkoder_sub: 
Reset Watchdog 
 
If Originplace = 1 Then 
Locate 2 , 1 
C1 = C4 / 100 
Set Bl 
Decr C4 
Lcd "step=" ; Fusing(c1 , "#.##") 
If C4 < 0 Or C4 = 0 Then 
C4 = 0 
Ad = 8 
Call Save1(c4 , Ad) 
C1 = 0 
Step1 = 0 
Originplace = 0 
Ad = 15 
Call Writing(originplace , Ad) 
Cls 
Lcd "reached" 
C4 = 0 
C1 = 0 
A1 = 2 
Comp = W3 * Fullturn 
Step1 = Quarterturn 
Ad = 12 
Call Save1(step1 , Ad) 
Reset Rightm 
Reset Leftm 
Wait 1 
A1 = 0 
Reset Rightm 
Set Leftm 
End If 
 
Else 
 
Reset Bl 
Direction = Cw 
Incr C4 
If C4 > Step1 Or C4 = Step1 Then 
C1 = Step1 / Fullturn 
If Comp = Step1 Then 
Comp = Comp * 2 
Comp1 = Comp / 100 
If Comp1 > W2 Then 
Comp = W3 * Fullturn 
Toggle A1 
C4 = 0 
Step1 = 0 
Else 
Toggle A1 
End If 
End If 'up sub 
Step1 = Step1 + 25 
Ad = 12 
Call Save1(step1 , Ad) 
Ad = 8 
Call Save1(c4 , Ad) 
End If 
'save a1(rotation) 
Ad = 14 
Call Writing(a1 , Ad) 
 
If A1 = 0 Then 
 
Locate 1 , 1 'test of encoder if performs OK 
Lcd "turn= " ; Fusing(c1 , "#.##") ; " ccw" 
Reset Rightm 
Set Leftm 
Elseif A1 = 255 Then 
 
Locate 1 , 1 
Lcd "turn= " ; Fusing(c1 , "#.##") ; " cw" 
Set Rightm 
Reset Leftm 
End If 'if OK, then C1 wil be incr/decr in 1 
Locate 2 , 1 
Lcd "set= " ; Fusing(w2 , "#.##") 
 
End If 
 
Debounce Zero , 0 , Origin , Sub 
Debounce Reset1 , 0 , Resetsub , Sub 
Return 
 
End 
 
 
 
 
 
Sub Entering 
Set Bl 
Reset Leftm 
Reset Rightm 
Cls 
Disable Interrupts 
Waitms 500 
If W2 < .5 Then 
W2 = .5 
Elseif W2 > 9.5 Then 
W2 = 9.5 
End If 
Do 
Reset Watchdog 
Waitms 200 
If Up = 0 Then 
W2 = W2 + .5 
If W2 > 9.5 Then W2 = 9.5 
Elseif Down = 0 Then 
W2 = W2 - .5 
If W2 < .5 Then W2 = .5 
End If 
Waitms 10 
Locate 2 , 1 'test of encoder if performs OK 
Lcd "set= " ; Fusing(w2 , "#.##") 
Loop Until Ent = 0 
 
W3 = W2 / 2 
Comp = W3 * Fullturn 
W1 = Comp 
Ad = 10 
Call Save1(w1 , Ad) 
Step1 = Quarterturn 
Ad = 12 
Call Save1(step1 , Ad) 
 
C1 = 0 
A1 = 0 
 
Ad = 14 
Call Writing(a1 , Ad) 
 
C4 = 0 
Reset Rightm 
Set Leftm 
Cls 
Enable Interrupts 
End Sub 
 
 
Sub Resetsub 
Set Bl 
Disable Interrupts 
Reset Leftm 
Reset Rightm 
C4 = 0 
C1 = 0 
A1 = 0 
Comp = W3 * Fullturn 
Step1 = Quarterturn 
Ad = 8 
Call Save1(c4 , Ad) 
Ad = 12 
Call Save1(step1 , Ad) 
Ad = 14 
Call Writing(a1 , Ad) 
Cls 
Lcd "reset!!!" 
Wait 1 
Enable Interrupts 
End Sub 
 
Sub Origin 
Set Bl 
Toggle Status 
Disable Int0 
 
Reset Leftm 
Reset Rightm 
K2 = C4 - W1 
If K2 > 0 Then 
C4 = C4 - W1 
End If 
Originplace = 1 
Ad = 15 
Call Writing(originplace , Ad) 
If A1 = 0 Then 
Toggle A1 
Reset Leftm 
Set Rightm 
Elseif A1 = 255 Then 
Toggle A1 
Set Leftm 
Reset Rightm 
End If 
Ad = 14 
Call Writing(a1 , 14) 
Cls 
Locate 1 , 1 
Lcd "originating..." 
 
Enable Int0 
Enable Interrupts 
End Sub 
 
Sub Save1(byval W33 As Integer , Address1 As Byte) 
Local B33 As Byte 
 
Local B44 As Byte 
 
B33 = W33 'save c4 
Shift W33 , Right , 8 
B44 = W33 
Call Writing(b33 , Address1) 
Incr Address1 
Call Writing(b44 , Address1) 
W33 = 0 
B33 = 0 
B44 = 0 
End Sub 
 
Sub Writing(byval A As Byte , Byval Address As Byte) 
I2cstart 
I2cwbyte Dswrite 
I2cwbyte Address 
I2cwbyte A 
I2cstop 
Waitms 5 
End Sub 
 
Sub Reading(a As Byte , Byval Address As Byte) 
 
I2cstart 
I2cwbyte Dswrite 
I2cwbyte Address 
I2cstart 
I2cwbyte Dsread 
I2crbyte A , Nack 
I2cstop 
Waitms 2 
End Sub

 
Last edited by a moderator:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top