中级会员
- 积分
- 219
- 威望
- 155
- 贡献
- 34
- 兑换币
- 0
- 注册时间
- 2011-11-22
- 在线时间
- 15 小时
|
准备用xs128的AD模块采集电位器与电阻间的电压,再通过串口通信在串口调试助手上显示,调试了好多次,始终没有显示。这个任务完成了就复习了,大虾们帮帮忙了~看哪里出错了- #include <hidef.h> /* common defines and macros */
- #include "derivative.h" /* derivative-specific definitions */
- unsigned char a;
- void SCI_init(){
- SCI0BDH=0x00;
- SCI0BDL=0x34;
- SCI0CR1=0x00;
- SCI0CR2=0x0c;
- }
- void ADinit(){
- // ATD0CTL0=0b01000010;
- ATD0CTL1=0b00000000;//8位精度
- ATD0CTL2=0b01000000;//禁止外部触发,标志位快速清零,中断禁止
- ATD0CTL3=0b10001000;//右对齐无符号.转换序列长度为1
- ATD0CTL4=0b00000001;//4AD采样周期;ATDClock=[BusClock*0.5]/[PRS+1] ,PRS=1,ATDClock=2Mhz ;
- ATD0DIEN=0b00000000;//禁止数字输入
- ATD0CTL5=0b00100000;//特殊通道禁止,单通道采样,扫描模式连续采样,ch AN0
- }
- void main(void) {
- /* put your own code here */
- SCI_init();
- ADinit();
- EnableInterrupts;
- for(;;) {
- while(!ATD0STAT0_SCF);
- ATD0STAT0_SCF=1;
- while(!SCI0SR1_TDRE);
- SCI0DRL=ATD0DR0L;
- _FEED_COP(); /* feeds the dog */
- } /* loop forever */
- /* please make sure that you never leave main */
- }
复制代码 |
|