Help using indf and fsr with 16f506

Status
Not open for further replies.

ghead

Member level 2
Joined
Nov 19, 2010
Messages
43
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
2,384
Hi all, I'm trying to take a quick succession of adc samples and use fsr to save them consecutively in locations 16h - 3ch which crosses into page 1. I'm not sure how to change page when program reaches end of page 0.

Here's exert from code but it doesn't seem to work at all.... :-?



Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
CLRF 04h
    movlw       b'01111001'             
    movwf       ADCON0            
                btfsS   PORTC,5
                goto    $-1
                ;call  _50us
                ;btfss  PORTC,5
                ;goto  $-4
                movlw   16h                     ;first location for storing A_D value 
                movwf   04h                     ;put value into File Select Register            
                bsf             ADCON0,1        ;Start A/D 
                btfsc   ADCON0,1        ;has conversion finished?
    goto        $-1             
                movf    ADRES,w ;put result of conversion into w
                movwf   INDF                    ;move value into INDF 
                incf    04h,f           ;increment FSR 
                movlw   3ch
                xorwf   04h,w           ;is file 04h = 3ch
                btfss   03,2            ;test zero flag in status   z=1 when same
                goto    $-9                     ;has loops reached end  no

 

You are not using the best PIC for this kind of application, one with more contiguous RAM would be more suitable.

Firstly, please change your code to avoid ambiguity, in particular, remove 'goto $-' and replace it with 'goto <label>' where label is the jine to jump to, it will make it much easier to read and if you add or remove instructions it saves you having to work out how many addresses to jump by. Also use register names, for example, instead of 'movwf 04h' use 'movwf FSR'.

Going back to your original problem, assuming you are using MPLAB, there is a useful macro called 'pagesel' which makes it easy to switch pages. The parameter you pass it will be the upper bits of the address you are using to store the ADC result.

Brian.
 
Reactions: ghead

    ghead

    Points: 2
    Helpful Answer Positive Rating
Hi,

To follow on from Betwixts good advice, also do not refer to the system registers by their numeric address , use their labels; example 0x04 is FSR, otherwise your code just becomes a jumble of numbers.

You are also mixed up between program memory and RAM, normally you can only write user information to RAM, not into program memory, so forget doing that and using pagesel.

You save your ADC values in RAM, the datasheet show the four BANKS available on that chip.
If you manually address the BANKs then you must use the banksel directive to let the system know which bank to use.

So what you need to do is first change the FSR adress to 0x10, the first byte of ram in of Bank0.
Unfortunately Bank1 RAM is not a consecutive address from Bank0 so you will have to manualy adjust the FSR to correctly increment to Bank1s start address of 0x30.

Another way to do what you want on a chip with such a small amont of ram is to define your own registers.

cblock 0x010 ;start of bank0 user registers
result1
result2
result3
;etc
endc

movf ADRES,W ; store adc result in register result1
movwf result1

What you might want to consider is that many more modern chips contain EEPROM, this allows you to write user data to it like RAM but it has the advantage that it retains the data when power is removed.
 
Reactions: ghead

    ghead

    Points: 2
    Helpful Answer Positive Rating
Thanks for reply I would upgrade to better pic but this is pretty much the core of the program plus code to output values to led matrix- basically audio cro.

Not to sure if i've got this right. no values are being moved into files still when simulated



