This post was last edited by Jacktang on 2019-11-7 22:01
DSP water light source program
- /*
- * main.c
- *
- *Created on: 2019-9-2
- * Author: CZQ
- */
- /*
- * GPxDAT Set to 1 high level Set to 0 low level
- * GPxSET 1---high 0---invalid
- * GPxCLEAR 1---low 0---invalid
- * GPxTolgole 1 --- Flip
- */
- #include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
- #include "DSP2833x_Examples.h" // DSP2833x Examples Include File
- //Declare function
- void delay_loop(void);
- void Gpio_select(void);
- main()
- {
- InitSysCtrl();
- //GPIO configuration
- Gpio_select();
- // Clear all interrupts and disable CPU global interrupts
- DINT;
- // Initialize the PIE control registers to their default states
- InitPieCtrl();
- //Disable CPU interrupts and clear all CPU interrupt flags
- IER = 0x0000;
- IFR = 0x0000;
- //Initialize the PIE interrupt vector table and point it to the interrupt service routine (ISR)
- InitPieVectTable();
- //User code, LED flashes
- GpioDataRegs.GPBDAT.all = 0x30000000;//0x30000000 0061-160-1
- GpioDataRegs.GPCDAT.all = 0x00000007;//0x00000007 000 68-067-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;
- }
- }
- //Delay sub-function
- void delay_loop()
- {
- Uint32 i;
- Uint32 j;
- for(i=0;i<32;i++)
- for(j=0;j<100000;j++){}
- }
- //GPIO initialization function
- 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, downloads: 4)
|