iar12-1.c

来自「手把手教你学AVR单片机C程序设计实验程序」· C语言 代码 · 共 40 行

C
40
字号
#include <iom16.h>
#include<intrinsics.h>
#define uchar unsigned char	
#define SET_BIT(x,y) (x|=(1<<y))
#define CLR_BIT(x,y) (x&=~(1<<y))
/*******************************/
void port_init(void)
{
 PORTB = 0x80;
 DDRB  = 0x80;
}
/*******************************/
void comparator_init(void)
{
 ACSR = 0x40;
}
/*******************************/
void init_devices(void)
{
 port_init();
 comparator_init();
 MCUCR = 0x00;
 GICR  = 0x00;
 TIMSK = 0x00; 
}
/*******************************/
void main(void)
{
  uchar temp;
 init_devices();
 while(1)
 {
  temp=ACSR&0x20;
  if(temp==0)
  SET_BIT(PORTB,7); 
  else
  CLR_BIT(PORTB,7);
 }
}

⌨️ 快捷键说明

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