ok6410的 ADC中断触发转换 实验
2012-06-11 19:50
225 查看
View Code
#include "library.h" #include "system.h" #include "sysc.h" #include "adcts.h" #include "intc.h" #define ADCTS ((volatile oADCTS_REGS*)ADCTS_BASE) void Adcts_Init(int channal, u32 freq); void __irq Adcts_Isr(void); void Delay(int time); u32 sample_data=0; int adc_flag = 0; void main(void) { int channal = 0; u32 freq = 2500000; SYSTEM_EnableVIC(); SYSTEM_EnableIRQ(); //得到g_PCLK; SYSC_GetClkInform(); Uart_Printf("此测试现在开始,可以按下ECS按键推出\n"); Adcts_Init(channal, freq); Uart_Printf("该ADC转换频率为: %d\n",freq); while(Uart_Getch() != 0x1b) { while(! adc_flag); adc_flag = 0; Uart_Printf("转换通道为:%d , 所得到的转换值为:%04d\n",channal, sample_data); Delay(3000); } } void Delay(int time) { int i; for(; time>0; time--) for(i=0; i<3000;i++); } //adc初始化; void Adcts_Init(int channal, u32 freq) { int prescale; u32 uConValue; prescale = (int)(g_PCLK/freq - 1); ADCTS->rADCCON = (1 << 14) | (prescale << 6) |(channal << 3);//配置分频率,选择通道; ADCTS->rADCCLRINT = 1; //清除ADC中断; //设置ADC的中断向量地址 Outp32(rVIC1VECTADDR + 4*(NUM_ADC - 32), (u32)Adcts_Isr); //使能中断向量; uConValue = Inp32(rVIC1INTENABLE); uConValue |= 1 << (NUM_ADC-32); Outp32(rVIC1INTENABLE,uConValue); //开始转换: ADCTS->rADCCON |= 0x1; } void __irq Adcts_Isr(void) { //清除中断标志位; ADCTS->rADCCLRINT = 1; sample_data = ADCTS->rADCDAT0 & 0X3FF; adc_flag = 1; //开始下一次转换; ADCTS->rADCCON |= 0x1; Outp32(rVIC1ADDR,0); Outp32(rVIC0ADDR,0); }
相关文章推荐
- 触摸屏代码分析——实现ADC转换完成中断
- AVR单片机模数转换的ADC实验 ATmega16
- 触摸屏代码分析——实现ADC转换完成中断
- 【DSP】TMS320F28035 ADC例程(软件触发+中断)
- STM32F10x_ADC三通道逐次转换(单次、单通道软件触发)
- STM32F10x_ADC三通道DMA连续转换(3通道、软件单次触发)
- STM32F10x_ADC三通道DMA连续转换(3通道、软件单次触发)
- LPC1788--ADC连续中断多通道转换程序学习分析
- stm8s103f3 单次ADC转换进中断问题
- STM32F10x_ADC三通道逐次转换(单次、单通道软件触发)
- cortex_m3_stm32嵌入式学习笔记(十六):ADC实验(模数转换)
- STM32F10x_ADC三通道逐次转换(单次、单通道软件触发)
- AVR单片机模数转换的ADC实验 ATmega16
- ADC 转换:神舟IV实验
- 单臂路由、扩展ACL与NAT的网络地址转换的配置实验
- SDUT 1208 C语言实验——温度转换
- Stateflow中转换多个事件触发的状态机HDL生成代码
- 【iCore4 双核心板_ARM】例程三:EXTI中断输入实验——读取ARM按键状态
- 20135202闫佳歆--week5 分析system_call中断处理过程--实验及总结
- 键盘中断扫描实验体会