⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main._c

📁 AVRM16 学习板--24C04
💻 _C
字号:
//ICC-AVR application builder : 2006-11-30 20:32:45
// Target : M16
// Crystal: 6.0000Mhz

#include <iom16v.h>
#include <macros.h>

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

//TWI initialisation
// bit rate:8
void twi_init(void)
{
 TWCR= 0X00; //disable twi
 TWBR= 0x08; //set bit rate
 TWSR= 0x01; //set prescale
 TWAR= 0x03; //set slave address
 TWCR= 0x45; //enable twi
}

#pragma interrupt_handler twi_isr:18
void twi_isr(void)
{
 //twi event
}

//call this routine to initialise all peripherals
void init_devices(void)
{
 //stop errant interrupts until set up
 CLI(); //disable all interrupts
 port_init();
 twi_init();

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

//
void main(void)
{
 init_devices();
 //insert your functional code here...
}

⌨️ 快捷键说明

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