📄 example_28xgpio.c
字号:
//
// TMDX ALPHA RELEASE
// Intended for product evaluation purposes
//
//###########################################################################
//
// FILE: Example_28xGpio.c
//
// TITLE: DSP28 Device GPIO test porgram.
// All the GPIO PORT pins IOs will toggle forever in an indefinite
// loop
//
//###########################################################################
//
// Ver | dd mmm yyyy | Who | Description of changes
// =====|=============|======|===============================================
// 0.56| 06 May 2002 | S.S. | EzDSP Alpha Release
// 0.57| 27 May 2002 | L.H. | No change
//###########################################################################
#include "DSP281x_Device.h"
#include "DSP281x_Examples.h"
// Prototype statements for functions found within this file.
// interrupt void ISRTimer2(void);
void delay_loop(void);
void Gpio_select(void);
unsigned int var1 = 0x4000;
unsigned int var2 = 0;
unsigned int var3 = 0;
unsigned int var4 = 0;
unsigned int var5 = 0;
extern Uint16 RamfuncsLoadStart;
extern Uint16 RamfuncsLoadEnd;
extern Uint16 RamfuncsRunStart;
void main(void)
{
// Step 1. Initialize System Control registers, PLL, WatchDog, Clocks to default state:
// This function is found in the DSP28_SysCtrl.c file.
InitSysCtrl();
// Step 2. Select GPIO for the device or for the specific application:
// This function is found in the DSP28_Gpio.c file.
// InitGpio(); skip this as this is for GPIO test
// Step 3. Initialize PIE vector table:
// The PIE vector table is initialized with pointers to shell Interrupt
// Service Routines (ISR). The shell routines are found in DSP28_DefaultIsr.c.
// Insert user specific ISR code in the appropriate shell ISR routine in
// the DSP28_DefaultIsr.c file.
// Disable and clear all CPU interrupts:
DINT;
IER = 0x0000;
IFR = 0x0000;
// Initialize Pie Control Registers To Default State:
// This function is found in the DSP28_PieCtrl.c file.
InitPieCtrl();
// Initialize the PIE Vector Table To a Known State:
// This function is found in DSP28_PieVect.c.
// This function populates the PIE vector table with pointers
// to the shell ISR functions found in DSP28_DefaultIsr.c.
InitPieVectTable();
// Step 4. Initialize all the Device Peripherals to a known state:
// This function is found in DSP28_InitPeripherals.c
// InitPeripherals(); skip this for GPIO tests
// Step 5. User specific functions, Reassign vectors (optional), Enable Interrupts:
// Step 5. User specific code, enable interrupts:
// Copy time critical code and Flash setup code to RAM
// This includes the following ISR functions: EvaTimer1(), EvaTimer2()
// EvbTimer3 and and InitFlash();
// The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
// symbols are created by the linker. Refer to the F2812.cmd file.
MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
// Call Flash Initialization to setup flash waitstates
// This function must reside in RAM
InitFlash();
// Run GPIO test
var1= 0x4000; // sets GPIO Muxs as I/Os
var2= 0xFFFF; // sets GPIO DIR as outputs
var3= 0x0000; // sets the Input qualifier values
Gpio_select();
// Toggle I/Os using DATA register for ever
while(1)
{
/*GpioDataRegs.GPADAT.all =0xAAAA;
GpioDataRegs.GPBDAT.all =0xAAAA;
GpioDataRegs.GPDDAT.all =0x0022;
GpioDataRegs.GPEDAT.all =0x0002;
GpioDataRegs.GPFDAT.all =0xAAAA;
GpioDataRegs.GPGDAT.all =0x0020; */
//delay_loop();
/*GpioDataRegs.GPADAT.all =0x5555;
GpioDataRegs.GPBDAT.all =0x5555;
GpioDataRegs.GPDDAT.all =0x0041; // Four I/Os only
GpioDataRegs.GPEDAT.all =0x0005; // ThreeI/Os only
GpioDataRegs.GPFDAT.all =0x5555;
GpioDataRegs.GPGDAT.all =0x0010;*/ // Two I/Os only
//delay_loop();
asm(" setc xf ");
*(int *)0x3f9fff = 0;
while(*(int *)0x3f9fff<0xffff)
{*(int *)0x3f9fff = *(int *)0x3f9fff+1;
*(int *)0x70d4 = 0x4000;
}
*(int *)0x3f9fff = 0;
while(*(int *)0x3f9fff<0xffff)
{*(int *)0x3f9fff = *(int *)0x3f9fff+1;
}
*(int *)0x3f9fff = 0;
while(*(int *)0x3f9fff<0xffff)
{*(int *)0x3f9fff = *(int *)0x3f9fff+1;
}
delay_loop();
delay_loop();
delay_loop();
asm(" clrc xf ");
*(int *)0x3f9fff = 0;
while(*(int *)0x3f9fff<0xffff)
{*(int *)0x3f9fff = *(int *)0x3f9fff+1;
}
*(int *)0x3f9fff = 0;
while(*(int *)0x3f9fff<0xffff)
{*(int *)0x3f9fff = *(int *)0x3f9fff+1;
}
*(int *)0x3f9fff = 0;
while(*(int *)0x3f9fff<0xffff)
{*(int *)0x3f9fff = *(int *)0x3f9fff+1;
}
}
// EALLOW; // This is needed to write to EALLOW protected registers
// PieVectTable.TINT2 = &ISRTimer2;
// EDIS; // This is needed to disable write to EALLOW protected registers
// Enable INT14 which is connected to CPU-Timer 2:
// IER |= M_INT14;
// Enable global Interrupts and higher priority real-time debug events:
// EINT; // Enable Global interrupt INTM
// ERTM; // Enable Global realtime interrupt DBGM
// Step 6. IDLE loop. Just sit and loop forever (optional):
// for(;;);
}
// Step 7. Insert all local Interrupt Service Routines (ISRs) and functions here:
// If local ISRs are used, reassign vector addresses in vector table as
// shown in Step 5
/*
// Interrupt function template
interrupt void ISRTimer2(void)
{
}
*/
void delay_loop()
{
short i,j;
for(j=0;j<100;j++)
{ for (i = 0; i < 0xffff; i++) {}
}
}
void Gpio_select(void)
{
EALLOW;
//GpioMuxRegs.GPAMUX.all=var1;
//GpioMuxRegs.GPBMUX.all=var1;
//GpioMuxRegs.GPDMUX.all=var1;
GpioMuxRegs.GPFMUX.all=var1;
//GpioMuxRegs.GPEMUX.all=var1;
//GpioMuxRegs.GPGMUX.all=var1;
//GpioMuxRegs.GPADIR.all=var2; // GPIO PORTs as output
//GpioMuxRegs.GPBDIR.all=var2; // GPIO DIR select GPIOs as output
//GpioMuxRegs.GPDDIR.all=var2;
//GpioMuxRegs.GPEDIR.all=var2;
// GpioMuxRegs.GPFDIR.all=var2;
//GpioMuxRegs.GPGDIR.all=var2;
//GpioMuxRegs.GPAQUAL.all=var3; // Set GPIO input qualifier values
//GpioMuxRegs.GPBQUAL.all=var3;
//GpioMuxRegs.GPDQUAL.all=var3;
//GpioMuxRegs.GPEQUAL.all=var3;
EDIS;
}
//===========================================================================
// No more.
//===========================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -