⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timers.html

📁 一个不出名的GBA模拟器
💻 HTML
字号:
<HTML>
<HEAD>
<TITLE>Mappy VM SDK - Timers</TITLE>
<META NAME="Author" CONTENT="Michael Noland">
<META NAME="Copyright" CONTENT="(C) 2001-2002 Bottled Light, Inc.">
</HEAD>
<BODY BGCOLOR="#FFFFFF" BACKGROUND="bgtile.jpg">

<H1>Timer Subsystem</H1>

<P>
There are 4 16 bit timers, which count up according to either a specified frequency or via a cascade.  When a timer overflows (crosses from FFFF to 0000), other timers can be incremented (if the cascade bit in the following timer is set), and an interrupt can occur, if the interrupt request bit is set.<BR>
Timers are useful for implementing the passage of time in a game, to profile code, or when producing sound.
</P>

<HR><!------------------------------------------------------------------------->

<A NAME="timerxcr">
<H2>Timer Control Registers (<CODE>TIMER<EM>x</EM>_CR</CODE>)</H2>
<TABLE BORDER="1" SUMMARY="Timer Data Registers">
<TR ALIGN="CENTER" BGCOLOR="#FFD050">
	<TD>Offset</TD><TD>Name</TD><TD>Type</TD>
	<TD>F</TD><TD>E</TD><TD>D</TD><TD>C</TD><TD>B</TD><TD>A</TD><TD>9</TD><TD>8</TD>
	<TD>7</TD><TD>6</TD><TD>5</TD><TD>4</TD><TD>3</TD><TD>2</TD><TD>1</TD><TD>0</TD>
</TR>
<TR ALIGN="CENTER" BGCOLOR="#FFD050">
	<TD>$102</TD>
	<TD>TIMER0_CR</TD>
	<TD BGCOLOR="#C0FF70">Read Write</TD>
	<TD BGCOLOR="#000000" COLSPAN="8">&nbsp</TD>
	<TD BGCOLOR="#C0FF70">Enabled</TD>
	<TD BGCOLOR="#C0FF70">Trigger IRQ</TD>
	<TD BGCOLOR="#000000" COLSPAN="3">&nbsp</TD>
	<TD BGCOLOR="#C0FF70">Cascade Mode</TD>
	<TD BGCOLOR="#C0FF70" COLSPAN="2">Frequency</TD>
</TR>
<TR ALIGN="CENTER" BGCOLOR="#FFD050">
	<TD>$106</TD>
	<TD>TIMER1_CR</TD>
	<TD BGCOLOR="#C0FF70">Read Write</TD>
	<TD BGCOLOR="#000000" COLSPAN="8">&nbsp</TD>
	<TD BGCOLOR="#C0FF70">Enabled</TD>
	<TD BGCOLOR="#C0FF70">Trigger IRQ</TD>
	<TD BGCOLOR="#000000" COLSPAN="3">&nbsp</TD>
	<TD BGCOLOR="#C0FF70">Cascade Mode</TD>
	<TD BGCOLOR="#C0FF70" COLSPAN="2">Frequency</TD>
</TR>
<TR ALIGN="CENTER" BGCOLOR="#FFD050">
	<TD>$10A</TD>
	<TD>TIMER2_CR</TD>
	<TD BGCOLOR="#C0FF70">Read Write</TD>
	<TD BGCOLOR="#000000" COLSPAN="8">&nbsp</TD>
	<TD BGCOLOR="#C0FF70">Enabled</TD>
	<TD BGCOLOR="#C0FF70">Trigger IRQ</TD>
	<TD BGCOLOR="#000000" COLSPAN="3">&nbsp</TD>
	<TD BGCOLOR="#C0FF70">Cascade Mode</TD>
	<TD BGCOLOR="#C0FF70" COLSPAN="2">Frequency</TD>
</TR>
<TR ALIGN="CENTER" BGCOLOR="#FFD050">
	<TD>$10E</TD>
	<TD>TIMER3_CR</TD>
	<TD BGCOLOR="#C0FF70">Read Write</TD>
	<TD BGCOLOR="#000000" COLSPAN="8">&nbsp</TD>
	<TD BGCOLOR="#C0FF70">Enabled</TD>
	<TD BGCOLOR="#C0FF70">Trigger IRQ</TD>
	<TD BGCOLOR="#000000" COLSPAN="3">&nbsp</TD>
	<TD BGCOLOR="#C0FF70">Cascade Mode</TD>
	<TD BGCOLOR="#C0FF70" COLSPAN="2">Frequency</TD>
</TR>
</TABLE>

<H3>Details</H3>

<P>
<UL>
<LI>
 <STRONG>Bits 0 to 1</STRONG> is the counting frequency:
 <UL>
 <LI>00: Every cycle (16.78MHz) (<CODE>TIMER_CLK</CODE>)</LI>
 <LI>01: 1/64 system clock (<CODE>TIMER_CLK_DIV_64</CODE>)</LI>
 <LI>10: 1/256 system clock (<CODE>TIMER_CLK_DIV_256</CODE>)</LI>
 <LI>11: 1/1024 system clock (<CODE>TIMER_CLK_DIV_1024</CODE>)</LI>
 </UL>
</LI>
<LI>
 <STRONG>Bit 2</STRONG> is the Cascade enable.  When set, the timer is part of a cascade chain timer, where an overflow of the previous timer increments this timer, rather than using the frequency specified in bits 0 to 1.  This bit is ignored for timer 0, since it does not have a lower timer to cascade from.  The constant for this is <CODE>TIMER_CASCADE</CODE>.
</LI>
<LI>s
 <STRONG>Bit 6</STRONG> is the local enable for the timer IRQ, it must be set for an IRQ to be produced in addition to the corresponding bit in IE. The constant for this is <CODE>TIMER_IRQ_ENABLE</CODE>.
</LI>
<LI>
 <STRONG>Bit 7</STRONG> is the timer enable.  The timer will only operate when this bit is set. The constant for this is <CODE>TIMER_ENABLED</CODE>.
</LI>
</UL>
</P>

<HR><!------------------------------------------------------------------------->

<A NAME="timerx">
<H2>Timer Data Registers (<CODE>TIMER<EM>x</EM>_DATA</CODE>)</H2>

<P>
<TABLE BORDER="1" SUMMARY="Timer Data Registers">
<TR ALIGN="CENTER" BGCOLOR="#FFD050">
	<TD>Offset</TD><TD>Name</TD><TD>Type</TD>
	<TD>F</TD><TD>E</TD><TD>D</TD><TD>C</TD><TD>B</TD><TD>A</TD><TD>9</TD><TD>8</TD>
	<TD>7</TD><TD>6</TD><TD>5</TD><TD>4</TD><TD>3</TD><TD>2</TD><TD>1</TD><TD>0</TD>
</TR>
<TR ALIGN="CENTER"  BGCOLOR="#FFD050">
	<TD>$100</TD>
	<TD>TIMER0_DATA</TD>
	<TD BGCOLOR="#D0D0D0">Read Only</TD>
	<TD BGCOLOR="#D0D0D0" COLSPAN="16">Current timer value</TD>
</TR>
<TR ALIGN="CENTER"  BGCOLOR="#FFD050">
	<TD>$104</TD>
	<TD>TIMER1_DATA</TD>
	<TD BGCOLOR="#D0D0D0">Read Only</TD>
	<TD BGCOLOR="#D0D0D0" COLSPAN="16">Current timer value</TD>
</TR>
<TR ALIGN="CENTER"  BGCOLOR="#FFD050">
	<TD>$108</TD>
	<TD>TIMER2_DATA</TD>
	<TD BGCOLOR="#D0D0D0">Read Only</TD>
	<TD BGCOLOR="#D0D0D0" COLSPAN="16">Current timer value</TD>
</TR>
<TR ALIGN="CENTER"  BGCOLOR="#FFD050">
	<TD>$10C</TD>
	<TD>TIMER3_DATA</TD>
	<TD BGCOLOR="#D0D0D0">Read Only</TD>
	<TD BGCOLOR="#D0D0D0" COLSPAN="16">Current timer value</TD>
</TR>
</TABLE>

<BR>

<TABLE BORDER="1" SUMMARY="Timer Data Registers">
<TR ALIGN="CENTER" BGCOLOR="#FFD050">
	<TD>Offset</TD><TD>Name</TD><TD>Type</TD>
	<TD>F</TD><TD>E</TD><TD>D</TD><TD>C</TD><TD>B</TD><TD>A</TD><TD>9</TD><TD>8</TD>
	<TD>7</TD><TD>6</TD><TD>5</TD><TD>4</TD><TD>3</TD><TD>2</TD><TD>1</TD><TD>0</TD>
</TR>
<TR ALIGN="CENTER"  BGCOLOR="#FFD050">
	<TD>$100</TD>
	<TD>TIMER0_DATA</TD>
	<TD BGCOLOR="#FFC0C0">Write Only</TD>
	<TD BGCOLOR="#FFC0C0" COLSPAN="16">Timer latch value</TD>
</TR>
<TR ALIGN="CENTER"  BGCOLOR="#FFD050">
	<TD>$104</TD>
	<TD>TIMER1_DATA</TD>
	<TD BGCOLOR="#FFC0C0">Write Only</TD>
	<TD BGCOLOR="#FFC0C0" COLSPAN="16">Timer latch value</TD>
</TR>
<TR ALIGN="CENTER" BGCOLOR="#FFD050">
	<TD>$108</TD>
	<TD>TIMER2_DATA</TD>
	<TD BGCOLOR="#FFC0C0">Write Only</TD>
	<TD BGCOLOR="#FFC0C0" COLSPAN="16">Timer latch value</TD>
</TR>
<TR ALIGN="CENTER"  BGCOLOR="#FFD050">
	<TD>$10C</TD>
	<TD>TIMER3_DATA</TD>
	<TD BGCOLOR="#FFC0C0">Write Only</TD>
	<TD BGCOLOR="#FFC0C0" COLSPAN="16">Timer latch value</TD>
</TR>
</TABLE>
</P>

<H3>Details</H3>
<P>
Reading a timer data register returns the current value of the timer.
</P>
<P>
Any value written to a timer data register sets the latch for that timer.  A write to a latch doesn't modify the value read from the register immediately, it is loaded into the timer whenever it overflows.  For instance, writing <CODE>FFFFh</CODE> would result in the timer overflowing every time it counts up.  The default value in the latches is <CODE>0000h</CODE>.
</P>

<HR><!------------------------------------------------------------------------->

<P>
<H3>Uses and examples</H3>
<UL>
<LI>writeme fixme todo findme</LI>
</UL>
</P>

<BLOCKQUOTE>
<EM>Example: timer usage.</EM>
<HR><TABLE BORDER="1" BGCOLOR="#FFFFFF"><TR><TD><PRE>

// fixme: insert code here
</PRE></TD></TR></TABLE></BLOCKQUOTE>

<HR><!------------------------------------------------------------------------->

<P ALIGN="center">Copyright &copy; 2001 to 2002, Bottled Light, Inc.</P>

</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -