这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » 44b0调试的问题,ad转换的,附加元程序

共2条 1/1 1 跳转至

44b0调试的问题,ad转换的,附加元程序

菜鸟
2004-10-29 21:12:08     打赏

大虾们,我的ad程序为什么在armulator里面正常,但是在44b0的板子上就不行?程序中有led点亮的一步,但是班子上面没有,而且串口发送的文字,用超级终端接收不到啊,这是为什么?

#include "44b.h" #include "44blib.h" #include "def.h" #include "option.h"

int ReadAdc(int ch);

void __irq ADC_Int(void);

void Test_Adc(void) { int a0=0,a1=0,a2=0,a3=0,a4=0,a5=0,a6=0,a7=0;

while(1) { a0=ReadAdc(0); /* 进行0通道ADC */ a1=ReadAdc(1); a2=ReadAdc(2); a3=ReadAdc(3); a4=ReadAdc(4); a5=ReadAdc(5); a6=ReadAdc(6); a7=ReadAdc(7); Uart_Printf("0:%04d 1:%04d 2:%04d 3:%04d 4:%04d 5:%04d 6:%04d 7:%04d",a0,a1,a2,a3,a4,a5,a6,a7); Delay(50000); //5s } } /************************************************ * Start and read one channel ADC * ************************************************/ int ReadAdc(int ch) { int i; static int prevCh=-1; /* 静态变量,第一次进入该程序是,ADC通道一定不为-1,因此必须等待信号建立 */ /* 以后进入该程序时,该语句赋值被忽略,preCh的值为上一次转换的通道号 */ if(prevCh!=ch) /* 若当前的转换通道不是上一次转换的通道,等待信号建立 */ { rADCCON=0x0|(ch<<2); //setup channel. for(i=0;i<150;i++); //min. 15us } rADCCON=0x1|(ch<<2); //Start A/D conversion while(rADCCON &0x1); //To avoid The first FLAG error case. //(The START bit is cleared in one ADC clock.) while(!(rADCCON & 0x40)); for(i=0;i<rADCPSR;i++); //To avoid The second FLAG error case prevCh=ch; /* 将此时的通道号,作为相对下一次转换的上一次转换通道号 */ return rADCDAT; /* 返回ADC结果 */ } /************************************************ * Start and read one channel ADC code end * ************************************************/ /************************************************ * ADC initiation * ************************************************/ void ADC_Init(U32 con_rate,U8 start) { //rINTCON=0x5; //rINTMOD=0x0; //All=IRQ mode pISR_ADC=(unsigned)ADC_Int; rINTMSK = rINTMSK & (~(BIT_GLOBAL|BIT_ADC)); //start INT,使能中断

if( start ==1) /* 若启动ADC,则进行寄存器配置 */ { Uart_Printf("The ADC_IN are adjusted to the following values."); rADCPSR = MCLK/(2*con_rate*16)-1; /* 根据主频、转换速率计算预定标值 */ Uart_Printf("ADC conv. freq.=%d(Hz)",(int)(MCLK/(2.*(rADCPSR+1.))/16.) ); rADCCON=0x00; //Enable ADC Delay(100); //delay for 10ms for ADC reference voltage stabilization. } else /* 若不启动ADC则禁止 */ rADCCON=0x20; //Disable ADC } /************************************************ * ADC initiation code end * ************************************************/ /************************************************ * ADC conversion interrupt * ************************************************/ void __irq ADC_Int(void) { rI_ISPC=BIT_ADC; //clear pending bit Uart_Printf("44B0X ADC interrupt test OK !"); } /************************************************ * ADC conversion interrupt code end * ************************************************/

void Main(void) { rSYSCFG=CACHECFG; // Using 8KB Cache//

Port_Init(); Uart_Init(0,57600); Delay(10); Uart_Select(0); //Select UART0 Led_Display(0x00); Delay(1000); //Led_Display(0x02);

Uart_Printf("FS44B0X"); // Uart_Printf(""); // Uart_Printf("FS44B0X ADC interrupt test!");

ADC_Init(10000,1); /* 设定转换速率,并启动 */ Test_Adc(); /* 测试及读取ADC结果 */ /* 在ADC_Init函数中,用户只需设置号转换速率,即可启动ADC,无需配置具体的寄存器,这由程序完成 */ /* 初始化完成后,用户可以直接使用ReadADC函数来进行某一通道的ADC,也可以使用类似于Test_Adc函数 */ /* 的形式,建立自己的调用函数 */

}




关键词: 调试     问题     转换     加元     程序     ReadAdc    

菜鸟
2004-11-01 17:09:00     打赏
2楼
hummingbir,ads不是有armulator和remoteA吗?前面的那个是软件仿真吧,然后仿真的时候main里面的函数都能执行啊,发光管也亮了,但是下载之后都不行,就是这样,

共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]