1829 views|0 replies

3836

Posts

19

Resources
The OP
 

DSP realizes the source code of the water light style [Copy link]

The source program is as follows: /* * main.c * * Created on: August 18, 2018* Author: LYJCD */ //################################################################################### // // FILE: Example1_2833xGpioLED.c // // TITLE: Experiment of lighting up the light-emitting diode with DSP// // // According to the need of debugging in RAM, this project is configured as "boot to SARAM". The 2833x boot mode // table is shown below. Another commonly used mode is the "boot to Flash" mode. When the program is debugged in RAM, // you can burn the code into Flash and use the "boot to Flash" boot mode. // // $Boot_Table: // // GPIO87 GPIO86 GPIO85 GPIO84 // XA15 // 1 0 1 0 McBSP-A boot // 1 0 0 1 Jump to XINTF x16 // 1 0 0 0 Jump to XINTF x32 // 0 1 1 1 Jump to OTP // 0 1 1 0 Parallel GPIO I/O boot // 0 1 0 1 Parallel XINTF boot // 0 1 0 0 Jump to SARAM <- "boot to SARAM" // 0 0 1 1 Branch to check boot mode // 0 0 1 0 Boot to flash, bypass ADC cal // 0 0 0 1 Boot to SARAM, bypass ADC cal // 0 0 0 0 Boot to SCI-A, bypass ADC cal // Boot_Table_End$ // // Function description: // // After the program is compiled and downloaded successfully, the LED light group will keep flashing when the program is running// //###################################################################################################### // Release date: 2013.11.11 //################################################################################################################ #include "DSP2833x_Device.h" // DSP2833x header file #include "DSP2833x_Examples.h" // DSP2833x example related header file #define D8 GpioCtrlRegs.GPBDAT.bit.GPIO60 //D8 represents GPIO60 #define D9 GpioCtrlRegs.GPBDAT.bit.GPIO61 //D9 represents GPIO61 #define D10 GpioCtrlRegs.GPCDAT.bit.GPIO64 //D10 represents GPIO64 #define D11 GpioCtrlRegs.GPCDAT.bit.GPIO65 //D11 represents GPIO65 #define D12 GpioCtrlRegs.GPCDAT.bit.GPIO66 //D12 represents GPIO66 #define D13 GpioCtrlRegs.GPCBAT.bit.GPIO67 //D13 represents GPIO67 #define D14 GpioCtrlRegs.GPCDAT.bit.GPIO68 //D14 represents GPIO68 // Before use, declare the related functions in this file; void delay_loop(void); void Gpio_select(void); void main(void) { // Step 1. Initialize system control: // Set up PLL, WatchDog, enable peripheral clocks // The following function can be found in the DSP2833x_SysCtrl.c file.. InitSysCtrl(); // Step 2. Initialize the general input and output multiplexer GPIO: // This function is defined in the DSP2833x_Gpio.c source file // This function initializes the GPIO control registers to their default state // InitGpio(); // This example does not use this sub-function // This example uses the following GPIO configuration Gpio_select(); // Step 3. Clear all interrupts Initialize the interrupt vector table: // Disable CPU global interrupt DINT; // Initialize the PIE control registers to their default state.// The default state is to disable PIE interrupts and clear all PIE interrupt flags // This function is placed in the DSP2833x_PieCtrl.c source file 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) // These interrupt service routines are placed in the DSP280x_DefaultIsr.c source file // This function is placed in the DSP2833x_PieVect.c source file. InitPieVectTable(); // Step 4. Initialize on-chip peripherals: // This function can be found in the DSP280x_CpuTimers.c source file // InitCpuTimers(); // This example only initializes the Cpu timer // Step 5. User-specific code for(;;) { //*******Let the lights light up one by one from D8 to D14******// GpioDataRegs.GPBDAT.bit.GPIO60=0; delay_loop(); GpioDataRegs.GPBSET.bit.GPIO60=1; delay_loop(); GpioDataRegs.GPBDAT.bit.GPIO61=0; delay_loop(); ; delay_loop(); GpioDataRegs.GPCSET.bit.GPIO64=1; delay_loop(); GpioDataRegs.GPCDAT.bit.GPIO65=0; delay_loop(); GpioDataRegs.GPCSET.bit.GPIO65=1; delay_loop(); GPIO66=1; delay_loop(); GpioDataRegs.GPCDAT.bit.GPIO67=0; delay_loop(); GpioDataRegs.GPCSET.bit.GPIO67=1; delay_loop(); GpioDataRegs.GPCDAT.bit.GPIO68=0; delay_loop(); ioDataRegs.GPCDAT.bit.GPIO68=0; delay_loop(); GpioDataRegs.GPCSET.bit.GPIO68=1; delay_loop(); GpioDataRegs.GPCDAT.bit.GPIO67=0; delay_loop(); loop(); GpioDataRegs.GPCSET.bit.GPIO66=1; delay_loop(); GpioDataRegs.GPCDAT.bit.GPIO65=0; delay_loop(); GpioDataRegs.GPCSET.bit.GPIO65=1; delay_loop(); ; delay_loop(); GpioDataRegs.GPBDAT.bit.GPIO61=0; delay_loop(); GpioDataRegs.GPBSET.bit.GPIO61=1; delay_loop(); GpioDataRegs.GPBDAT.bit.GPIO60=0; delay_loop(); /******GPCSET (set register) is a small register under GpioData (data register) GpioDataRegs.GPBDAT.bit.GPIO60=0; delay_loop(); GpioDataRegs.GPBSET.bit.GPIO60=1; These two numbers should be used together, otherwise they will not work as a running light, delay_loop();**/ /* D8=0; D9=1; D10=0; D11=1; D12=0; D13=1; D14=0;*/ } } //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.GPBMUX2.bit.GPIO60=0; // GPIO0 = GPIO0 general purpose I/0 GPIO48 to GPIO port 63 is to select GPIOB selection register 2 GpioCtrlRegs.GPBDIR.bit.GPIO60=1; // GPIO0 is configured as an output port GpioCtrlRegs.GPBMUX2.bit.GPIO61=0; // GPIO0 = GPIO0 general purpose I/0 GpioCtrlRegs.GPBDIR.bit.GPIO61=1; // GPIO0 is configured as an output port GpioCtrlRegs.GPCMUX1.bit.GPIO64=0; // GPIO0 = GPIO0 general purpose I/0 GPIO64 to GPIO79 is to select GPIOC selection register 1 GpioCtrlRegs.GPCDIR.bit.GPIO64=1; // GPIO0 is configured as an output port GpioCtrlRegs.GPCMUX1.bit.GPIO65=0; // GPIO0 = GPIO0 general I/0 GpioCtrlRegs.GPCDIR.bit.GPIO65=1; // GPIO0 is configured as an output port GpioCtrlRegs.GPCMUX1.bit.GPIO66=0; // GPIO0 = GPIO0 general I/0 GpioCtrlRegs.GPCDIR.bit.GPIO66=1; // GPIO0 is configured as an output port GpioCtrlRegs.GPCMUX1.bit.GPIO67=0; // GPIO0 = GPIO0 general I/0 GpioCtrlRegs.GPCDIR.bit.GPIO67=1; // GPIO0 is configured as an output port GpioCtrlRegs.GPCMUX1.bit.GPIO68=0; // GPIO0 = GPIO0 general I/0 GpioCtrlRegs.GPCDIR.bit.GPIO68=1; // GPIO0 is configured as an output port EDIS; } //============================================================================ // No more. //================================================================================


This post is from DSP and ARM Processors
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list