📄 111.c
字号:
//ICC-AVR application builder : 2008/11/17 22:33:32
// Target : M8
// Crystal: 8.0000Mhz
#include <iom8v.h>
#include <macros.h>
#include "mydelay.h"
#define uchar unsigned char
void delay0ms5us(void)
{
/*精确延时0ms 5us ,晶振8MHz*/
/*us级精确延时 766us/晶振以内 延时=1+n*3 */
// CLI;//屏蔽中断
asm("LDI R18,10");//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级精确延时 24543us以内,可用nop补足余数*/
//===精确延时 4.125us,晶振8MHz ===//
//===调用函数及返回花费0.875us==//
}
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();
PORTC=0x00;
delay0ms900us();
PORTC=0xff;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -