標(biāo)題:
DSP2833x例程GPIO_output_LED
[打印本頁(yè)]
作者:
lxiiii
時(shí)間:
2017-12-25 20:09
標(biāo)題:
DSP2833x例程GPIO_output_LED
源程序如下:
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#define LED1 GpioDataRegs.GPADAT.bit.GPIO0
#define LED2 GpioDataRegs.GPADAT.bit.GPIO1
#define LED3 GpioDataRegs.GPADAT.bit.GPIO2
#define LED4 GpioDataRegs.GPADAT.bit.GPIO3
#define LED5 GpioDataRegs.GPADAT.bit.GPIO4
void configtestled(void);
void main(void)
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2833x_SysCtrl.c file.
InitSysCtrl();
// Step 2. Initalize GPIO:
// This example function is found in the DSP2833x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio(); // Skipped for this example
InitXintf16Gpio(); //zq
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
DINT;
// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP2833x_PieCtrl.c file.
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in DSP2833x_DefaultIsr.c.
// This function is found in DSP2833x_PieVect.c.
InitPieVectTable();
configtestled();
// LED1=1;
// DELAY_US(10);
// LED2=1;
// DELAY_US(10);
LED1=0;
DELAY_US(10);
LED2=0;
DELAY_US(10);
LED3=0;
DELAY_US(10);
LED4=0;
DELAY_US(10);
LED5=0;
DELAY_US(10);
while(1){
LED1=~LED1;
DELAY_US(100000);
LED2=~LED2;
DELAY_US(100000);
LED3=~LED3;
DELAY_US(100000);
LED4=~LED4;
DELAY_US(100000);
LED5=~LED5;
DELAY_US(100000);
}
}
void configtestled(void)
{
EALLOW;
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0; // GPIO0復(fù)用為GPIO功能
GpioCtrlRegs.GPADIR.bit.GPIO0 = 1; // GPIO0設(shè)置為輸出
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0; // GPIO1 = GPIO1
……………………
…………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼
所有資料51hei提供下載:
lab1-GPIO_output_LED.rar
(412.62 KB, 下載次數(shù): 26)
2017-12-25 20:09 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
作者:
jiangkeqin_sy
時(shí)間:
2018-4-12 16:12
學(xué)習(xí)啊
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1