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
文件的最后一行没有换行符结束

目录
相关文章
STM32串口编程基础知识讲解
STM32串口编程基础知识讲解
112 0
|
5月前
stm32f407探索者开发板(十九)——外部中断实验-EXIT
stm32f407探索者开发板(十九)——外部中断实验-EXIT
371 0
|
5月前
stm32f407探索者开发板(十六)——串行通信原理讲解-UART
stm32f407探索者开发板(十六)——串行通信原理讲解-UART
324 0
|
存储 芯片
STM32速成笔记(十一)—EEPROM(AT24C02)
本文详细介绍了什么是AT24C02,介绍了它的引脚,读/写时序,给出了应用实例和详细的程序设计。最后,简单介绍了AT24C02的应用场景。
593 0
STM32速成笔记(十一)—EEPROM(AT24C02)
|
7月前
|
存储 编解码 算法
基于STM32的开源简易示波器项目
基于STM32的开源简易示波器项目
171 0
|
传感器 编解码 API
大彩串口屏在RTOS编程中应该注意的要点
大彩串口屏在RTOS编程中应该注意的要点
233 0
大彩串口屏在RTOS编程中应该注意的要点
|
算法 搜索推荐 芯片
TM4C123库函数学习(1)--- 点亮LED+TM4C123的ROM函数简介+keil开发环境搭建
TM4C123库函数学习(1)--- 点亮LED+TM4C123的ROM函数简介+keil开发环境搭建
252 0
|
存储 消息中间件 安全
瑞萨RA2E1使用实时操作系统RTOS
瑞萨RA2E1使用实时操作系统RTOS
417 0
瑞萨RA2E1使用实时操作系统RTOS
STM32的串口固件库编程归纳
STM32的串口固件库编程归纳
97 0
|
API
stm32RTOS创建任务
stm32RTOS创建任务
157 0