#include "main.h"
#define VREF 5 /* Voltage Reference: max voltage VDDP+0.1, minimum voltage 4.5 */
static unsigned short ADCData = 0;
static unsigned char ADCchannel = 0;
// 1ms loop delay
/*
void loop_delay_ms(unsigned int cnt)
{
unsigned int i, j;
for(i=0; i<cnt; i++)
{
for(j=0; j<4000; j++);
}
}
*/
void main(void)
{
/* A/D Converter */
while (1)
{
/* Init ADC */
ADC_CON = 0xB0; /* ADM autoscan continuous conversion and start bit = 1 */
ADC_CON_ADBSY = 1; /* Busy flag */
while (ADC_CON_ADBSY); /* Wait for conversion */
/* Output 0-1023 ADDAT value without using floating-point */
/*
printf ("ADDAT Value %4u = %01u.%04u Volts\r",
(unsigned) ADC_DAT,
(unsigned) (ADC_DAT * VREF)>> 10, // Output Integer Portion
(unsigned) ((ADC_DAT * VREF * 10000UL) >> 10UL) % 10000); // Output Decimal Portion
*/
ADCData = (unsigned) ADC_DAT;
ADCchannel = ADCData >> 12;
// ADCchannel = (unsigned) ADC_CON_ADCRQ;
// ADCData2 = (unsigned) ADC_DAT2;
}
}
/*
// main
void main(void)
{
// set direction register Port P1L.0 as output
DP1L = 0x10;
while(1)
{
P1L_P4 = ~P1L_P4;
loop_delay_ms(100);
}
}
*/
ADC.zip_ xc164_XC164
版权申诉
2 浏览量
2022-09-24
01:43:38
上传
评论
收藏 87KB ZIP 举报
四散
- 粉丝: 52
- 资源: 1万+
最新资源
- 详解protobuf-c之在C语言中如何使用repeated生成数组和字符串(包含配置pb-callback-t)
- Python 程序语言设计模式思路-并发模式:消费者模式:协调生产者和消费者之间的数据交换
- pythonA*算法(A-star algorithm),寻路算法
- guitest.zip
- udp_echo.v
- udp_echo_server.v
- python双向广度优先搜索算法(Bidirectional Breadth-First Search, BBFS),寻路算法
- python迭代加深算法(Iterative Deepening Depth-First Search, IDDFS),寻路算法
- 京东商品链接采集助手 2024版
- 基于Java的ApplicationPower快速项目生成脚手架设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