Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
||
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[52.14.33.175] |
|
Сообщ.
#1
,
|
|
|
Требуется считать значение с нулевого канала АЦП. Больше по заданию ни слова.
Какой микроконтроллер выбрать и почему? Может кто поможет в CodeVision сделать. |
Сообщ.
#2
,
|
|
|
#include <mega32.h> #include <delay.h> #include <stdio.h> #include <stdlib.h> #define ADC_VREF_TYPE 0xC0 unsigned int readAdc(unsigned char adc_input) // Read the AD conversion result { ADMUX = adc_input | (ADC_VREF_TYPE & 0xff); delay_us(10); // Delay needed for the stabilization of the ADC input voltage ADCSRA |= 0x40; // Start the AD conversion while((ADCSRA & 0x10) == 0); // Wait for the AD conversion to complete ADCSRA |= 0x10; return(ADCW); } void main() { // инициализация портов // Port A PORTA=0x00; // без поддтяжки к питанию DDRA=0x00; // весь порт на вход // Global enable interrupts #asm("sei"); printf("\r\n\t\t\t readAdc(0) = %i", readAdc(0)); while(1); } |