;******************************************************************************* ;* Module : DELAY10MS.SUB ;* Programmer: Tony Papadimitriou <tonyp@acm.org> ;* Purpose : Hard delay 10 msec, regardless of CPU (HC08/9S08) or system clock ;* Language : Motorola/Freescale/NXP HC08/9S08 Assembly Language (aspisys.com/ASM8) ;* Status : FREEWARE Copyright (c) 2021 by Tony Papadimitriou <tonyp@acm.org> ;* Original : http://www.aspisys.com/code/hc08/delay10ms.html ;* Note(s) : Use: #Include delay10ms.sub ;* : call Delay10ms ;* History : 10.01.15 v1.00 Original ;* : 14.09.17 Added 6 cycles for JSR for a little greater accuracy ;* : 20.01.09 v1.10 Protect user's CCR ;******************************************************************************* #ifmain ;----------------------------------------------------------------------- #ListOff #Uses mcu.inc #ListOn #endif ;------------------------------------------------------------------------ ?_OBJECT_? #Cycles 6 ;reset the cycles counter Delay10ms proc push tpa ldhx #DELAY@@ #Cycles Loop@@ @cop ;kick the watchdog aix #-1 cphx #0 bne Loop@@ #temp :cycles tap pull rtc DELAY@@ equ 10*BUS_KHZ-:cycles-:ocycles/:temp #sp ;******************************************************************************* #Exit ;******************************************************************************* @EndStats