|
这是一个要交的作业,之前是英文, 我翻译过来了,不过我还是不确定所以把中英文都放上来。 并且附加了大概的程序结构。 求大神帮我完成下。感激不尽!!!
1.编写一个程序来测量的模拟电压PC0(ADC0), 使用带有参考电压的ADC外部设备选择模拟电源。使用一个电压源并用ADC0的直流电压记录20个输入电压在0到5伏的测量值。 使用万用表或者示波器来测量实际输入电压V(input). 提供一个表格,表格里包括输入电压的测量值,包括ADC的预期输入电压V(input),记录ADC的值(一个10进制的无符号整数)和记录的ADC电压值得呈现。[backcolor=rgba(255, 255, 255, 0.8)]
1.Write a program to measure the analog voltage on PC0(ADC0) pin using the ADC peripheral
with VREF selected to be AVCC. Using a voltage source apply a DC voltage to ADC0 record
measurements at 20 dierent input voltages between 0 and 5 volts. Use a multimeter or O-
scope to measure the actual input voltage, Vin. Provide a table that includes measured voltage
Vin, expected ADC value for Vin, recorded ADC value (a 10-bit unsigned integer) and voltage
the recorded ADC value represents.
从这开始是程序结构, 希望大家帮我填完。
/*
Example program
- basic super-loop structure.
- additional timing control, allowing you to call functions once per loop or at a
perscribed rate (e.g. 1kHz, 100Hz, 10Hz 1Hz).
- Makes use of timer0 to generate an ISR every msec.
*/
// Includes
#include <stdint.h>
#include "myRegDefs.h"
#include "myTimer.h"
#define DEBUG_OUTPUT_MESSAGE_MAX_LENGTH 80
// global variables
uint8_t message[DEBUG_OUTPUT_MESSAGE_MAX_LENGTH];
/***********************************************************************************
* Entry point for the program 从这开始就可以填写了。
***********************************************************************************/
int main() {
uint32_t loopCount = 0;
// must call library init function for register setup related to Arduino library support
init();
// Initialize the timer0 peripheral to generate our timebase used for control flow
InitTimer0Module();
// Write a message to the serial port once after we power up
Serial.begin(9600);
sprintf((char *)message, "Start of program\n");
Serial.write((char *)message);
// Endless loop
while(1)
{
// List of stuff that run everytime around the loop
loopCount++;
// Functions that run once per msec
if (run1kHzFunctions())
{
}
// Functions that run once per 10 msec
if (run100HzFunctions())
{
}
// Functions that run once per 100 msec
if (run10HzFunctions())
{
}
// Functions that run once per second
if (run1HzFunctions())
{
// run-time debug message
sprintf((char *)message, "LoopCount = %u\n", loopCount);
Serial.write((char *)message);
loopCount = 0;
}
} // while(1) loop
return 0;
}
|
|