Download 2 - Homepages at WMU
Transcript
Example 8.6: Estimating an Input
Waveforms Frequency
#include <hcs12.h>
#include <vectors12.h>
#include <convert.c>
#include <stdio.c>
#define
INTERRUPT __attribute__((interrupt))
unsigned int frequency;
void
INTERRUPT
TC0_isr(void);
void main(void)
{
char arr[7];
char *msg = "Signal frequency is ";
int i, oc_cnt;
unsigned frequency;
UserTimerCh0 = (unsigned short)&TC0_isr;
TSCR1 = 0x90;
/* enable TCNT and fast flag clear */
TSCR2 = 0x02;
/* set prescale factor to 4 */
TIOS
= 0x02;
/* select OC1 and IC0 */
oc_cnt
= 100;
/* prepare to perform 100 OC1 operations */
frequency = 0;
ECE
4510/5530
Material from or based on: The HCS12/9S12: An Introduction to Software & Hardware
Interfacing, Thomson Delmar Learning, 2006.