百度空间 | 百度首页 
               
 
查看文章
 
inverter
2008-07-30 17:04

/*******************************************************************
** Project     : inverter example
*******************************************************************/

#include <hidef.h> /* for EnableInterrupts macro */
#include <MC9S08QG8.h> /* include peripheral declarations */

void main(void)
{

ACMPSC_ACMOD = 11; // 1 = comparator output on rising or fallingedge
ACMPSC_ACOPE = 1;   // 1 = comparator output enabled on external pin
SOPT1_BKGDPE = 0;   // 0 = disable bgdb mode on compo pin
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 event flag


// set up output port for an indicator
PTBDD_PTBDD7 = 1;   //set PTB.7 as an output, LED2 on demo board
PTBD_PTBD7 = 1;
PTBDD_PTBDD6 = 1;   //set PTB.6 as an output, LED1 on demo board
PTBD_PTBD6 = 1;

EnableInterrupts;   // inverter can work without generating an interrupt

for(;;)
{
    __RESET_WATCHDOG(); /* feeds the dog */
}// loop

}// end main


//ACMP ISR
interrupt 20 void   ACMP_ISR(void)
{
if (ACMPSC_ACO)
    {
    PTBD_PTBD7 = 1;   // toggle PTB.7 pin on compare event
    PTBD_PTBD6 = 0;   // toggle PTB.6 pin on compare event
    }
else
    {
    PTBD_PTBD7 = 0;   // toggle PTB.7 pin on compare event
    PTBD_PTBD6 = 1;   // toggle PTB.6 pin on compare event
    }

ACMPSC_ACF = 1;             // writing 1 clears event flag
}


类别:笔记 | 添加到搜藏 | 浏览() | 评论 (1)
 
最近读者:
 
网友评论:
1
2009-01-31 12:18 | 回复
新三宁电子将于2009年全面改板,性能更稳定、价格更优惠!! V144-001 V144-301 VIT71010.52 VIT70004.50 I320B1-16A I315B1-16A I320B1-24 HIU-535A RDENC2266TPZ (SHARP LK315T3LZ43) T87I015.01 T87I015.01 TOKO:250000003601 TOKO:250000008700 MIT68013.60 VK89144804 东芝 _D7304-B001-Z3-0 笔记本高压条 LG YDRVTP 42V6 6871QDH066B ,LG YDRVBT 42V6 6871QDH067B LG42V6缓冲板(边板) LJ92-01202A、01203A 三星40寸缓冲板(边板) 单、双、四灯测试板订做生产!!!!!! QQ:551829846 TEL:0755-21947646李生
 
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu