DSP_代码笔记(基于TMS320X281x)

系统初始化函数:

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

凌川江雪

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值