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

📄 eeprom.c

📁 EPPROM应用,测试程序,AVR内核,供初学者参考
💻 C
字号:
//ICC-AVR application builder : 2008-5-10 上午 09:22:27
// Target : m48
// Crystal: 8.0000Mhz

#include <iom48v.h>
#include <macros.h>

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

//TIMER0 initialize - prescale:1024
// WGM: Normal
// desired value: 64Hz
// actual value: 64.037Hz (0.1%)
void timer0_init(void)
{
 TCCR0B = 0x00; //stop
 TCNT0 = 0x86; //set count
 TCCR0A = 0x00; 
 TCCR0B = 0x05; //start timer
}

#pragma interrupt_handler timer0_ovf_isr:iv_TIM0_OVF
void timer0_ovf_isr(void)
{
 //TIMER0 has overflowed
}

#pragma interrupt_handler int0_isr:iv_INT0
void int0_isr(void)
{
 //external interupt on INT0
}

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

 MCUCR = 0x00;
 EICRA = 0x02; //extended ext ints
 EIMSK = 0x01;
 
 TIMSK0 = 0x01; //timer 0 interrupt sources
 TIMSK1 = 0x00; //timer 1 interrupt sources
 TIMSK2 = 0x00; //timer 2 interrupt sources
 
 PCMSK0 = 0x00; //pin change mask 0 
 PCMSK1 = 0x00; //pin change mask 1 
 PCMSK2 = 0x00; //pin change mask 2
 PCICR = 0x00; //pin change enable 
 PRR = 0x00; //power controller
 SEI(); //re-enable interrupts
 //all peripherals are now initialized
}

⌨️ 快捷键说明

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