本帖最后由 Jacktang 于 2019-11-7 22:01 编辑
DSP流水灯源程序
- /*
- * main.c
- *
- * Created on: 2019-9-2
- * Author: CZQ
- */
-
-
- /*
- * GPxDAT 置1高电平 置0低电平
- * GPxSET 1---高 0---无效
- * GPxCLEAR 1---低 0---无效
- * GPxTolgole 1---翻转
- */
-
-
- #include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
- #include "DSP2833x_Examples.h" // DSP2833x Examples Include File
-
- //声明函数
- void delay_loop(void);
- void Gpio_select(void);
-
- main()
- {
- InitSysCtrl();
-
- //GPIO配置
- Gpio_select();
-
- //清除所有中断,禁止CPU全局中断
- DINT;
-
- //初始化PIE控制寄存器到他们的默认状态
- InitPieCtrl();
-
- //禁止CPU中断和清除所有CPU中断标志
- IER = 0x0000;
- IFR = 0x0000;
-
- //初始化PIE中断向量表,并使其指向中断服务子程序(ISR)
- InitPieVectTable();
-
- //用户代码,LED闪烁
- GpioDataRegs.GPBDAT.all = 0x30000000; //0x30000000 00 61-1 60-1
- GpioDataRegs.GPCDAT.all = 0x00000007; //0x00000007 000 68-0 67-0 66-1 65-1 64-1
-
- for(;;)
- {
- GpioDataRegs.GPBDAT.all = 0x1000000;
- GpioDataRegs.GPCDAT.all = 0x0000001F;
- delay_loop();
- GpioDataRegs.GPBDAT.all = 0x20000000;
- GpioDataRegs.GPCDAT.all = 0x0000001F;
- delay_loop();
- GpioDataRegs.GPBDAT.all = 0x30000000;
- GpioDataRegs.GPCDAT.all = 0x0000001E;
- delay_loop();
- GpioDataRegs.GPBDAT.all = 0x30000000;
- GpioDataRegs.GPCDAT.all = 0x0000001D;
- delay_loop();
- GpioDataRegs.GPBDAT.all = 0x30000000;
- GpioDataRegs.GPCDAT.all = 0x0000000B;
- delay_loop();
- GpioDataRegs.GPBDAT.all = 0x30000000;
- GpioDataRegs.GPCDAT.all = 0x00000017;
- delay_loop();
- GpioDataRegs.GPBDAT.all = 0x30000000;
- GpioDataRegs.GPCDAT.all = 0x0000000F;
- delay_loop();
-
-
-
-
-
-
- // delay_loop();
- // GpioDataRegs.GPBTOGGLE.all = 0x30000000;
- // GpioDataRegs.GPCTOGGLE.all = 0x00000007;
- //
- // delay_loop();
- // GpioDataRegs.GPBTOGGLE.all = 0x30000000;
- // GpioDataRegs.GPCTOGGLE.all = 0x00000007;
-
- }
- }
-
- //延时子函数
- void delay_loop()
- {
- Uint32 i;
- Uint32 j;
- for(i=0;i<32;i++)
- for(j=0;j<100000;j++){}
- }
-
- //GPIO初始化函数
- void Gpio_select(void)
- {
- EALLOW;
- GpioCtrlRegs.GPAMUX1.all = 0x00000000; //ALL GPIO
- GpioCtrlRegs.GPAMUX2.all = 0x00000000;
- GpioCtrlRegs.GPBMUX1.all = 0x00000000;
- GpioCtrlRegs.GPBMUX2.all = 0x00000000;
- GpioCtrlRegs.GPCMUX1.all = 0x00000000;
- GpioCtrlRegs.GPCMUX2.all = 0x00000000;
-
- GpioCtrlRegs.GPADIR.all = 0xFFFFFFFF; //ALL outputs
- GpioCtrlRegs.GPBDIR.all = 0xFFFFFFFF;
- GpioCtrlRegs.GPCDIR.all = 0xFFFFFFFF;
-
- EDIS;
- }
DSP-流水灯.rar
(151.17 KB, 下载次数: 4)
|