DSP_代码笔记(基于TMS320X281x)

简介: 系统初始化函数:void InitSysCtrl(void){ Uint16 i; EALLOW; SysCtrlRegs.WDCR = 0x0068; SysCtrlRegs.

系统初始化函数:

void InitSysCtrl(void)
{
    Uint16 i;
    EALLOW;
    SysCtrlRegs.WDCR = 0x0068;
    SysCtrlRegs.PLLCR = 0xA;
    for(i=0;i<5000;i++){}
    SysCtrlRegs.HISPCP.all = 0x0001;
    SysCtrlRegs.LOSPCP.all = 0x0002;
    SysCtrlRegs.PCLKCR.bit.EVAENCLK = 1;
    SysCtrlRegs.PCLKCR.bit.EVBENCLK = 1;
    SysCtrlRegs.PCLKCR.bit.SCIENCLKA = 1;
    EDIS;
}

GPIO初始化函数:

void InitGpio(void)
{
    EALLOW;
    GpioMuxRegs.GPAMUX.bit.T1PWM_GPIOA6 = 1;
    GpioMuxRegs.GPAMUX.bit.T2PWM_GPIOA7 = 1;
    GpioMuxRegs.GPAMUX.bit.PWM1_GPIOA0=1;
    GpioMuxRegs.GPAMUX.bit.PWM2_GPIOA1=1;
    GpioMuxRegs.GPAMUX.bit.PWM3_GPIOA2=1;
    GpioMuxRegs.GPAMUX.bit.PWM4_GPIOA3=1;
    GpioMuxRegs.GPAMUX.bit.PWM5_GPIOA4=1;
    GpioMuxRegs.GPAMUX.bit.PWM6_GPIOA5=1;

    GpioMuxRegs.GPBMUX.bit.T3PWM_GPIOB6=1;
    GpioMuxRegs.GPBMUX.bit.T4PWM_GPIOB7=1;
    GpioMuxRegs.GPBMUX.bit.PWM7_GPIOB0=1;
    GpioMuxRegs.GPBMUX.bit.PWM8_GPIOB1=1;
    GpioMuxRegs.GPBMUX.bit.PWM9_GPIOB2=1;
    GpioMuxRegs.GPBMUX.bit.PWM10_GPIOB3=1;
    GpioMuxRegs.GPBMUX.bit.PWM11_GPIOB4=1;
    GpioMuxRegs.GPBMUX.bit.PWM12_GPIOB5=1;
    
    EDIS;

}

初始化EV函数:

void InitEv(void)
{
    EvaRegs.T1CON.bit.TMODE=2;
    EvaRegs.T1CON.bit.TPS= 1;
    EvaRegs.T1CON.bit.TENABLE=0;
    EvaRegs.T1CON.bit.TCLKS10=0;
    EvaRegs.T1CON.bit.TECMPR=1;
    EvaRegs.T2CON.bit.TMODE=2;
    EvaRegs.T2CON.bit.TPS =1;
    EvaRegs.T2CON.bit.TENABLE=0;
    EvaRegs.T2CON.bit.TCLKS10=0;
    EvaRegs.T2CON.bit.TECMPR=1;
    EvaRegs.GPTCONA.bit.TCOMPOE=1;

    EvaRegs.GPTCONA.bit.T1PIN=1;
    EvaRegs.GPTCONA.bit.T2PIN=2;
    EvaRegs.T1PR=0x927B;
    EvaRegs.T1CMPR=0x3A98;
    EvaRegs.T1CNT=0;

    EvaRegs.T2PR=0x927B;
    EvaRegs.T2CMPR=0x57E4;
    EvaRegs.T2CNT=0;

    EvaRegs.COMCONA.bit.CENABLE=1;
    EvaRegs.COMCONA.bit.FCOMPOE=1;
    EvaRegs.COMCONA.bit.CLD=2;

    EvaRegs.DBTCONA.bit.DBT=10;
    EvaRegs.DBTCONA.bit.EDBT1=1;
    EvaRegs.DBTCONA.bit.EDBT2=1;
    EvaRegs.DBTCONA.bit.EDBT3=1;
    EvaRegs.DBTCONA.bit.DBTPS=4;

    EvaRegs.ACTR.all=0x0999;

    EvaRegs.CMPR1=0x3A98;
    EvaRegs.CMPR2=0x3A98;
    EvaRegs.CMPR3=0x3A98;

    EvbRegs.T3CON.bit.TMODE=1;
    EvbRegs.T3CON.bit.TPS=1;
    EvbRegs.T3CON.bit.TENABLE=0;
    EvbRegs.T3CON.bit.TCLKS10=0;
    EvbRegs.T3CON.bit.TECMPR=1;

    EvbRegs.T4CON.bit.TMODE=1;
    EvbRegs.T4CON.bit.TPS=1;
    EvbRegs.T4CON.bit.TENABLE=0;
    EvbRegs.T4CON.bit.TCLKS10=0;
    EvbRegs.T4CON.bit.TECMPR=1;

    EvbRegs.GPTCONB.bit.TCOMPOE=1;
    EvbRegs.GPTCONB.bit.T3PIN=1;
    EvbRegs.GPTCONB.bit.T4PIN=2;

    EvbRegs.T3PR=0x493E;
    EvbRegs.T3CMPR=0x1D4C;
    EvbRegs.T3CNT=0;

    EvbRegs.T4PR=0x493E;
    EvbRegs.T4CMPR=0x2BF2;
    EvbRegs.T4CNT=0;

    EvbRegs.COMCONB.bit.CENABLE=1;
    EvbRegs.COMCONB.bit.FCOMPOE=1;
    EvbRegs.COMCONB.bit.CLD=2;
    
    EvbRegs.DBTCONB.bit.DBT=10;
    EvbRegs.DBTCONB.bit.EDBT1=1;
    EvbRegs.DBTCONB.bit.EDBT2=1;
    EvbRegs.DBTCONB.bit.EDBT3=1;
    EvbRegs.DBTCONB.bit.DBTPS=4;

    EvbRegs.ACTRB.all=0x0999;

    EvbRegs.CMPR4=0x1D4C;
    EvbRegs.CMPR5=0x1D4C;
    EvbRegs.CMPR6=0x1D4C;

}

主函数:

void main(void)
{
    InitSysCtrl();
    DINT;
    IER=0x0000;
    IFR=0x0000;
    InitPieCtrl();
    InitPieVectTable();
    InitGpio();
    InitEv();
    EvaRegs.T1CON.bit.TENABLE=1;
    EvaRegs.T2CON.bit.TENABLE=1;
    EvbRegs.T3CON.bit.TENABLE=1;
    EvbRegs.T4CON.bit.TENABLE=1;
}

Debug:
"DSP28_Gpio.c", line 51: warning: last line of file ends without a newline
文件的最后一行没有换行符结束

目录
相关文章
|
4月前
stm32f407探索者开发板(十九)——外部中断实验-EXIT
stm32f407探索者开发板(十九)——外部中断实验-EXIT
311 0
|
1月前
|
传感器 芯片 索引
|
4月前
|
监控
stm32f407探索者开发板(十八)——串口通信实验讲解(USART_RX_STA流程图详解)
stm32f407探索者开发板(十八)——串口通信实验讲解(USART_RX_STA流程图详解)
313 0
|
4月前
|
前端开发 安全
stm32f407探索者开发板(十一)——SystemInit时钟系统初始化剖析
stm32f407探索者开发板(十一)——SystemInit时钟系统初始化剖析
160 0
|
算法 搜索推荐 芯片
TM4C123库函数学习(1)--- 点亮LED+TM4C123的ROM函数简介+keil开发环境搭建
TM4C123库函数学习(1)--- 点亮LED+TM4C123的ROM函数简介+keil开发环境搭建
236 0
|
编解码 物联网
国产MCU-CW32F030开发学习-ST7735 LCD模块
国产MCU-CW32F030开发学习-ST7735 LCD模块
131 0
国产MCU-CW32F030开发学习-ST7735 LCD模块
|
芯片
野火F1开发板STM32案例 0.96 oled综合库使用
野火F1开发板STM32案例 0.96 oled综合库使用
211 0
|
存储 编解码 芯片
ZYNQ裸板:LHB155304-RT篇
1553总线是一种指令/响应式串行总线标准,除了作为美军标在国外广泛应用于军用飞机坦克、船舶、卫星、导弹等领域,在国内已得到了广泛的应用。抗干扰能力强实时性好,且拥有着双冗余备份设计,数据传输极为可靠。就我个人认知来看,常见的实现形式一种是通过专用的接口协议芯片,相对比较简单集成度高;另一种是IP核,非常考验逻辑和软件设计的功底。此次工程选用了前者,LHB15530接口芯片,在不改变原有传输方式的前提下,突破了原有的1Mb/s的传输速率,可达4Mb/s,也能满足绝大部分应用场景。
470 0
ZYNQ裸板:LHB155304-RT篇
|
Linux 开发工具 git
嵌入式linux/鸿蒙开发板(IMX6ULL)开发(三十)LED模板驱动程序的改造:总线设备驱动模型
嵌入式linux/鸿蒙开发板(IMX6ULL)开发(三十)LED模板驱动程序的改造:总线设备驱动模型
229 1
嵌入式linux/鸿蒙开发板(IMX6ULL)开发(三十)LED模板驱动程序的改造:总线设备驱动模型