Based-on-LM3S1138-driver.rar

  • jy_recsys
    了解作者
  • Others
    开发工具
  • 9KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 35
    下载次数
  • 2012-08-04 07:39
    上传日期
基于M3内核的TIMCULM3S1138的底层硬件驱动代码和一些算法程序。包括数字电位器AD5254,DAC7821,LCD1602,FIR数字滤波和FFT变换等。
Based-on-LM3S1138-driver.rar
  • LCD1602.c
    3KB
  • DAC7512.c
    1.4KB
  • DAC7821.c
    1.1KB
  • PWM.c
    1.3KB
  • AD5254.c
    3KB
  • DDS.c
    4.7KB
  • frequency.c
    7.8KB
  • myadc.c
    2.5KB
  • skewing.c
    3.4KB
  • spi.c
    1.4KB
内容介绍
#include <hw_types.h> #include <hw_memmap.h> #include <hw_ints.h> #include <hw_sysctl.h> #include <hw_gpio.h> #include <hw_timer.h> #include <interrupt.h> #include <sysctl.h> #include <gpio.h> #include <timer.h> #include "LM3S1138_PinMap.H" #include "frequency.h" #define TIME1ABUFFERSIZE 256 //采集时间数据的个数,应该与TIME0ABUFFERSIZE相等 #define TIME0ABUFFERSIZE 256 //采集时间数据的个数,应该与TIME1ABUFFERSIZE相等 #define SYSTEMFREQUENCY 50000000 //系统时钟的频率 unsigned long Time1ABuffer[TIME1ABUFFERSIZE]; //存储正边沿捕获的时间数据 volatile unsigned char Time1AEndFlag=0; //标志数据采集结束 unsigned long Time0ABuffer[TIME0ABUFFERSIZE]; //存储正边沿捕获的时间数据 volatile unsigned char Time0AEndFlag=0; //标志数据采集结束 static unsigned int i1=0; //用于数据计数 static unsigned int i0=0; //用于数据计数 /*------------------------------------------------------------------------------------- fuction:time1A触发计时初始化 notice:使用time1A触发计时功能时,调用TimerEnable(TIMER1_BASE,TIMER_A),等待Time1AEndFlag为1, 然后赋0给TimeEndFlag,处理TimeBuffer[],例如: TimerEnable(TIMER1_BASE,TIMER_A); while(Time1AEndFlag==0); Time1AEndFlag=0; ------------------------------------------------------------------------------------*/ //CCP2是管脚PB1 //CCP0是管脚PB0 void timer1Init(void) { SysCtlPeripheralEnable(CCP2_PERIPH); /* 使能CCP2所在的GPIO端口 */ GPIOPinTypeTimer(CCP2_PORT,CCP2_PIN); /* 配置CCP2管脚为边沿事件输入 */ SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); /* 使能定时器模块 */ TimerConfigure( TIMER1_BASE,TIMER_CFG_16_BIT_PAIR|TIMER_CFG_A_CAP_TIME); /* 配置TimerA为16位事件计数器 */ TimerControlStall(TIMER1_BASE,TIMER_A,true); /* 允许在调试时暂停定时器计数 */ TimerControlEvent(TIMER1_BASE,TIMER_A,TIMER_EVENT_POS_EDGE); /* 控制TimerA捕获CCP正边沿 */ TimerLoadSet(TIMER1_BASE,TIMER_A,0xFFFF); /* 设置计数器初值 */ TimerIntEnable(TIMER1_BASE,TIMER_CAPA_EVENT); /* 使能TimerA事件捕获中断 */ IntEnable(INT_TIMER1A); /* 使能TimerA中断 */ IntMasterEnable(); /* 使能处理器中断 */ //TimerEnable(TIMER1_BASE,TIMER_A); /* 使能TimerA计数 */ } /*------------------------------------------------------------------------------------- fuction:time0A触发计时初始化 notice:使用time0A触发计时功能时,调用TimerEnable(TIMER0_BASE,TIMER_A),等待TimeEndFlag为1, 然后赋0给TimeEndFlag,处理TimeBuffer[],例如: TimerEnable(TIMER0_BASE,TIMER_A); while(Time0AEndFlag==0); Time0AEndFlag=0; ------------------------------------------------------------------------------------*/ //CCP2是管脚PB1 //CCP0是管脚PB0 void timer0Init(void) { SysCtlPeripheralEnable(CCP0_PERIPH); /* 使能CCP2所在的GPIO端口 */ GPIOPinTypeTimer(CCP0_PORT,CCP0_PIN); /* 配置CCP2管脚为边沿事件输入 */ SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); /* 使能定时器模块 */ TimerConfigure( TIMER0_BASE,TIMER_CFG_16_BIT_PAIR|TIMER_CFG_A_CAP_TIME); /* 配置TimerA为16位事件计数器 */ TimerControlStall(TIMER0_BASE,TIMER_A,true); /* 允许在调试时暂停定时器计数 */ TimerControlEvent(TIMER0_BASE,TIMER_A,TIMER_EVENT_POS_EDGE); /* 控制TimerA捕获CCP正边沿 */ TimerLoadSet(TIMER0_BASE,TIMER_A,0xFFFF); /* 设置计数器初值 */ TimerIntEnable(TIMER0_BASE,TIMER_CAPA_EVENT); /* 使能TimerA事件捕获中断 */ IntEnable(INT_TIMER0A); /* 使能TimerA中断 */ IntMasterEnable(); /* 使能处理器中断 */ //TimerEnable(TIMER0_BASE,TIMER_A); /* 使能TimerA计数 */ } /*---------------------------------------------------------------------------------------- function:用Timer1A采集的数据计算频率 input: fraction:分频大小,时钟的分频数在1~255之间,因此也在1~255 output: 返回频率,单位为Hz ----------------------------------------------------------------------------------------*/ float FrequencyGetFromTimer1(unsigned char fraction) { float temp=0; float temp1=0; unsigned int i; temp1=((float)SYSTEMFREQUENCY/fraction)*(float)(TIME1ABUFFERSIZE-1); for(i=0;i<(TIME1ABUFFERSIZE-1);i++) { if(Time1ABuffer[i+1]>Time1ABuffer[i]) { temp+=Time1ABuffer[i]+0xffff-Time1ABuffer[i+1]; } else temp+=Time1ABuffer[i]-Time1ABuffer[i+1]; } temp=temp1/temp; return((temp+1)); } /*---------------------------------------------------------------------------------------- function:用Timer0A采集的数据计算频率 input: fraction:分频大小,时钟的分频数在1~255之间,因此也在1~255 output: 返回频率,单位为Hz ----------------------------------------------------------------------------------------*/ float FrequencyGetFromTimer0(unsigned char fraction) { float temp=0; float temp1=0; unsigned int i; temp1=((float)SYSTEMFREQUENCY/fraction)*(float)(TIME0ABUFFERSIZE-1); for(i=0;i<(TIME0ABUFFERSIZE-1);i++) { if(Time0ABuffer[i+1]>Time0ABuffer[i]) { temp+=Time0ABuffer[i]+0xffff-Time0ABuffer[i+1]; } else temp+=Time0ABuffer[i]-Time0ABuffer[i+1]; } temp=temp1/temp; return((temp+1)); } /*------------------------------------------------------------------------------------------------- function:求两频率相同的方波的相位差 input: buffer0:波形0沿触发采集到的一系列时间数据 buffer1:波形1沿触发采集到的一系列时间数据 fraction:分频大小,时钟的分频数在1~255之间,因此也在1~255 output: 返回相位差的度数 -------------------------------------------------------------------------------------------------*/ /* float SkewingGet(unsigned char fraction) { float temp=0; float frequency=0; unsigned int i; if((Time1ABuffer[0]>Time0ABuffer[0])&&(Time1ABuffer[0]-Time0ABuffer[0])<0x8888) { for(i=0;i<TIME1ABUFFERSIZE;i++) { if(Time0ABuffer[i]>Time1ABuffer[i]) { temp+=Time1ABuffer[i]+0xffff-Time0ABuffer[i]; } else temp+=Time1ABuffer[i]-Time0ABuffer[i]; } } else { for(i=0;i<TIME1ABUFFERSIZE;i++) { if(Time1ABuffer[i]>Time0ABuffer[i]) { temp+=Time0ABuffer[i]+0xffff-Time1ABuffer[i]; } else temp+=Time0ABuffer[i]-Time1ABuffer[i]; } } frequency=(FrequencyGet(0,fraction)+FrequencyGet(1,fraction))/2; temp=((float)SYSTEMFREQUENCY/(float)fraction)/(float)temp*(float)TIME1ABUFFERSIZE; temp=360*frequency/temp; return(temp); } */ /* Timer1A的中断服务函数 */ void Timer1A_Frequency_ISR(void) { TimerIntClear( TIMER1_BASE,TIMER_CAPA_EVENT); /* 清除TimerA事件捕获中断 */ if(i1<TIME1ABUFFERSIZE) { Time1ABuffer[i1]= TimerValueGet(TIMER1_BASE,TIMER_A); /* 读取捕获值 */ i1++; } else { TimerDisable (TIMER1_BASE,TIMER_A); //禁止TimerA计数 i1=0; Time1AEndFlag=1; } } /* Timer0A的中断服务函数 */ void Timer0A_Frequency_ISR(void) { TimerIntClear( TIMER0_BASE,TIMER_CAPA_EVENT); /* 清除Timer0A事件捕获中断 */ if(i0<TIME0ABUFFERSIZE) { Time0ABuffer[i0]= TimerValueGet(TIMER0_BASE,TIMER_A); /* 读取捕获值 */ i0++; } else { TimerDisable (TIMER0_BASE,TIMER_A); //禁止Timer0A计数 i0=0; Time0AEndFlag=1; } }
评论
    相关推荐
    • AD9361_cn.rar
      AD9361的参考资料,是中文的,便于理解和阅读,加快设计进程。
    • Exp-FIR-AD.rar
      这是在C5000系列DSP上实现FIR滤波器的源码,是用汇编语言编写的,可直接在CCS上运行
    • FIR.rar
      本程序是由C语言编译的,用来开发dsp的FIR滤波器的程序
    • Exp-FIR-AD.rar
      c语言编写的fir滤波器在dsp上的实现
    • C5402fir.rar
      C5402DSP汇编编写的FIR滤波器的实现程序,可对AD采集的数据进行FIR滤波,程序调试通过。
    • AD6649.pdf.zip
      The AD6649 is a mixed -signal intermediate frequency (IF) receiver consisting of d ual 14- bit, 250 MSPS ADCs and a wideband digital downconverter (DDC).
    • C5402 DSP FIR IIR滤波器仿真文件
      DSP C5402 FIR IIR 低通滤波器CCS仿真文件
    • AD胡.zip
      用FPGA开发板实现FIR滤波器,C2000 DSP教学实验箱
    • FIR低通滤波器 ccs运行环境
      FIR低通滤波器,主程序是c语言,汇编是辅助。完全的程序,可完全运行,注意是ccs软件!
    • ad9361_driver.rar
      ad9361的驱动源码,基于c语言ad9361_synth_lut.h ad9361_gain_tables.h ad9361_filter_taps.h ad9361_device.h ad9361_client.h ad9361_device.cpp