📄 111._c
字号:
//ICC-AVR application builder : 2008/11/17 1:48:21
// Target : M8
// Crystal: 1.0000Mhz
#include <iom8v.h>
#include <macros.h>
#define uchar unsigned char
void delay()
{
/*精确延时111us,晶振4MHz */
/*us级精确延时 766us/晶振以内 延时=1+n*3 */
// CLI;//屏蔽中断
asm("LDI R18,147");//1t ,寄存器R15~R30
asm("CLZ");//1t
asm("LOOP1:DEC R18");//1t
asm("BRNE LOOP1");//1t或2t//标志位Z是0就转移
asm("NOP");//1t
asm("NOP");//1t
// SEI;
/*us级精确延时 766us/晶振以内,可用nop补足余数*/
/*精确延时0ms 111us */
}
void port_init(void)
{
PORTB = 0x00;
DDRB = 0x00;
PORTC = 0x00; //m103 output only
DDRC = 0xff;
PORTD = 0x00;
DDRD = 0x00;
}
//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(void)
{
init_devices();
delay();
PORTC=0xff;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -