Hardware Reference
In-Depth Information
The C language version of the function to be compiled by the CodeWarrior is as follows:
void delayby10ms(int k)
{
int i;
TSCR1 | 5 TFFCA;
// enable fast timer flag clear
for (i 5 0; i , k; i 11 ) {
MCCTL 5 0x07;
// enable modulus down counter with 1:16 as prescaler
MCCNT 5 15000;
// let modulus down counter count down from 15,000
while(!(MCFLG & MCZF));
MCCTL & 5 , 0x04;
// disable modulus down counter
}
}
By storing the previous delay function in the appropriate directory, one can include it in
the program. The following program calls the previous subroutine to create a delay of 200 ms,
increments a count value, and then outputs this count value to Port B:
#include “c:\miniIDE\hcs12.inc”
org
$1000
count
ds.b
1
org
$1500
movb #$FF,DDRB
clr
count
movb
count,PORTB
loops
ldy
#20
; create 200-ms delay
jsr
delayby10ms
;
inc
count
; increment count by 1
movb
count,PORTB
; update LED displays
bra loops
#include “c:\miniIDE\delay.asm”
end
Delay functions that create time delays by a multiple of other delay times can be created by
modifying the previous delay function. The file delay.asm (and delay.c ) contains the following
delay functions and is contained in the complementary CD:
1. delayby10
μ
s
2. delayby50
s
3. delayby1ms
4. delayby10ms
5. delayby100ms
μ
8.9 Enhanced Capture Timer (ECT) Module
Some of the HCS12 members (e.g., MC9S12DG256) implement an enhanced capture timer
(ECT) module that has the features of the standard timer (TIM) module enhanced by additional
features in order to enlarge the field of applications. These additional features are
One 16-bit buffer register for each of the four input-capture (IC) channels.
Four 8-bit pulse accumulators. Each of these 8-bit pulse accumulators has an
associated 8-bit buffer. Two of these 8-bit pulse accumulators can be concatenated
into a single 16-bit pulse accumulator.
 
Search WWH ::




Custom Search