Code ASM - [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
banksel      0x00    ;select bank 00?
                movlw   0x10                    ;first location for storing A_D value 
                movwf   FSR                     ;put value into File Select Register            
ADSTART         
                bsf            ADCON0,1 ;Start A/D 
                btfsc          ADCON0,1 ;has conversion finished?
                goto    $-1             
                movf            ADRES,w ;put result of conversion into w
                movwf       INDF                        ;move value into INDF 
                incf            FSR,f           ;increment FSR 
                movlw   0x1F
                xorwf           FSR,w           ;is file 04h = 0x1F
                btfss           03,2            ;test zero flag in status   z=1 when same
                goto            ADSTART                 ;has loops reached end  no      
                
ADSTART1
                banksel      0x01
                movlw   0x30                    ;first location for storing A_D value 
                movwf   FSR                     ;put value into File Select Register            
                bsf            ADCON0,1 ;Start A/D on GP0 (pin 7)
                btfsc           ADCON0,1        ;has conversion finished?
                goto      $-1           
                movf            ADRES,w ;put result of conversion into w
                movwf   INDF                    ;move value into INDF (actually 30h+)
                incf            FSR,f           ;increment FSR to 31h etc
                movlw   0x3F
                xorwf          FSR,w            ;is file 04h = 5Fh
                btfss          03,2             ;test zero flag in status   z=1 when same
                goto           ADSTART1                 ;has loops reached file end?  no

 

Hi,

Question to you -

Are you simply trying to create two or more set points so that when your ADC value goes above value 1 if does action1, when it goes above value2 it does action2 and so on.

Or are you wanting to retain the adc readings for some other reason.

Just that I cannot see what the need for using the more complicated FSRs is against using normal User Registers ?

Also what program are you using to simulate your code - its always better to show all the code becuse problems in the config parameters etc can affect the rest of the program.

- - - Updated - - -

Hi,


Here is a bit of code to simulate your situation.

A dummy value is created as the adc result, so removing any problems from the adc routine.

It sets up the FSR and compares the two values.

You can run a simple simulation in Mplab as shown in the screenshot, build the code, involke the debugger then Step Into / F7 so you step though each line of code, watching the results.

Change the stored value from 0x1F to 0x11 nad rebuild /debug to prove your xor logic works ok.
 

Attachments

  • FSR_506.rar
    77.2 KB · Views: 71
Reactions: ghead

    ghead

    Points: 2
    Helpful Answer Positive Rating
I want to take 48 samples of the adc ch one after another then detect which of 16 set points (8 ch multiplexed into 16 ch to drive leds) each sample is equal to then drive a simple display eg;

testing 48 adc values, save values in gpr

deciding which leds to drive,
setting port value from that,
move onto next adc value to display
back to start and take new adc values

Im using notepad2, mpasm and real pic simulator but I've dug out mplab and are testing and fixing at the moment will post full asm file soon.

Bit confused as when i clear FSR it still reads dec 128 so am having to use an adjusted value (by adding 192) to detect end of bank 00 or 0x1F... sure im missing something here

update soon
 
Last edited:

Heres full asm


Code ASM - [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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
;Audio CRO 
 
        list    p=16F506
        include "p16f506.inc"
        
        errorlevel      -302    ; Dont complain about BANK 1 Registers during assembly
 
        radix   dec
 
        __CONFIG        _MCLRE_OFF & _CP_OFF & _WDT_OFF &  _IntRC_OSC_RB4EN & _IOSCFS_ON
 
        
 
;****************************************************************
; variables 
;****************************************************************
 
 cblock 0x0D    
  shift  ;0Dh
  fetch  ;0Eh
  loops  ;0Fh
  fileA  ;10h
  fileB  ;12h
  fileC  ;13h
  temp1  ;14h
  test1  ;15h
  random ;16h
 endc
 
                                                ; bits ports
;SYNC equ  PORTC,5 ; rotation sync input
;IR   equ  PORTB,4      ;       Ifrared input   yet to be implemented   
;AUD  equ  PORTB,2 ; Audio input
;A               equ    PORTB,1 ; HIGH CH1 LOW  CH1 
;B               equ    PORTB,0 ; HIGH CH2 LOW  CH2
;C               equ    PORTB,5 ; HIGH CH3 LOW  CH3 
;D               equ    PORTC,0 ; HIGH CH4 LOW  CH4
;E               equ    PORTC,1 ; HIGH CH5 LOW  CH5
;F               equ    PORTC,2 ; HIGH CH6 LOW  CH6 
;G    equ  PORTC,3 ; HIGH CH7 LOW  CH7
;H    equ  PORTC,4 ; HIGH CH8 LOW  CH8 
 
 
                                                ;bits
                                
 
 
 
;****************************************************************
;Beginning of program
;****************************************************************
                
        ORG     0x3FF             ; processor reset vector
        ORG     0x000            ; coding begins here
        movwf   OSCCAL           ; update register with factory cal value 
 
                                                                
SetUp   
    clrf        VRCON
    movlw       b'11000000'
    OPTION
    movlw       b'11111111'             ;Set GPI0 input 
    TRIS        6                   ;   
    movlw       b'11111111'             ;Set GPI0 input 
    TRIS        7                   ;   
    movlw       b'01000001'             ;Set GPI0 input 
    movwf       CM1CON0                 ;Vref off (power off the comparator - saves power)
    movlw       b'01000001'             ;Set GPI0 input 
    movwf       CM2CON0                 ;Vref off (power off the comparator - saves power)
    goto        Main    
                
 
 
;************************************
;* Delays                       *
;************************************
                        
 
                
;Delay 250uS
 
_250uS  
        movlw   0xFF            ;movlw  06              ;movlw  0Ch
        movwf   fileB
        movlw   0x30
        movwf   fileA   
Del250  
        nop
        decfsz  fileB,1         ; ,1 denotes the result of the decrement 
        goto    Del250
        decfsz  fileA,1
        goto    Del250  
        retlw   00              
 
;Delay 50us
_50uS
        movlw   0x30            ;movlw  06              ;movlw  0Ch
        movwf   fileB   
Del50
        nop
        decfsz  fileB,1         ; ,1 denotes the result of the decrement 
        goto    Del50   
        retlw   00              
                
                                
 
        ;Delay 0.01 sec (10mS)
 
_10ms
        movlw   0x0A
        movwf   fileA   
DelY
        nop
        decfsz  fileA,1         ; ,1 denotes the result of the decrement 
        goto    DelY    
        retlw   00
        
        
 
;************************************
;* Sub routines                 *
;************************************
 
                
convert                                         ;converts A/D value to 8 output lines
 
 
        movwf   test1           ;load the A/D value into the "test" file 
        movlw   d'05'           ;load decimal  into w
        subwf   test1,0         ;subtract d'' from test
        btfss   03,0            ;test the carry flag
        goto    _05percent      ;carry flag is SET if w is less than "test"
                
        movwf   test1           ;load the A/D value into the "test" file 
        movlw   d'10'           ;load decimal  into w
        subwf   test1,0         ;subtract d'' from test
        btfss   03,0            ;test the carry flag
        goto    _10percent      ;carry flag is SET if w is less than "test"
                
        movwf   test1           ;load the A/D value into the "test" file 
        movlw   d'15'           ;load decimal  into w
        subwf   test1,0         ;subtract d'' from test
        btfss   03,0            ;test the carry flag
        goto    _15percent      ;carry flag is SET if w is less than "test"
                
        movwf   test1           ;load the A/D value into the "test" file 
        movlw   d'20'           ;load decimal  into w
        subwf   test1,0         ;subtract d'' from test
        btfss   03,0            ;test the carry flag
        goto    _20percent      ;carry flag is SET if w is less than "test"
                
        movwf   test1           ;load the A/D valaue into the "test" file 
        movlw   d'25'           ;load decimal  into w
        subwf   test1,0         ;subtract d'' from test
        btfss   03,0            ;test the carry flag
        goto    _25percent      ;carry flag is SET if w is less than "test"
                
        movwf   test1           ;load the A/D value into the "test" file 
        movlw   d'30'           ;load decimal  into w
        subwf   test1,0         ;subtract d'' from test
        btfss   03,0            ;test the carry flag
        goto    _30percent      ;carry flag is SET if w is less than "test"
                
        movwf   test1           ;load the A/D value into the "test" file 
        movlw   d'35'           ;load decimal  into w
        subwf   test1,0         ;subtract d'' from test
        btfss   03,0            ;test the carry flag
        goto    _35percent      ;carry flag is SET if w is less than "test"
 
        movwf   test1           ;load the A/D value into the "test" file 
        movlw   d'40'           ;load decimal  into w
        subwf   test1,0         ;subtract d'' from test
        btfss   03,0            ;test the carry flag
        goto    _40percent      ;carry flag is SET if w is less than "test"
                
        movwf   test1           ;load the A/D value into the "test" file 
        movlw   d'45'           ;load decimal  into w
        subwf   test1,0         ;subtract d'' from test
        btfss   03,0            ;test the carry flag
        goto    _45percent      ;carry flag is SET if w is less than "test"
                
        movwf   test1           ;load the A/D value into the "test" file 
        movlw   d'50'           ;load decimal  into w
        subwf   test1,0         ;subtract d'' from test
        btfss   03,0            ;test the carry flag
        goto    _50percent      ;carry flag is SET if w is less than "test"
                
        movwf   test1           ;load the A/D value into the "test" file 
        movlw   d'55'           ;load decimal  into w
        subwf   test1,0         ;subtract d'' from test
        btfss   03,0            ;test the carry flag
        goto    _55percent      ;carry flag is SET if w is less than "test"
                
        movwf   test1           ;load the A/D valaue into the "test" file 
        movlw   d'60'           ;load decimal  into w
        subwf   test1,0         ;subtract d'' from test
        btfss   03,0            ;test the carry flag
        goto    _60percent      ;carry flag is SET if w is less than "test"
                
        movwf   test1           ;load the A/D value into the "test" file 
        movlw   d'65'           ;load decimal  into w
        subwf   test1,0         ;subtract d'' from test
        btfss   03,0            ;test the carry flag
        goto    _65percent      ;carry flag is SET if w is less than "test"
                
        movwf   test1           ;load the A/D value into the "test" file 
        movlw   d'70'           ;load decimal  into w
        subwf   test1,0         ;subtract d'' from test
        btfss   03,0            ;test the carry flag
        goto    _70percent      ;carry flag is SET if w is less than "test"
 
        movwf   test1           ;load the A/D valaue into the "test" file 
        movlw   d'75'           ;load decimal  into w
        subwf   test1,0         ;subtract d'' from test
        btfss   03,0            ;test the carry flag
        goto    _75percent      ;carry flag is SET if w is less than "test"
                
        goto    _80percent      
                
                
_00percent                                      ;ALL LEDS OFF
    movlw       b'11111111'     ;Set all GP0 input    
        TRIS 6
        TRIS 7
    CLRF        PORTB
    CLRF        PORTC
        retlw   00                      
 
_05percent                                      
  movlw b'11111101'     
        TRIS 6
        movlw   b'00000010'         
        movwf   PORTB
        retlw   00      
 
_10percent
  movlw b'11111101'      
        TRIS 6
        movlw   b'00000000'          
        movwf   PORTB
        retlw   00                      
        
_15percent
  movlw b'11111110'     
        TRIS 6
        movlw   b'00000001'          
        movwf   PORTB
        retlw   00              
                
_20percent
  movlw b'11111110'     
        TRIS 6
        movlw   b'00000000'            
        movwf   PORTB
        retlw   00              
                
_25percent              
  movlw b'11011111'     
        TRIS 6
        movlw   b'00100000'      
        movwf   PORTB
        retlw   00
                                                
_30percent      
  movlw b'11011111' 
        TRIS 6
        movlw   b'00000000'         
        movwf   PORTB
        retlw   00                      
                
_35percent      
  movlw b'11111110'     
        TRIS 7
        movlw   b'00000001'        
        movwf   PORTC
        retlw   00
                                        
_40percent
  movlw b'11111110'      
        TRIS 7
        movlw   b'00000000'        
        movwf   PORTC
        retlw   00      
 
_45percent                                      
  movlw b'11111101'      
        TRIS 7
        movlw   b'00000010'      
        movwf   PORTC
        retlw   00      
 
_50percent
  movlw b'11111101'     
        TRIS 7
        movlw   b'00000000'         
        movwf   PORTC
        retlw   00                      
        
_55percent
  movlw b'11111011'     
        TRIS 7
        movlw   b'00000100'          
        movwf   PORTC
        retlw   00              
                
_60percent
  movlw b'11111011'     
        TRIS 7
        movlw   b'00000000'           
        movwf   PORTC
        retlw   00              
                
_65percent              
  movlw b'11110111'     
        TRIS 7
        movlw   b'00001000'      
        movwf   PORTC
        retlw   00
                                                
_70percent      
  movlw b'11110111'      
        TRIS 7
        movlw   b'00000000'         
        movwf   PORTC
        retlw   00                      
                
_75percent      
  movlw b'11101111'      
        TRIS 7
        movlw   b'00010000'        
        movwf   PORTC
        retlw   00
                                        
_80percent
  movlw b'11101111'     
        TRIS 7
        movlw   b'00000000'      
        movwf   PORTC
        retlw   00      
                
 
 
;*************************************
;* Main                                                         *
;*************************************
Main            
        CLRF    STATUS
        CLRF    FSR
        movlw   b'01111001'             
        movwf   ADCON0            
        btfss   PORTC,5
        goto    $-1
                ;call  _50us      ;Debounce delay
                ;btfss  PORTC,5 
                ;goto  $-4
        banksel 01    ;select bank 00?
        movlw   0x30                    ;first location for storing A_D value 
        movwf   FSR                     ;put value into File Select Register            
ADSTART         
        bsf             ADCON0,1        ;Start A/D 
        btfsc   ADCON0,1        ;has conversion finished?
        goto    $-1             
        movf    ADRES,w ;put result of conversion into w
        movlw   0xff
        movwf   INDF                    ;move value into INDF 
        incf    FSR,f           ;increment FSR 
        movlw   0xC0
        xorwf   FSR,w           ;is file 04h = 0x1F
        btfss   STATUS,Z                ;test zero flag in status   z=1 when same
        goto    ADSTART                 ;has loops reached end  no      
                
  CLRF  STATUS
        CLRF    FSR
  movlw b'01111001'             
  movwf ADCON0            
        banksel 10
        movlw   0x50                    ;first location for storing A_D value 
        movwf   FSR                     ;put value into File Select Register            
ADSTART1
        bsf             ADCON0,1        ;Start A/D 
        btfsc   ADCON0,1        ;has conversion finished?
        goto    $-1             
        movf    ADRES,w ;put result of conversion into w
        movlw   0x80
        movwf   INDF                    ;move value into INDF (actually 30h+)
        incf    FSR,f           ;increment FSR to 31h etc
        movlw   0xE0
        xorwf   FSR,w           ;is file 04h = 5Fh
        btfss   STATUS,Z                ;test zero flag in status   z=1 when same
        goto    ADSTART1                        ;has loops reached file end?  no        
                
  CLRF  STATUS
        CLRF    FSR
  movlw b'01111001'             
  movwf ADCON0            
        banksel 11
        movlw   0x70                    ;first location for storing A_D value 
        movwf   FSR                     ;put value into File Select Register            
ADSTART2
        bsf             ADCON0,1        ;Start A/D 
        btfsc   ADCON0,1        ;has conversion finished?
  goto  $-1             
        movf    ADRES,w ;put result of conversion into w
        movlw   0x20
        movwf   INDF                    ;move value into INDF (actually 30h+)
        incf    FSR,f           ;increment FSR to 31h etc
        movlw   0x80
        xorwf   FSR,w           ;is file 04h = 5Fh
        btfss   STATUS,Z                ;test zero flag in status   z=1 when same
        goto    ADSTART2                        ;has loops reached file end?  no        
 
                                                ;displays 48 values on screen 
DISPLAY                 
        movlw   d'30'
        movwf   loops           ;creates the 0.25sec refresh-time for viewing display           
DISP
        btfss   PORTC,5
        goto    $-1
                ;call  _50us
                ;btfss  PORTC,5
                ;goto  $-4
        CLRF    STATUS
        CLRF    FSR
        banksel 01    ;select bank 00?
        movlw   0x30                    ;first location for storing A_D value 
        movwf   FSR                     ;put value into File Select Register            
DISP0
        movf    INDF,w          ;move value from INDF (30h+) into w
        call    convert
        call    _50uS           ;display for short time
        call    _00percent      ;all LEDs off
        nop                                     ;gap between pixels             
        incf    FSR,f           ;increment FSR to 31h etc
        movlw   0xC0
        xorwf   FSR,w           ;is file 04h = 5Fh
        btfss   03,2            ;test zero flag in status   z=1 when same
        goto    DISP0
        
        CLRF    STATUS
        CLRF    FSR
        banksel 10
        movlw   0x50                    ;first location for storing A_D value 
        movwf   FSR                     ;put value into File Select Register            
DISP1
        movf    INDF,w          ;move value from INDF (30h+) into w
        call    convert
        call    _50uS           ;display for short time
        call    _00percent      ;all LEDs off
        nop                                     ;gap between pixels             
        incf    FSR,f           ;increment FSR to 31h etc
        movlw   0xE0
        xorwf   FSR,w           ;is file 04h = 5Fh
        btfss   03,2            ;test zero flag in status   z=1 when same
        goto    DISP1
        
        CLRF    STATUS
        CLRF    FSR
        banksel 11
        movlw   0x70                    ;first location for storing A_D value 
        movwf   FSR                     ;put value into File Select Register            
DISP2
        movf    INDF,w          ;move value from INDF (30h+) into w
        call    convert
        call    _50uS           ;display for short time
        call    _00percent      ;all LEDs off
        nop                                     ;gap between pixels             
        incf    FSR,f           ;increment FSR to 31h etc
        movlw   0x80
        xorwf   FSR,w           ;is file 04h = 5Fh
        btfss   03,2            ;test zero flag in status   z=1 when same
        goto    DISP1
 
        decfsz  loops,1         ;loops reached file 5Fh
        goto    DISP
 
;CLEAR          
;    banksel 01
;    MOVLW   0x30 ;initialize pointer
;    MOVWF   FSR ;to RAM
;NEXT
;    CLRF    INDF ;clear INDF register
;    INCF    FSR,F ;inc pointer
;    BTFSC   FSR,4 ;all done?
;    GOTO    NEXT ;NO, clear next
;    banksel 10
;   movlw   0x50
;    movwf   FSR
;NEXT0 
;    CLRF    INDF ;clear INDF register
;    INCF    FSR,F ;inc pointer
;    BTFSC   FSR,4 ;all done?
;    GOTO    NEXT0 ;NO, clear next
;    banksel 11
;    movlw   0x70
;    movwf   FSR 
;NEXT1 
;    CLRF    INDF ;clear INDF register
;    INCF    FSR,F ;inc pointer
;    BTFSC   FSR,4 ;all done?
;    GOTO    NEXT1 ;NO, clear next
                
        goto    Main
                
        
        end



or

.asm attached


Think I've got the banking sorted but now I'm not able to load the saved values to convert them for display.
When simulated nothing gets moved into the file 'test1' when the routine 'display is reached anven tho all the locations are filled..:-?
 

Attachments

  • Audio CRO - 506.asm.txt
    12.1 KB · Views: 81

Hi,

Had a quick look at your code.

If you see the data sheet figs4.5 and 4.6 on the 506 Bit7 of the FSR is not used and that bit just happens to default to one, so as my demo showed it does work properly.

The Banksel - sorry , afraid I have mislead you there a bit as this is the first pic chip I have seen that does not use banksel, so please remove all your references to Banksel.

It seems on this smaller chip, you are expected to directly or indirecty address the RaM locations by means of the FSR only as fig 4.6 shows.

For your work you are only using your own user registers, 0x0D, in the default Bank0 anyway, all other banks are addressed by your use of the FSR.

Hope that gets you running ok
 
Reactions: ghead

    ghead

    Points: 2
    Helpful Answer Positive Rating
Heh I find these datasheets so confusing.... mixing 2 chips in 1 document. Well I learned about banksel although it's irrelevant for this project. Right fixed most of my many mistakes realizing i'd set perf's using 12f510 codes and a few cut and pastes the broke my loops grrr silly me not reading properly really.

Can anyone point me in the right direction for setting up an adc input for simulator in mplab (mplab sim)?

Thanks all for input Will post project files soon if any one interested in building a 'spinning led audio cro and effects display'
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…