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
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
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
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?