element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
NXP Semiconductors
  • Products
  • Manufacturers
  • NXP Semiconductors
  • More
  • Cancel
NXP Semiconductors
Forum any advice about RS08KA2 two hour delay timer?
  • Blog
  • Forum
  • Documents
  • Events
  • Quiz
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join NXP Semiconductors to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 1 reply
  • Subscribers 39 subscribers
  • Views 420 views
  • Users 0 members are here
Related

any advice about RS08KA2 two hour delay timer?

Former Member
Former Member over 16 years ago

I'm a novice and I'm looking for help on a two hour delay timer for a project I'm working on.

I'm using a RS08KA2 MC and it doesn't have a RTC so I've nested loops to create a long delay but it isn't very accurate. Does anyone know how to implement a long delay in the KA2 that may be easier to implement and more accurate? I've looked at AN3413 Low Cost digital timer but it ties in a ADC and I can't seem to understand the code.

 

Below is what I've done to get a long delay and it works but seems like a very bad way to do it.

I included all the code since it's such a small program.

 

Any advice would be appreciated,

 

=====================================================================================
  ORG RAMStart
counter:        DS.B  1
counter2:      DS.B  1         
counter3:      DS.B  1
time2:          DS.B  1

; Const Section
ConstSection:  SECTION
time:           DC.B  $FF

; Code Section

            ORG ROMStart
  
;*******************************************************************************************
; Peripheral Initialization
;*******************************************************************************************
init:

;CONFIGURES SYSTEM CONTROL
    mov #HIGH_6_13(SOPT), PAGESEL
    mov #$03, MAP_ADDR_6(SOPT)      ; Disables COP, enables BKGD (PTA3) and RESET (PTA2)                                

;CONFIGURES CLOCK (FEI Operation Mode)       
    mov #HIGH_6_13(NV_ICSTRM),PAGESEL
    lda MAP_ADDR_6(NV_ICSTRM)       
   sta ICSTRM                      ; Sets trimming value 
   clr ICSC1                         ; Selects FLL as clock source and disables it in stop mode
   clr ICSC2                         ; ICSOUT = DCO output frequency 
wait_clock:
    brset CLKST,ICSSC,wait_clock      ; Waits until FLL is engaged
  
;CONFIGURES TIMER
    mov #$70, MTIMSC                    ; Enables interrupt, stops and resets timer counter
    mov #$FF, MTIMMOD                 ; MTIM modulo = 256 counts before interrupt
    mov #$08, MTIMCLK                  ; Selects fBUS as reference clock (8 MHz)


;CONFIGURES I/O CONTROL PORT   
    mov #$31, PTADD                   ; Configures PTA0, PTA4 and PTA5 as output,PTA1 as an Input
    mov #HIGH_6_13(PTAPE), PAGESEL
    mov #$04, MAP_ADDR_6(PTAPE)       ; Enables Pull UP on PTA2 

;CONFIGURES KEYBOARD INTERRUPTS (KBI)
    mov #$00, KBIES                   ; Selects Falling Edge/Low on Pin
    mov #$02, KBIPE                   ; PTA1 as KBI input
    mov #$06, KBISC                   ; Clears any false interrupts
  
  
    clr PTAD                          ; Clears PTA port
    rts

 

 

;*******************************************************************************************
; Entry Point
;*******************************************************************************************
_Startup:
main:
    bsr init
    clr counter
    clr counter2
    clr counter3

main_loop:

loopRelay:
  
    mov #HIGH_6_13(SIP1),PAGESEL       
    brset 4,MAP_ADDR_6(SIP1),RelayOn      ;If button pushed goto Relay on
  
    bra loopRelay
                                                ;No push button continue to wait
RelayOn:
    bset 2, KBISC                         ;Clear KBI Interrupt
    bset 5, PTAD                          ;Turn on Relay LED
    bset 4,PTAD                           ;Turn on Relay

 

;BELOW IS THE NESTED DELAY LOOPS I USED 

 

StartDelay:
    mov #$60,MTIMSC

    bclr 4,MTIMSC                         ; Start MTIM counter

    wait
    lda counter
    cbeqa #255,Delay2
    inc counter
    bra StartDelay

Delay2:
    clr counter
    lda counter2
    cbeqa #55,Delay3
    inc counter2
    bra StartDelay
  
Delay3:
    clr counter
    clr counter2
    lda counter3
    cbeqa #57, RelayOff
    inc counter3
    bra StartDelay

 

RelayOff
    clr counter
    clr counter2
    clr counter3
    bclr 5,PTAD
    bclr 4,PTAD
    bra loopRelay

  • Sign in to reply
  • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube