Count Seconds, Minutes, and Hours by Andrew Warren
SECONDS EQU [any register, on any page] MINUTES EQU SECONDS+1 HOURS EQU MINUTES+1 TICK: MOVLW SECONDS ;First, initialize the FSR to point MOVWF FSR ; at SECONDS. CALL SUB1 ;Use the BCD-increment code to inc CALL SUB0 ; SECONDS and then MINUTES. CALL SUB0 ;Call it one last time to increment ; HOURS. GOTO SUB2 ;Keep HOURS in the range [0-23]. SUB0: INCF FSR ;You enter here to point to the next SKPNC ; register before incrementing it. SUB1: INCF INDF ;Or enter here to just increment the ; register. MOVLW 6 ;Use this MOVLW/ADDWF to see whether ADDWF INDF ; reg is outside the range [0-9]. SKPDC ;Obscure DC flag usage was contributed SUBWF INDF ; by Scott Dattalo. MOVLW 0100H - 060H ;Load W with a value that'll make the SUB2: ADDWF INDF,W ; ADDWF overflow if the reg > 60. SKPNC ;If there's an overflow, clear the CLRF INDF ; register. RETLW 0100H - 024H ;Now return with W holding a value that ; will make ADDWF overflow if reg>24.
file: /Techref/microchip/countsecminhrs-aw.htm, 1KB, , updated: 2010/3/26 15:52, local time: 2024/8/14 20:44,
18.118.154.25:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://piclist.com/Techref/microchip/countsecminhrs-aw.htm"> PIC Microcontoller Time Method: Count Seconds, Minutes, and Hours by Andrew Warren</A> |
Did you find what you needed? |
![]() o List host: MIT, Site host massmind.org, Top posters @none found - Page Editors: James Newton, David Cary, and YOU! * Roman Black of Black Robotics donates from sales of Linistep stepper controller kits. * Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters. * Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated! * Contributors: Richard Seriani, Sr. |
Welcome to piclist.com! |
.