文件名称:AVR Studio例子
-
所属分类:
- 标签属性:
- 上传时间:2020-08-07
-
文件大小:296.06kb
-
已下载:0次
-
提 供 者:
-
相关连接:无
-
下载说明:别用迅雷下载,失败请重下,重下不扣分!
下载1 (296.06kb)
别用迅雷、360浏览器下载。
如迅雷强制弹出,可右键点击选“另存为”。
失败请重下,重下不扣分。
如迅雷强制弹出,可右键点击选“另存为”。
失败请重下,重下不扣分。
介绍说明--下载内容来自于网络,使用问题请自行百度
/*
* ADC.c
*
* Created: 22-5-2011 8:22:10 PM
* Author: Wingston
*/
#include <avr/io.h>
#include <avr/interrupt.h>
uint16_t ReadChannel(int mux);
int main (void)
{
DDRC = 0xFF;
uint16_t adcval = 0;
while(1){
adcval = ReadChannel(0);
if(adcval <400)
{
PORTC = 0;
}
else
{
PORTC = 0xFF;
}
}
}
uint16_t ReadChannel(int mux)
{
uint8_t i;
uint16_t result = 0;
ADCSRA = (1<<ADEN) | (1<<ADPS1) | (1<<ADPS0);
ADMUX = mux; // channel select
ADMUX |= (1<<REFS1) | (1<<REFS0); // VCC
ADCSRA |= (1<<ADSC); // start ADC
while ( ADCSRA & (1<<ADSC) ) {
;
}
for(i=0;i<4;i++)
{
ADCSRA |= (1<<ADSC);
while ( ADCSRA & (1<<ADSC) ) {
;
}
result += ADCW;
}
ADCSRA &= ~(1<<ADEN); // ADC deactivate (2)
result /= 4;
return result;
}
* ADC.c
*
* Created: 22-5-2011 8:22:10 PM
* Author: Wingston
*/
#include <avr/io.h>
#include <avr/interrupt.h>
uint16_t ReadChannel(int mux);
int main (void)
{
DDRC = 0xFF;
uint16_t adcval = 0;
while(1){
adcval = ReadChannel(0);
if(adcval <400)
{
PORTC = 0;
}
else
{
PORTC = 0xFF;
}
}
}
uint16_t ReadChannel(int mux)
{
uint8_t i;
uint16_t result = 0;
ADCSRA = (1<<ADEN) | (1<<ADPS1) | (1<<ADPS0);
ADMUX = mux; // channel select
ADMUX |= (1<<REFS1) | (1<<REFS0); // VCC
ADCSRA |= (1<<ADSC); // start ADC
while ( ADCSRA & (1<<ADSC) ) {
;
}
for(i=0;i<4;i++)
{
ADCSRA |= (1<<ADSC);
while ( ADCSRA & (1<<ADSC) ) {
;
}
result += ADCW;
}
ADCSRA &= ~(1<<ADEN); // ADC deactivate (2)
result /= 4;
return result;
}
(系统自动生成,下载前可以参看下载内容)
下载文件列表
压缩包 : AVR-Examples-master.zip 列表 AVR-Examples-master/ AVR-Examples-master/ADC/ AVR-Examples-master/ADC/ADC.avrsln AVR-Examples-master/ADC/ADC.avrsuo AVR-Examples-master/ADC/ADC/ AVR-Examples-master/ADC/ADC/ADC.avrgccproj AVR-Examples-master/ADC/ADC/ADC.c AVR-Examples-master/ADC/ADC/Debug/ AVR-Examples-master/ADC/ADC/Debug/ADC.d AVR-Examples-master/ADC/ADC/Debug/ADC.eep AVR-Examples-master/ADC/ADC/Debug/ADC.elf AVR-Examples-master/ADC/ADC/Debug/ADC.hex AVR-Examples-master/ADC/ADC/Debug/ADC.lss AVR-Examples-master/ADC/ADC/Debug/ADC.map AVR-Examples-master/ADC/ADC/Debug/ADC.o AVR-Examples-master/ADC/ADC/Debug/Makefile AVR-Examples-master/ADC/ADC/Debug/Outputfile.d AVR-Examples-master/AVRDude/ AVR-Examples-master/AVRDude/AVRDude/ AVR-Examples-master/AVRDude/AVRDude/avrdude.conf AVR-Examples-master/AVRDude/AVRDude/avrdude.exe AVR-Examples-master/AVRDude/AVRDude/libusb0.dll AVR-Examples-master/AVRDude/AVRDude/libusb0.sys AVR-Examples-master/AVRDude/AVRDude/usbtinyisp.cat AVR-Examples-master/AVRDude/AVRDude/usbtinyisp.inf AVR-Examples-master/Blinking_LED/ AVR-Examples-master/Blinking_LED/Blinking_LED.avrsln AVR-Examples-master/Blinking_LED/Blinking_LED.avrsuo AVR-Examples-master/Blinking_LED/Blinking_LED/ AVR-Examples-master/Blinking_LED/Blinking_LED/Blinking_LED.avrgccproj AVR-Examples-master/Blinking_LED/Blinking_LED/Blinking_LED.c AVR-Examples-master/Blinking_LED/Blinking_LED/Debug/ AVR-Examples-master/Blinking_LED/Blinking_LED/Debug/Blinking_LED.d AVR-Examples-master/Blinking_LED/Blinking_LED/Debug/Blinking_LED.eep AVR-Examples-master/Blinking_LED/Blinking_LED/Debug/Blinking_LED.elf AVR-Examples-master/Blinking_LED/Blinking_LED/Debug/Blinking_LED.hex AVR-Examples-master/Blinking_LED/Blinking_LED/Debug/Blinking_LED.lss AVR-Examples-master/Blinking_LED/Blinking_LED/Debug/Blinking_LED.map AVR-Examples-master/Blinking_LED/Blinking_LED/Debug/Blinking_LED.o AVR-Examples-master/Blinking_LED/Blinking_LED/Debug/Makefile AVR-Examples-master/Blinking_LED/Blinking_LED/Debug/Outputfile.d AVR-Examples-master/LCD_test/ AVR-Examples-master/LCD_test/LCD_test.avrsln AVR-Examples-master/LCD_test/LCD_test.avrsuo AVR-Examples-master/LCD_test/LCD_test/ AVR-Examples-master/LCD_test/LCD_test/Debug/ AVR-Examples-master/LCD_test/LCD_test/Debug/LCD_test.d AVR-Examples-master/LCD_test/LCD_test/Debug/LCD_test.eep AVR-Examples-master/LCD_test/LCD_test/Debug/LCD_test.elf AVR-Examples-master/LCD_test/LCD_test/Debug/LCD_test.hex AVR-Examples-master/LCD_test/LCD_test/Debug/LCD_test.lss AVR-Examples-master/LCD_test/LCD_test/Debug/LCD_test.map AVR-Examples-master/LCD_test/LCD_test/Debug/LCD_test.o AVR-Examples-master/LCD_test/LCD_test/Debug/Makefile AVR-Examples-master/LCD_test/LCD_test/Debug/Outputfile.d AVR-Examples-master/LCD_test/LCD_test/LCD_test.avrgccproj AVR-Examples-master/LCD_test/LCD_test/LCD_test.c AVR-Examples-master/LCD_test/LCD_test/lcd.h AVR-Examples-master/PWM/ AVR-Examples-master/PWM/PWM.avrsln AVR-Examples-master/PWM/PWM.avrsuo AVR-Examples-master/PWM/PWM/ AVR-Examples-master/PWM/PWM/Debug/ AVR-Examples-master/PWM/PWM/Debug/Makefile AVR-Examples-master/PWM/PWM/Debug/Outputfile.d AVR-Examples-master/PWM/PWM/Debug/PWM.d AVR-Examples-master/PWM/PWM/Debug/PWM.eep AVR-Examples-master/PWM/PWM/Debug/PWM.elf AVR-Examples-master/PWM/PWM/Debug/PWM.hex AVR-Examples-master/PWM/PWM/Debug/PWM.lss AVR-Examples-master/PWM/PWM/Debug/PWM.map AVR-Examples-master/PWM/PWM/Debug/PWM.o AVR-Examples-master/PWM/PWM/PWM.avrgccproj AVR-Examples-master/PWM/PWM/PWM.c AVR-Examples-master/avr_interrupt/ AVR-Examples-master/avr_interrupt/avr_interrupt.avrsln AVR-Examples-master/avr_interrupt/avr_interrupt.avrsuo AVR-Examples-master/avr_interrupt/avr_interrupt/ AVR-Examples-master/avr_interrupt/avr_interrupt/Debug/ AVR-Examples-master/avr_interrupt/avr_interrupt/Debug/Makefile AVR-Examples-master/avr_interrupt/avr_interrupt/Debug/Outputfile.d AVR-Examples-master/avr_interrupt/avr_interrupt/Debug/avr_interrupt.d AVR-Examples-master/avr_interrupt/avr_interrupt/Debug/avr_interrupt.eep AVR-Examples-master/avr_interrupt/avr_interrupt/Debug/avr_interrupt.elf AVR-Examples-master/avr_interrupt/avr_interrupt/Debug/avr_interrupt.hex AVR-Examples-master/avr_interrupt/avr_interrupt/Debug/avr_interrupt.lss AVR-Examples-master/avr_interrupt/avr_interrupt/Debug/avr_interrupt.map AVR-Examples-master/avr_interrupt/avr_interrupt/Debug/avr_interrupt.o AVR-Examples-master/avr_interrupt/avr_interrupt/avr_interrupt.avrgccproj AVR-Examples-master/avr_interrupt/avr_interrupt/avr_interrupt.c AVR-Examples-master/test/ AVR-Examples-master/test/test.avrsln AVR-Examples-master/test/test.avrsuo AVR-Examples-master/test1/ AVR-Examples-master/test1/test1.avrsln AVR-Examples-master/test1/test1.avrsuo AVR-Examples-master/test1/test1/ AVR-Examples-master/test1/test1/Debug/ AVR-Examples-master/test1/test1/Debug/Makefile AVR-Examples-master/test1/test1/Debug/Outputfile.d AVR-Examples-master/test1/test1/Debug/test1.d AVR-Examples-master/test1/test1/Debug/test1.eep AVR-Examples-master/test1/test1/Debug/test1.elf AVR-Examples-master/test1/test1/Debug/test1.hex AVR-Examples-master/test1/test1/Debug/test1.lss AVR-Examples-master/test1/test1/Debug/tes