pd._c

来自「AVR单片机六路ADC采集与七段数码管显示采集值」· _C 代码 · 共 45 行

_C
45
字号
//ICC-AVR application builder : 2008-08-28 8:30:08
// Target : M8
// Crystal: 8.0000Mhz

#include <iom8v.h>
#include <macros.h>

void port_init(void)
{
 PORTB = 0x00;
 DDRB  = 0xFF;
 PORTC = 0x00; //m103 output only
 DDRC  = 0x00;
 PORTD = 0xFF;
 DDRD  = 0x0F;
}

//call this routine to initialize all peripherals
void init_devices(void)
{

 //stop errant interrupts until set up
 CLI(); //disable all interrupts
 port_init();

 MCUCR = 0x00;
 GICR  = 0x00;
 TIMSK = 0x00; //timer interrupt sources
 SEI(); //re-enable interrupts
 //all peripherals are now initialized
}

void main()
{ char a;
  init_devices();
 while(1)
 {	  PORTD |= 0xF0;
      a = (PIND & 0xF0);
	  a = (a >> 4);
	  PORTB = PORTD;
	  PORTD = (a | 0xF0);
 }
}

⌨️ 快捷键说明

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