MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 1 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00001 ;************************************************************************** 00002 ; xmas_pip.asm - modified from pp001.ASM 00003 ; 00004 ; PROGRAM: Perfect Pubround LED flasher xmas edition 12/06/1009 00005 ; 00006 ; DESCRIPTION: A rechip of teh Maplin Lottery Picker to demo the "perfect pub round" or "endpoint Picked In Proportions" algorithm. 00007 ; 00008 ; AUTHOR: Douglas Rice 00009 ; Copyright 2009 00010 ; 00011 ; 00012 ;================================================================ 00013 ; "Perfect Pub Round" or "endpoints Picked In Proportion" demo 00014 ;================================================================ 00015 ; 00016 ; endpoints Picked in Proportion - 00017 ; 00018 ; Given a stream of events, and a set of N destinations, pick one and only one of the destinations or en dpoints for each event. 00019 ; 00020 ; Try to make sure the least bunching of events to each destination. 00021 ; 00022 ; e.g there are three destinations and the proportions required are 25%,50%,25% 00023 ; 00024 ; It would be possible to send events in this sequence. Send the next 25 events to endpoint A, then the next 50 events to endpoint B then the next 25 events to endpoint C and start again. 00025 ; this bunches the events excessively. This is not prefered. The systems receiving the events would need to be able at full event rate for the duration of these bunches. 00026 ; 00027 ; As reason for having N endpoints is to provide enough processing power to support an event rate of gre ater than X. 00028 ; The endpoints can only support an event rate of X. 00029 ; 00030 ; The endpoints have elastic buffers to assorb offered event rates of greater than X until the elastic b uffers are full. 00031 ; 00032 ; The best sequence would be: send next event to A, next event to B, next event to C, next event to B, n ext event to C 00033 ; 00034 ; Another sequence could be: send next event to A, next event to B, next event to B, next event to C, a nd start again. 00035 ; 00036 ; 00037 ; This demo does the Perfect Pub Round algorithm on a re-chiped Lottery Number Picker Kit I purchased fr om Maplin. 00038 ; I have also called it ePIP, which is "effective proportions in parts" or "endpoints Picked In Proporti on" 00039 ; 00040 ; It also allows you to enter the proportions, using the single button. 00041 ; 00042 ; For the demo we have 7 segment display so have 7 destinations, one segment per destination. The destin ation picked is shown by which segment is flashed. MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 2 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00043 ; 00044 ; 00045 ; Say we have three desintaions and you want to distribute calls in the proportions 25%, 40%, 35% to des tinations A, B, C. 00046 ; 00047 ; A call can only go to A, B or C. 00048 ; 00049 ; It is similar to having Oscillators whose frequencies are 25 times clock, 40 times clock , 35 times cl ock. 00050 ; 00051 ; Clock happens when a call needs to be distributed. 00052 ; 00053 ; If these are clocked, when they overflow, and the overflows are in proportions. However this is not qu ite what is required. 00054 ; 00055 ; The Perfect Pubround algorithm knocks back one of the "Oscillators" based on the one with the largest count, by the sum of proportions. 00056 ; 00057 ;================================================================ 00058 ; Demo overview 00059 ;================================================================ 00060 ; 00061 ; 00062 ; There is a display mode when the wants are used to set the frequency of 1:1 oscillators that clock eac h segment. 00063 ; 00064 ; 00065 ; It has two 7 segment displays, so for the load share output the destination picked by mapping the dest inations onto the segments. 00066 ; 00067 ; In summary you have a stream of calls and each call needs to be delivered to one of 7 destinations in the proportions specified. 00068 ; 00069 ; To acheive this have a list of wants, which can be set between 0 and F. 00070 ; 00071 ; For each destination ( or segment ) { 00072 ; have one want and a bucket variable. 00073 ; Add want to bucket 00074 ; note which is the fullest bucket. 00075 ; } 00076 ; 00077 ; The fullest bucket is the destination to pick. 00078 ; Now take summ of wants away from the fullest bucket. 00079 ; 00080 ; There is a problem if all wants are 0 as there must be a destination picked. 00081 ; On each itteration add the wants to 00082 ; 00083 ; 00084 ;================================================================ 00085 ; Operation 00086 ;================================================================ 00087 ; 00088 ; Turn on picker and the left segment displays ePIP using the porportions 8,8,8,8,8,8,8. MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 3 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00089 ; The right disply shows the segment's proportion. This can be between 0 to 0xF. 00090 ; 00091 ; The segments are picked using the proportions. 00092 ; 00093 ; Press the button, and the rate of picks increases. 00094 ; 00095 ; After the fastest rate, there is a display mode where the proportions are used to set the frequency of flash of the segments. 00096 ; The left display shows the frequencies as 1:1 oscillators, the right display shows the clock edge. 00097 ; This gives a pleasing display that slowly changes. 00098 ; 00099 ; Top set the proportions hold the button down for a long press, 00100 ; The left sisplay should light one segment and teh right display should show the current count. 00101 ; 00102 ; a short press of the button is used to increment the count. 00103 ; a long press increments the segment being set. 00104 ; 00105 ; The 8th segment is used to set special modes. No segment is displayed. If the count is 0 or even, the proportions are not modified. 00106 ; If the right number is odd, the proportions are modified tos that the display in more "interesting. 00107 ; A segments proportion is reduced based on the segment just picked for display. The proportions slowly decrese until all proportions reach 0. 00108 00109 ; A very long press returned to the display mode. 00110 ; 00111 ; 00112 ;************************************************************************** 00113 00114 00115 00116 ;#define dev16F628 00117 #define dev16F84 00118 00119 ;-------------------------------------------------------------------------- 00120 ; Sec 0. Configs for different chips 00121 ;-------------------------------------------------------------------------- 00122 00123 00124 ;-------------------------------------------------------------------------- 00125 ; Sec 0.2 Device: 16F628 00126 ;-------------------------------------------------------------------------- 00127 00128 ifdef dev16F628 00129 00130 00131 list p=16f628 ; list directive to define processor 00132 #include ; processor specific variable definitions 00133 00134 __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _INTRC_OSC_CLKOUT & _MCLRE_OFF & _LVP_OF F 00135 00136 PORTLEDS EQU PORTA 00137 RAMSTART EQU 0x20 MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 4 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00138 00139 endif 00140 00141 00142 00143 ifdef dev16F84 00144 Warning[215]: Processor superseded by command line. Verify processor symbol. 00145 list p=16F84 ; list directive to define processor 00146 #include ; processor specific variable definitions 00001 LIST 00002 ; P16F84.INC Standard Header File, Version 2.00 Microchip Technology, Inc. Message[301]: MESSAGE: (Processor-header file mismatch. Verify selected processor.) 00136 LIST 00147 2007 3FF3 00148 __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _RC_OSC 00149 00150 Warning[207]: Found label after column 1. (PORTLEDS) 00000006 00151 PORTLEDS EQU PORTB Warning[207]: Found label after column 1. (RAMSTART) 0000000C 00152 RAMSTART EQU 0x0C 00153 00154 endif 00155 00156 00157 ;-------------------------------------------------------------------------- 00158 ; Sec 1. Equates and Constants 00159 ;-------------------------------------------------------------------------- 00160 ; The General Purpose Registers start at the end of the 00161 ; Special Purpose Registers. 00162 00163 00164 00165 ; DoTimeSlice bits 00166 ; these bits are set to schedule a timer chain event 00000000 00167 DTsS4event EQU 0 00000001 00168 DTsSevent EQU 1 00169 00170 ;-------------------------------------------------------------------------- 00171 ; Sec 1.1 Button and LED 00172 ;-------------------------------------------------------------------------- 00173 00000002 00174 BUTTON_ONE EQU 2 00175 00176 ;-------------------------------------------------------------------------- 00177 ; Sec 1.0 MACROS 00178 ;-------------------------------------------------------------------------- 00179 00180 TEST_STRADDLE MACRO START 00181 if high( $ ) != high( START ) 00182 Error "Table straddles Page Boundary " + Start 00183 endif MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 5 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00184 endm 00185 00186 ;-------------------------------------------------------------------------- 00187 ; Sec 2.0 Variables 00188 ;-------------------------------------------------------------------------- 00189 ; Variables start 0x20 00190 ; 00191 00192 cblock RAMSTART 00193 00194 00195 00196 00197 0000000C 00198 DoTimeSlice 00199 00200 ; clock chain variables 0000000D 00201 CLtmr4sec ; counts quarter seconds 0000000E 00202 CLnbcdS ; stores current time 00203 0000000F 00204 IPlast ; Input variables 00000010 00205 IPnew 00206 00000011 00207 IPbuttonEvent 00000012 00208 IPbuttonEventt 00209 ;IPbuttonEventF 00000013 00210 IPsetState 00211 00000014 00212 IPoneTimer 00000015 00213 IPoneInactivityTimer 00000016 00214 IPoneCnt 00000017 00215 IPonePressedCnt 00216 00000018 00217 IPonePORTB 00218 00219 ; Buckets 00000019 00220 LDindex 0000001A 00221 LDtotalBucket 0000001B 00222 LDtotalWant 0000001C 00223 LDbucketCarry 0000001D 00224 LDbucketCarryOsc 00225 0000001E 00226 LDmaxPtr 0000001F 00227 LDmaxVal 00228 00000020 00229 LDtemp 00230 00000021 00231 LDbucket0 00000022 00232 LDbucket1 00000023 00233 LDbucket2 00234 00235 ; 00236 ; Set these up in the proportions ( or Parts ) required MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 6 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00237 ; 00238 ; Each segment of the 7 Segment LED display is a destination. 00000024 00239 LDwant0 00000025 00240 LDwant1 00000026 00241 LDwant2 00242 00000027 00243 PPcnt 00000028 00244 PPindex 00000029 00245 PPsettingMode 0000002A 00246 PPspeed 00247 00248 ; 00249 ; diplay Phase 00250 ; 00251 0000002B 00252 PPphaseLast 0000002C 00253 PPphase 0000002D 00254 PPphaseEvent 00255 0000002E 00256 PPphaseLastH 0000002F 00257 PPphaseH 00000030 00258 PPphaseEventH 00259 00260 00261 ; 00262 ; display buffers - these are multiplexed onto the diplay 00263 ; 00000031 00264 PPdispLeft 00000032 00265 PPdispRight 00266 00267 ; 00000033 00268 PPmode ; if PPmode:0 is set then setting, else display 00269 00270 00271 ; 00272 ; IOne button 00273 ; 00274 00000034 00275 OPcount 00000035 00276 OPlastCount 00277 00000036 00278 OPpegs 00279 00000037 00280 LastVar 00281 endc 00282 00283 00000030 00284 OPbufferStart EQU 0x30 ; 32 bytes of files that can store Dates 00285 00286 ;PORT_BUTTONS EQU IPonePORTB 00000005 00287 PORT_BUTTONS EQU PORTA 00288 00289 ; remaining code goes here MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 7 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00290 ; define bit in Port B 00291 00000004 00292 r equ 4 00000002 00293 y equ 2 00000001 00294 g equ 1 00295 00296 00297 ;-------------------------------------------------------------------------- 00298 ; Sec 3. Program Code 00299 ;-------------------------------------------------------------------------- 00300 0000 00301 ORG 0 0000 283F 00302 goto Start 00303 0004 00304 ORG 4 0004 29BD 00305 goto Intrtn 00306 00307 00308 ;-------------------------------------------------------------------------- 00309 ; Sec 4.3 Tables - look up 00310 ;-------------------------------------------------------------------------- 00311 00312 0005 00313 LDlookupBit 0005 00A0 00314 movwf LDtemp 0006 3000 00315 movlw high( IPjmpTable4Start ) 0007 008A 00316 movwf PCLATH 00317 ; Its not a CLICK or HOLD 0008 0820 00318 movfw LDtemp 00319 00320 ; 00321 ; set choice State Table - limited to 8 states 00322 ; 00323 ; rb3 00324 ;rb1 rb2 00325 ; rb0 00326 ;rb5 rb4 00327 ; rb6 00328 ; 00329 ; spin clockwise 00330 ; 00331 00000001 00332 rb0 equ 1 << 0 00000002 00333 rb1 equ 1 << 1 00000004 00334 rb2 equ 1 << 2 00000008 00335 rb3 equ 1 << 3 00000010 00336 rb4 equ 1 << 4 00000020 00337 rb5 equ 1 << 5 00000040 00338 rb6 equ 1 << 6 00000080 00339 rb7 equ 1 << 7 00000000 00340 off equ 0 00341 00342 MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 8 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0009 00343 IPjmpTable4Start 0009 3907 00344 andlw 0x07 000A 0782 00345 addwf PCL,f 00346 000B 3401 00347 retlw rb0 000C 3402 00348 retlw rb1 000D 3404 00349 retlw rb2 000E 3408 00350 retlw rb3 00351 000F 3410 00352 retlw rb4 0010 3440 00353 retlw rb6 0011 3420 00354 retlw rb5 00355 0012 3400 00356 retlw 0x00 00357 IF 0 != ( high ( $ ) - high ( IPjmpTable4Start ) ) 00358 Error "Table 4 straddles Page Boundary " 00359 ENDIF 00360 0013 00361 IPjmpTable4End 00362 00363 ; 00364 ; set choice State Table - limited to 8 states 00365 ; 00366 ; rb3 00367 ;rb1 rb2 00368 ; rb0 00369 ;rb5 rb4 00370 ; rb6 00371 ; 00372 00373 0013 00374 LDlookupNum 0013 00A0 00375 movwf LDtemp 0014 3000 00376 movlw high( IPjmpTable5Start ) 0015 008A 00377 movwf PCLATH 00378 ; Its not a CLICK or HOLD 00379 ; movfw LDmaxPtr 00380 0016 0820 00381 movfw LDtemp 00382 0017 00383 IPjmpTable5Start 00384 00385 ; 00386 ; 7 Segment display look up table 00387 ; 00388 0017 390F 00389 andlw 0x0F 0018 0782 00390 addwf PCL,f 0019 347E 00391 retlw rb1 | rb2 | rb3 | rb4 | rb5 | rb6 ; 0 001A 3414 00392 retlw rb2 | rb4 ; 1 001B 346D 00393 retlw rb0 | rb2 | rb3 | rb5 | rb6 ; 2 001C 345D 00394 retlw rb0 | rb2 | rb3 | rb4 | rb6 ; 3 001D 3417 00395 retlw rb0 | rb1 | rb2 | rb4 ; 4 MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 9 LOC OBJECT CODE LINE SOURCE TEXT VALUE 001E 345B 00396 retlw rb0 | rb1 | rb3 | rb4 | rb6 ; 5 001F 347B 00397 retlw rb0 | rb1 | rb3 | rb4 | rb5 | rb6 ; 6 0020 341C 00398 retlw rb2 | rb3 | rb4 ; 7 0021 347F 00399 retlw rb0 | rb1 | rb2 | rb3 | rb4 | rb5 | rb6 ; 8 0022 345F 00400 retlw rb0 | rb1 | rb2 | rb3 | rb4 | rb6 ; 9 0023 343F 00401 retlw rb0 | rb1 | rb2 | rb3 | rb4 | rb5 ; A 0024 3473 00402 retlw rb0 | rb1 | rb4 | rb5 | rb6 ; b 0025 346A 00403 retlw rb1 | rb3 | rb5 | rb6 ; C 0026 3475 00404 retlw rb0 | rb2 | rb4 | rb5 | rb6 ; d 0027 346B 00405 retlw rb0 | rb1 | rb3 | rb5 | rb6 ; E 0028 342B 00406 retlw rb0 | rb1 | rb3 | rb5 ; F 00407 IF 0 != ( high ( $ ) - high ( IPjmpTable5Start ) ) 00408 Error "Table 5 straddles Page Boundary " 00409 ENDIF 00410 0029 00411 IPjmpTable5End 00412 00413 00414 IF 0 != high ( $ ) 00415 Error "Table not in page 0 " 00416 ENDIF 00417 00418 00419 0029 00420 OPJumpTable 0029 00A0 00421 movwf LDtemp 002A 3000 00422 movlw high( IPjmpTable5Start ) 002B 008A 00423 movwf PCLATH 002C 0820 00424 movfw LDtemp 00425 002D 00426 OPjumpTableStart 00427 00428 ; 00429 ; 7 Segment display look up table 00430 ; 00431 002D 390F 00432 andlw 0x0F 002E 0782 00433 addwf PCL,f 002F 29BB 00434 goto OPnop ; count0:timer:pressed 0030 29BB 00435 goto OPnop ; count0:timer:released 0031 29BB 00436 goto OPnop ; count0:change:pressed 0032 29BB 00437 goto OPnop ; count0:change:released 00438 0033 29BB 00439 goto OPnop ; count1:timer:pressed 0034 29BB 00440 goto OPnop ; count1:timer:released 0035 29BB 00441 goto OPnop ; count1:change:pressed 0036 29BB 00442 goto OPnop ; count1:change:released 00443 0037 29BB 00444 goto OPnop ; count2:timer:pressed 0038 29BB 00445 goto OPnop ; count2:timer:released 0039 29BB 00446 goto OPnop ; count2:change:pressed 003A 29BB 00447 goto OPnop ; count2:change:released 00448 MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 10 LOC OBJECT CODE LINE SOURCE TEXT VALUE 003B 29BB 00449 goto OPnop ; count3:timer:pressed 003C 29BB 00450 goto OPnop ; count3:timer:released 003D 29BB 00451 goto OPnop ; count3:change:pressed 003E 29BB 00452 goto OPnop ; count3:change:released 00453 00454 IF 0 != ( high ( $ ) - high ( OPjumpTableStart ) ) 00455 Error "Table OPjmpTable straddles Page Boundary " 00456 ENDIF 00457 003F 00458 OPjumpTableEnd 00459 00460 00461 00462 00463 00464 ;-------------------------------------------------------------------------- 00465 ; Sec 3.1 Main Program Init Code 00466 ;-------------------------------------------------------------------------- 00467 003F 00468 Start 003F 21A0 00469 call OPinit 0040 204C 00470 call LDloadShareInit 0041 2190 00471 call PPinit 0042 2171 00472 call INinit 0043 2844 00473 goto MainLoop 00474 00475 ;-------------------------------------------------------------------------- 00476 ; Sec 3.2 Main Program 00477 ;-------------------------------------------------------------------------- 00478 0044 00479 MainLoop 0044 20CB 00480 call CLtimeslice 00481 00482 ; Any events that exist 0045 180C 00483 BTFSC DoTimeSlice,DTsS4event ; On 1/4 Second Tick 0046 20D8 00484 call SS4tick 00485 0047 188C 00486 BTFSC DoTimeSlice,DTsSevent ; On Second Tick 0048 211A 00487 call SStick 00488 0049 1912 00489 BTFSC IPbuttonEventt,BUTTON_ONE ; On BUTTON_ONE Press 004A 211F 00490 call IPoneChanged 00491 00492 ; call IPtimesliceFast ; also does switch action if edge found. 004B 2844 00493 goto MainLoop 00494 00495 ;-------------------------------------------------------------------------- 00496 ; Sec 4. Subroutines, procedures and functions 00497 ;-------------------------------------------------------------------------- 00498 00499 ;-------------------------------------------------------------------------- 00500 ; Sec 4.1 Load Share routines - LD 00501 ;-------------------------------------------------------------------------- MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 11 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00502 ; 00503 ; USing the Winner takes all method. 00504 ; For each destination, have a bucket and a corresponding want 00505 ; 00506 ; For each event add the want to the bucket 00507 ; Find out which bucket if fullest, i.e is the largest value. 00508 ; This this the destination to be used, so now subtract the sum of the wants from this bucket. 00509 ; 00510 ; 00511 00512 004C 00513 LDloadShareInit 004C 3000 00514 movlw 0 004D 0099 00515 movwf LDindex 00516 00517 004E 019E 00518 clrf LDmaxPtr 004F 20A0 00519 call LDclearBuckets 00520 0050 300F 00521 movlw 0xf 0051 00A4 00522 movwf LDwant0 0052 300E 00523 movlw 0xe 0053 00A5 00524 movwf LDwant1 0054 300D 00525 movlw 0xd 0055 00A6 00526 movwf LDwant2 00527 0056 0008 00528 return 00529 00530 expand 00531 ;Define macro Read 00532 LDloadShareMac macro n 00533 00534 MOVF LDwant#v(n),w 00535 addwf LDbucket#v(n),f 00536 00537 MOVF LDbucket#v(n),w 00538 addwf LDtotalBucket,f 00539 00540 00541 comf LDmaxVal,w 00542 addwf LDbucket#v(n),w 00543 00544 bc LDloadShare#v(n) 00545 ; New max value 00546 MOVF LDbucket#v(n),w 00547 movwf LDmaxVal 00548 movlw #v(n) 00549 movwf LDmaxPtr 00550 LDloadShare#v(n) Warning[205]: Found directive in column 1. (endm) 00551 endm 00552 0057 00553 LDdoloadShare MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 12 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0057 3080 00554 movlw 0x80 0058 009F 00555 movwf LDmaxVal 0059 019E 00556 clrf LDmaxPtr 005A 019A 00557 clrf LDtotalBucket 00558 00559 LDloadShareMac 0 M 005B 0824 M MOVF LDwant0,w 005C 07A1 M addwf LDbucket0,f M 005D 0821 M MOVF LDbucket0,w 005E 079A M addwf LDtotalBucket,f M M 005F 091F M comf LDmaxVal,w 0060 0721 M addwf LDbucket0,w M 0061 1803 2867 M bc LDloadShare0 M ; New max value 0063 0821 M MOVF LDbucket0,w 0064 009F M movwf LDmaxVal 0065 3000 M movlw 0 0066 009E M movwf LDmaxPtr 0067 M LDloadShare0 00560 LDloadShareMac 1 M 0067 0825 M MOVF LDwant1,w 0068 07A2 M addwf LDbucket1,f M 0069 0822 M MOVF LDbucket1,w 006A 079A M addwf LDtotalBucket,f M M 006B 091F M comf LDmaxVal,w 006C 0722 M addwf LDbucket1,w M 006D 1803 2873 M bc LDloadShare1 M ; New max value 006F 0822 M MOVF LDbucket1,w 0070 009F M movwf LDmaxVal 0071 3001 M movlw 1 0072 009E M movwf LDmaxPtr 0073 M LDloadShare1 00561 LDloadShareMac 2 M 0073 0826 M MOVF LDwant2,w 0074 07A3 M addwf LDbucket2,f M 0075 0823 M MOVF LDbucket2,w 0076 079A M addwf LDtotalBucket,f M M 0077 091F M comf LDmaxVal,w MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 13 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0078 0723 M addwf LDbucket2,w M 0079 1803 287F M bc LDloadShare2 M ; New max value 007B 0823 M MOVF LDbucket2,w 007C 009F M movwf LDmaxVal 007D 3002 M movlw 2 007E 009E M movwf LDmaxPtr 007F M LDloadShare2 00562 00563 ifdef doug 00564 LDloadShare0 00565 movfw LDwant0 00566 addwf LDbucket0,f 00567 MOVFw LDbucket0 00568 addwf LDtotalBucket,f 00569 00570 comf LDmaxVal,w 00571 addwf LDbucket0,w 00572 00573 bc LDloadShare1 00574 ; New max value 00575 movfw LDbucket0 00576 movwf LDmaxVal 00577 movlw 0 00578 movwf LDmaxPtr 00579 endif 00580 00581 ; 00582 ; now knock back the fullest bucket with the total counts. 00583 ; 007F 1383 00584 bankisel LDwant0 00585 0080 3021 00586 movlw LDbucket0 0081 071E 00587 addwf LDmaxPtr,w 0082 0084 00588 movwf FSR 0083 081A 00589 movfw LDtotalBucket 0084 0280 00590 subwf INDF,F 00591 0085 0008 00592 return 00593 00594 00595 00596 00597 ;Define macro Read 00598 LDfreqMac macro n 00599 MOVF LDwant#v(n),w 00600 addwf LDbucket#v(n),f 00601 skpc 00602 goto LDfreqMac#v(n) 00603 movlw #v(n) 00604 call LDlookupBit 00605 iorwf LDbucketCarry,f MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 14 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00606 xorwf LDbucketCarryOsc,f 00607 LDfreqMac#v(n) Warning[205]: Found directive in column 1. (endm) 00608 endm 00609 00610 0086 00611 LDdoFreq 0086 019C 00612 clrf LDbucketCarry 00613 LDfreqMac 0 0087 0824 M MOVF LDwant0,w 0088 07A1 M addwf LDbucket0,f 0089 1C03 M skpc 008A 288F M goto LDfreqMac0 008B 3000 M movlw 0 008C 2005 M call LDlookupBit 008D 049C M iorwf LDbucketCarry,f 008E 069D M xorwf LDbucketCarryOsc,f 008F M LDfreqMac0 00614 LDfreqMac 1 008F 0825 M MOVF LDwant1,w 0090 07A2 M addwf LDbucket1,f 0091 1C03 M skpc 0092 2897 M goto LDfreqMac1 0093 3001 M movlw 1 0094 2005 M call LDlookupBit 0095 049C M iorwf LDbucketCarry,f 0096 069D M xorwf LDbucketCarryOsc,f 0097 M LDfreqMac1 00615 LDfreqMac 2 0097 0826 M MOVF LDwant2,w 0098 07A3 M addwf LDbucket2,f 0099 1C03 M skpc 009A 289F M goto LDfreqMac2 009B 3002 M movlw 2 009C 2005 M call LDlookupBit 009D 049C M iorwf LDbucketCarry,f 009E 069D M xorwf LDbucketCarryOsc,f 009F M LDfreqMac2 00616 ; 009F 0008 00617 return 00618 00619 00620 00A0 00621 LDclearBuckets 00A0 019E 00622 clrf LDmaxPtr 00A1 01A1 00623 clrf LDbucket0 00A2 01A2 00624 clrf LDbucket1 00A3 01A3 00625 clrf LDbucket2 00626 00A4 019D 00627 clrf LDbucketCarryOsc 00628 00A5 0008 00629 return 00630 MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 15 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00631 00632 00633 00634 00A6 00635 LDloadShareDecWants 00636 00A6 0FA7 00637 incfsz PPcnt,f 00A7 0008 00638 return 00639 00A8 20A0 00640 call LDclearBuckets 00641 00A9 0BA4 00642 decfsz LDwant0,f 00AA 0008 00643 return 00644 00AB 0BA5 00645 decfsz LDwant1,f 00AC 0008 00646 return 00647 00AD 0BA6 00648 decfsz LDwant2,f 00AE 0008 00649 return 00650 00AF 0008 00651 return 00652 00B0 00653 LDloadShareIncWants 00B0 1283 1303 00654 banksel PPcnt 00B2 0FA7 00655 incfsz PPcnt,f 00B3 0008 00656 return 00657 00658 00659 ; W = want[ PPindex ] 00660 00B4 081E 00661 movfw LDmaxPtr 00662 00663 ; add offet into files 00B5 3E24 00664 addlw LDwant0 00665 00B6 1383 00666 bankisel LDwant0 00B7 0084 00667 movwf FSR 00B8 0380 00668 decf INDF,f 00669 00670 ; clear buckets and maxPtr to start with a clean sheet. 00B9 20A0 00671 call LDclearBuckets 00BA 0008 00672 return 00673 00674 00BB 00675 LDloadShareMaskCounts 00BB 300F 00676 movlw 0x0F 00BC 05A4 00677 andwf LDwant0,f 00BD 05A5 00678 andwf LDwant1,f 00BE 05A6 00679 andwf LDwant2,f 00BF 0008 00680 return 00681 00682 ;-------------------------------------------------------------------------- 00683 ; Sec 4.2 Button Poll Routine MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 16 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00684 ;-------------------------------------------------------------------------- 00685 00C0 00686 IPtimeslice 00687 ; ----___ 00688 ; --_____ 00689 ; 00690 ; This reads all Port A inputs and looks for Press 00C0 0810 00691 movfw IPnew 00C1 008F 00692 movwf IPlast 00C2 0805 00693 movfw PORT_BUTTONS 00C3 0090 00694 movwf IPnew 00695 00696 ; IP last contains new setting, IPlast contains previous 00697 00698 ; ----___ 00699 ; --_____ 00700 ; 00701 00702 ; trigger event on down and up 00C4 0810 00703 movfw IPnew ; ----______ 00C5 060F 00704 XORWF IPlast,W ; -----_____ 00705 ; ____-_____ 00706 ; now force IPbuttonEvent bits to high for new pressed button 00707 ; the service routine should clear the bit to clear the event. 00C6 0492 00708 iorwf IPbuttonEventt,F 00709 ; return 00710 00711 ; trigger event on press 00712 ; On press PA2 goes high 00C7 090F 00713 comf IPlast,W ; -----_____ 00C8 0510 00714 andwf IPnew,W ; ____------ 00715 ; ____-_____ 00716 ; now force IPbuttonEvent bits to high for new pressed button 00717 ; the service routine should clear the bit to clear the event. 00C9 0491 00718 iorwf IPbuttonEvent,F 00CA 0008 00719 return 00720 00721 ;-------------------------------------------------------------------------- 00722 ; Sec 4.3 Clock Chain Routine 00723 ;-------------------------------------------------------------------------- 00724 00CB 00725 CLtimeslice 00726 ; CLOCK TIME SLICE - run Timer chain 00727 ; Assuming: 00728 ; tmr0 is clocked by Osc. 00729 00CB 1D0B 00730 btfss INTCON,T0IF 00CC 0008 00731 return 00732 00733 ;slow down the button press code 00CD 20C0 00734 call IPtimeslice 00735 00736 ; TMR0 timeout MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 17 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00CE 110B 00737 bcf INTCON,T0IF 00CF 140C 00738 bsf DoTimeSlice,DTsS4event 00739 00740 ; This ticks 1 per second, 00741 ; 00D0 0B8D 00742 decfsz CLtmr4sec,f 00D1 0008 00743 return 00744 00745 00D2 21AA 00746 call OPtimer 00747 00748 00749 ; divide by 4 00D3 3010 00750 movlw 10 00D4 008D 00751 movwf CLtmr4sec 00D5 28D6 00752 goto CLbcdS 00753 00754 ;-------------------------------------------------------------------------- 00755 ; Sec 4.4 BDC Clock Chain Routine 00756 ;-------------------------------------------------------------------------- 00757 00758 ; BCD Counter - Seconds 00D6 00759 CLbcdS 00D6 148C 00760 bsf DoTimeSlice,DTsSevent 00761 00762 00763 00D7 0008 00764 return 00765 00766 00767 ;-------------------------------------------------------------------------- 00768 ; Sec 4.5 Event Handler Routines - Timer 00769 ;-------------------------------------------------------------------------- 00770 00D8 00771 SS4tick ; do this 4 times a second 00D8 100C 00772 bcf DoTimeSlice,DTsS4event 00773 00774 00775 00776 00777 ; look for edge 00D9 082C 00778 movfw PPphase 00DA 00AB 00779 movwf PPphaseLast 00780 00781 ; look for edge 00DB 082F 00782 movfw PPphaseH 00DC 00AE 00783 movwf PPphaseLastH 00784 00DD 0AAC 00785 incf PPphase,f 00DE 1903 00786 skpnz 00DF 0AAF 00787 incf PPphaseH,f 00788 00E0 192F 00789 btfsc PPphaseH,2 MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 18 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00E1 28EB 00790 goto SS4tick000 00791 00E2 082C 00792 movfw PPphase 00E3 3903 00793 andlw 0x03 00E4 1D03 00794 skpz 00E5 0008 00795 return 00796 00797 00798 ; 00799 ; load share 00800 ; 00E6 2057 00801 call LDdoloadShare 00E7 081E 00802 movfw LDmaxPtr 00803 00804 ; 00805 ; display segment on left and num on right. 00806 ; 00E8 2005 00807 call LDlookupBit 00E9 00B1 00808 movwf PPdispLeft 00809 00EA 2912 00810 goto SS4tick1 00811 00812 00EB 00813 SS4tick000 00814 00EB 2086 00815 call LDdoFreq 00816 00817 ; look up the Oscillator and display on Left 00818 ; look up the Oscillator carry events and display on Right 00819 00820 ; store in display buffer for display 00EC 081D 00821 movfw LDbucketCarryOsc 00ED 00B1 00822 movwf PPdispLeft 00823 00824 00EE 2912 00825 goto SS4tick1 00826 00827 00828 00829 00830 00831 00832 00833 00834 00835 00836 00837 00838 00839 00840 ; trigger event on press 00841 ; On press PA2 goes high 00EF 092B 00842 comf PPphaseLast,W ; -----_____ MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 19 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00F0 052C 00843 andwf PPphase,W ; ____------ 00844 ; ____-_____ 00845 00846 ; now force IPbuttonEvent bits to high for new pressed button 00847 ; the service routine should clear the bit to clear the event. 00F1 04AD 00848 iorwf PPphaseEvent,F 00849 00F2 092E 00850 comf PPphaseLastH,W ; -----_____ 00F3 052F 00851 andwf PPphaseH,W ; ____------ 00852 ; ____-_____ 00F4 04B0 00853 iorwf PPphaseEventH,F 00854 00F5 1EB0 00855 btfss PPphaseEventH,5 00F6 28F8 00856 goto SS4tick00 00F7 12B0 00857 bcf PPphaseEventH,5 00858 00F8 00859 SS4tick00 00860 00F8 082A 00861 movfw PPspeed 00862 ; bit map: 1 selects freq display, 0 selects ePIP display 00F9 3915 00863 andlw 0x15 00864 00FA 1903 00865 skpnz 00FB 2908 00866 goto SS4tickLoadShare 00867 00868 00869 ; has there been a PPphaseEvent 00870 ; movlw 1 << 0 00871 00FC 082A 00872 movfw PPspeed 00FD 052D 00873 andwf PPphaseEvent,w 00FE 1903 2912 00874 bz SS4tick1 00875 00876 ; reset events 00877 ; movlw ~( 1 << 0 ) 0100 092A 00878 comf PPspeed,w 0101 05AD 00879 andwf PPphaseEvent,f 00880 0102 2086 00881 call LDdoFreq 00882 00883 ; look up the Oscillator and display on Left 00884 ; look up the Oscillator carry events and display on Right 00885 00886 ; store in display buffer for display 0103 081D 00887 movfw LDbucketCarryOsc 0104 00B1 00888 movwf PPdispLeft 00889 0105 081C 00890 movfw LDbucketCarry 0106 00B2 00891 movwf PPdispRight 00892 ; goto SS4tick1 00893 00894 0107 2912 00895 goto SS4tick1 MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 20 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00896 00897 0108 00898 SS4tickLoadShare 00899 00900 ; has timer event 0108 082A 00901 movfw PPspeed 0109 052D 00902 andwf PPphaseEvent,w 010A 1903 290F 00903 bz SS4tick0 00904 00905 ; reset events 010C 092A 00906 comf PPspeed,w 010D 05AD 00907 andwf PPphaseEvent,f 00908 010E 2057 00909 call LDdoloadShare 00910 00911 ; ; test bit in 00912 ; btfsc LDwant7,0 00913 ; call LDloadShareIncWants 00914 ; call LDloadShareMaskCounts 00915 00916 ; Multiplex display buffers onto LEDS now 00917 00918 00919 010F 00920 SS4tick0 00921 00922 00923 00924 00925 00926 00927 ; look up count for PPindex 00928 ; PPindex 00929 00930 ; movfw PPindex 00931 ; btfss PPmode,0 010F 081E 00932 movfw LDmaxPtr 00933 00934 ; 00935 ; display segment on left and num on right. 00936 ; 0110 2005 00937 call LDlookupBit 0111 00B1 00938 movwf PPdispLeft 00939 00940 00941 00942 ; ; W = want[ PPindex ] 00943 ; movfw PPindex 00944 ; btfss PPmode,0 00945 ; movfw LDmaxPtr 00946 ; 00947 ; ; add offet into files 00948 ; addlw LDwant0 MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 21 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00949 ; 00950 ; bankisel LDwant0 00951 ; movwf FSR 00952 ; movfw INDF 00953 ; 00954 ; call LDlookupNum 00955 ; 00956 ; movwf PPdispRight 00957 ; goto SS4tick1 00958 00959 00960 00961 0112 00962 SS4tick1 00963 ; multiplex left and right displays on alternate phases 00964 00965 ; 00966 ; turn off display 00967 ; 00968 ; bcf PORTA,0 00969 ; bcf PORTA,1 00970 00971 ;PPhase is incremented, so bit 1 selects which display is to be powered 00972 ; btfss PPphase,1 00973 ; goto SS4tick2 00974 00975 ; 00976 ; drive left hand display 00977 ; 00978 ; movfw PPdispLeft 0112 0931 00979 comf PPdispLeft,w 0113 0086 00980 movwf PORTB 00981 00982 ; bsf PORTA,0 00983 ; bcf PORTA,1 0114 0008 00984 return 00985 0115 00986 SS4tick2 00987 ; 00988 ; drive right hand display 00989 ; 0115 0832 00990 movfw PPdispRight 0116 0086 00991 movwf PORTB 00992 0117 1005 00993 bcf PORTA,0 0118 1485 00994 bsf PORTA,1 0119 0008 00995 return 00996 00997 011A 00998 SStick 011A 108C 00999 bcf DoTimeSlice,DTsSevent 011B 215C 01000 call IPts 011C 0008 01001 return MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 22 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01002 01003 011D 01004 SMtick 011D 108C 01005 bcf DoTimeSlice,DTsSevent 011E 0008 01006 return 01007 01008 ;-------------------------------------------------------------------------- 01009 ; Sec 4.6 Event Handler Routine - Buttons 01010 ;-------------------------------------------------------------------------- 01011 ; come here and combine the current state and the current event to index into 01012 ; the state jump table. 01013 ; 01014 011F 01015 IPoneChanged 011F 1112 01016 bcf IPbuttonEventt,BUTTON_ONE 01017 0120 21AA 01018 call OPtimer 01019 01020 01021 ; test for up/down 0121 1D10 01022 btfss IPnew,BUTTON_ONE 0122 292B 01023 goto IPoneReleased 01024 01025 ; 01026 ; During press - count timeouts 01027 ; On release start a timer to end incrementing the same digit. 01028 ; On next press, if timer is stopped move onto next digit. 01029 ; On next press, if timer is running increment current digit 01030 ; long presses stop the timer. 01031 01032 ; reset pressed counter on count 01033 ; ______----_______ count ticks while pressed and action on release 01034 ; 01035 01036 ; if count = 1 then ZERO 01037 ; if count = 0 then increment count and wait long release 01038 ; if pressed while timer running, then increment current digit 01039 ; 01040 0123 01041 IPonePressed 01042 01043 ; reset counter incremented during pressed. 0123 0197 01044 clrf IPonePressedCnt 01045 01046 01047 ; First test if timer is still running to indicate if the same digit is to be imcremente d. 01048 ; test if the timer has stopped. 0124 0894 01049 MOVF IPoneTimer,f 0125 1903 01050 SKPNZ 0126 2929 01051 goto IPpressAfterLongPause 01052 01053 MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 23 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01054 ; buffer timer 01055 01056 01057 ; start of press 0127 2157 01058 call IPstartTimer 01059 0128 0008 01060 return 01061 01062 0129 01063 IPpressAfterLongPause 01064 ; move onto the next digit 01065 ; NOTE: no range test 0129 2157 01066 call IPstartTimer 012A 0008 01067 return 01068 01069 012B 01070 IPoneReleased 01071 ; The button has been released 01072 ; If a very long press, then reset the state machine 01073 ; If a long press then digit is zero 01074 ; If a short press then increment a digit 01075 ; 01076 ; test if the timer has stopped. 01077 ; If so the button was pressed for a very long time 012B 0817 01078 MOVF IPonePressedCnt,W 012C 1903 2932 01079 BZ IPReleasedAfterShortPress ; count = 0 012E 3EFF 01080 ADDLW -1 012F 1903 2944 01081 BZ IPReleasedAfterLongPress ; count = 1 0131 294E 01082 goto IPReleasedAfterVeryLongPress ; count = 2 or more 01083 0132 01084 IPReleasedAfterShortPress 01085 0132 1CA9 01086 btfss PPsettingMode,1 0133 293E 01087 goto IPReleasedAfterShortPress1 01088 ; Incrementing counter 01089 ; Short press, do nothing until long release 01090 ; If timer still running the 01091 01092 ; inc 01093 0134 3024 01094 movlw LDwant0 0135 0728 01095 addwf PPindex,w 01096 0136 1383 01097 bankisel LDwant0 0137 0084 01098 movwf FSR 0138 0A80 01099 incf INDF,f 01100 0139 300F 01101 movlw 0x0F 013A 0580 01102 andwf INDF,f 01103 013B 1433 01104 bsf PPmode,0 01105 013C 2157 01106 call IPstartTimer MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 24 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01107 013D 0008 01108 return 01109 013E 01110 IPReleasedAfterShortPress1 01111 013E 1003 01112 bcf STATUS,C 013F 0CAA 01113 rrf PPspeed,f 01114 01115 ; if zero set it to 1 0140 08AA 01116 movf PPspeed,f 0141 1903 01117 skpnz 0142 16AA 01118 bsf PPspeed,5 01119 0143 0008 01120 return 01121 01122 01123 0144 01124 IPReleasedAfterLongPress 01125 ; This indicates a long press, zero the current digit and increment pointer 01126 ; Clear the current digit. 01127 0144 1383 01128 bankisel LDwant0 01129 0145 1433 01130 bsf PPmode,0 01131 0146 0AA8 01132 incf PPindex,f 0147 3007 01133 movlw 0x07 0148 05A8 01134 andwf PPindex,f 01135 01136 ; not sure why 0149 01A9 01137 clrf PPsettingMode 014A 14A9 01138 bsf PPsettingMode,1 014B 20A0 01139 call LDclearBuckets 01140 01141 01142 ; Stop the timers to simulate a long pause to move onto the next digit. 014C 0194 01143 clrf IPoneTimer 014D 0008 01144 return 01145 01146 014E 01147 IPReleasedAfterVeryLongPress 014E 3007 01148 movlw 7 014F 00A8 01149 movwf PPindex 01150 0150 01B3 01151 clrf PPmode 0151 01A9 01152 clrf PPsettingMode 0152 01AA 01153 clrf PPspeed 0153 3008 01154 movlw 1 << 3 0154 00AA 01155 movwf PPspeed 0155 20A0 01156 call LDclearBuckets 0156 0008 01157 return 01158 01159 MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 25 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0157 01160 IPstartTimer 01161 ; clrf IPoneTimer ; clear the timer 0157 3004 01162 movlw 4 0158 0094 01163 movwf IPoneTimer ; this timer uses a shitf reg 01164 0159 3020 01165 movlw 20 015A 0095 01166 movwf IPoneInactivityTimer ; this timer uses a shitf reg 015B 0008 01167 return 01168 015C 01169 IPts 01170 ; 01171 ; Time Slice 01172 ; 01173 01174 ;is IPoneInactivityTimer timer is running, if so decrement it 01175 ; 01176 015C 0895 01177 MOVF IPoneInactivityTimer,f 015D 1D03 01178 SKPZ Message[305]: Using default destination of 1 (file). 015E 0B95 01179 decfsz IPoneInactivityTimer 015F 2961 01180 goto IPtsActivity 0160 0008 01181 return 01182 01183 0161 01184 IPtsActivity 01185 ;test if timer is running, if so decrement it 01186 ; 0161 0894 01187 MOVF IPoneTimer,f 0162 1903 01188 SKPNZ 0163 0008 01189 return 0164 0B94 01190 decfsz IPoneTimer,f 0165 0008 01191 return 01192 01193 ; Timeout 01194 ; Test if button pressed, if so increment Pressed Counter 0166 1D0F 01195 btfss IPlast,BUTTON_ONE 0167 0008 01196 return 01197 0168 01198 IPtsWhilePressed 0168 0A97 01199 incf IPonePressedCnt,f 01200 ; restart timer. Already blinked 0169 2157 01201 call IPstartTimer 01202 016A 216C 01203 call PPblink 01204 016B 0008 01205 return 01206 01207 01208 01209 ;-------------------------------------------------------------------------- 01210 ; Sec 4.7 Flash Display as Key Click 01211 ;-------------------------------------------------------------------------- MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 26 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01212 01213 016C 01214 PPblink 016C 30FF 01215 movlw 0xFF 016D 0086 01216 movwf PORTB 016E 1405 01217 bsf PORTA,0 016F 1085 01218 bcf PORTA,1 0170 0008 01219 return 01220 01221 ;-------------------------------------------------------------------------- 01222 ; Sec 5. Initilization code - 01223 ;-------------------------------------------------------------------------- 01224 01225 0171 01226 INinit 01227 01228 ; Enable Interupts 0171 3000 01229 movlw H'00' 0172 008B 01230 movwf INTCON 01231 01232 01233 ifdef dev16F628 01234 01235 clrf PORTA ;Initialize PORTA by setting 01236 ;output data latches 01237 ; you have to do this for the 16F628 01238 BANKSEL CMCON 01239 movlw 0X07 ;Turn comparators off and 01240 movwf CMCON ;enable pins for I/O 01241 01242 endif 01243 01244 0173 1683 1303 01245 banksel TRISB 0175 3080 01246 movlw 0X80 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0176 0086 01247 movwf TRISB 0177 30FF 01248 movlw 0xFF Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0178 0085 01249 movwf TRISA 01250 01251 ; Change Prescaler 0179 0064 01252 CLRWDT 01253 01254 ; Set up prescaller for 8192 / 16 = 512 ticks perseconds. 01255 01256 ; movlw 0x0 + 7 ; For Tmr0 0=/2, 1=/4, 2=/8,3=/16 017A 3000 01257 movlw 0x0 + 0 ; For Tmr0 0=/2, 1=/4, 2=/8,3=/16 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 017B 0081 01258 movwf OPTION_REG 017C 3000 01259 movlw 0x0 + 0 ; For Tmr0 0=/2, 1=/4, 2=/8,3=/16 017D 1283 1303 01260 banksel STATUS 017F 1283 01261 bcf STATUS,RP0 MPASM 5.33 XMAS_PIP.ASM 12-17-2009 22:33:19 PAGE 27 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01262 01263 01264 ifdef dev16F628 01265 01266 ; Configure Tmr 1 01267 movlw 0x0 | 1<