📄 main.c
字号:
/*******************************************************************
** Filename : main.c
** Project : acmp example
** Processor : MC9S08QG8
** Version : $v
** Location : h:\projects\freescale\acmp\
** Author : Jim McLean
** Company : Highlander Technologies
** Date : 10/26/2005, 12:13 AM
** Compiler : Metrowerks CodeWarrior HC08 C Compiler
** Notes : HC9S08QG Quick Start Example
** : This example can be used on the DEMO9S08QG8 board
**
*******************************************************************/
#include <hidef.h> /* for EnableInterrupts macro */
#include <MC9S08QG8.h> /* include peripheral declarations */
void main(void)
{
ACMPSC_ACMOD = 1; // 1 = interrupt on rising edge of comparator output
ACMPSC_ACOPE = 0; // 0 = comparator output disabled on external pin
//SOPT1_BKGDPE = 0; // disable bgdb mode on ACMPO pin if using pin for compare output
ACMPSC_ACIE = 1; // 1 = comparator interrupt enabled
ACMPSC_ACBGS = 1; // 1 = use internal reference on ACMP+
SPMSC1_BGBE = 1; // 1 = enable bandgap buffer for internal reference
ACMPSC_ACME = 1; // 1 = comparator enabled
ACMPSC_ACF = 1; // writing 1 clears compare event flag
// set up an output port as an indicator
PTBDD_PTBDD7 = 1; //set PTB.7 as an output, LED2 on demo board
PTBD_PTBD7 = 0;
EnableInterrupts; /* enable interrupts */
for(;;)
{
__RESET_WATCHDOG();
}// wait here
}// end main
//ACMP ISR
interrupt 20 void ACMP_ISR(void)
{
PTBD_PTBD7 = ~PTBD_PTBD7; // toggle PTB.7 pin on compare event
ACMPSC_ACF = 1; // writing 1 clears event flag
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -