init commit.
Проект каким он достался от Димы.
This commit is contained in:
245
v120/DSP2833x_examples/gpio_toggle/Example_2833xGpioToggle.c
Normal file
245
v120/DSP2833x_examples/gpio_toggle/Example_2833xGpioToggle.c
Normal file
@@ -0,0 +1,245 @@
|
||||
// TI File $Revision: /main/8 $
|
||||
// Checkin $Date: April 21, 2008 15:42:43 $
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: Example_2833xGpioToggle.c
|
||||
//
|
||||
// TITLE: DSP2833x Device GPIO toggle test program.
|
||||
//
|
||||
// ASSUMPTIONS:
|
||||
//
|
||||
// This program requires the DSP2833x header files.
|
||||
//
|
||||
// ALL OF THE I/O'S TOGGLE IN THIS PROGRAM. MAKE SURE
|
||||
// THIS WILL NOT DAMAGE YOUR HARDWARE BEFORE RUNNING THIS
|
||||
// EXAMPLE.
|
||||
//
|
||||
// Monitor desired pins on an oscilloscope.
|
||||
//
|
||||
// As supplied, this project is configured for "boot to SARAM"
|
||||
// operation. The 2833x Boot Mode table is shown below.
|
||||
// For information on configuring the boot mode of an eZdsp,
|
||||
// please refer to the documentation included with the eZdsp,
|
||||
//
|
||||
// $Boot_Table:
|
||||
//
|
||||
// GPIO87 GPIO86 GPIO85 GPIO84
|
||||
// XA15 XA14 XA13 XA12
|
||||
// PU PU PU PU
|
||||
// ==========================================
|
||||
// 1 1 1 1 Jump to Flash
|
||||
// 1 1 1 0 SCI-A boot
|
||||
// 1 1 0 1 SPI-A boot
|
||||
// 1 1 0 0 I2C-A boot
|
||||
// 1 0 1 1 eCAN-A boot
|
||||
// 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$
|
||||
//
|
||||
// DESCRIPTION:
|
||||
//
|
||||
// Three different examples are included. Select the example
|
||||
// (data, set/clear or toggle) to execute before compiling using
|
||||
// the #define statements found at the top of the code.
|
||||
//
|
||||
//
|
||||
// Toggle all of the GPIO PORT pins
|
||||
//
|
||||
// The pins can be observed using Oscilloscope.
|
||||
//
|
||||
//
|
||||
//###########################################################################
|
||||
// $TI Release: DSP2833x/DSP2823x Header Files V1.20 $
|
||||
// $Release Date: August 1, 2008 $
|
||||
//###########################################################################
|
||||
|
||||
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
|
||||
|
||||
// Select the example to compile in. Only one example should be set as 1
|
||||
// the rest should be set as 0.
|
||||
#define EXAMPLE1 1 // Use DATA registers to toggle I/O's
|
||||
#define EXAMPLE2 0 // Use SET/CLEAR registers to toggle I/O's
|
||||
#define EXAMPLE3 0 // Use TOGGLE registers to toggle I/O's
|
||||
|
||||
|
||||
// Prototype statements for functions found within this file.
|
||||
void delay_loop(void);
|
||||
void Gpio_select(void);
|
||||
void Gpio_example1(void);
|
||||
void Gpio_example2(void);
|
||||
void Gpio_example3(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
|
||||
|
||||
// For this example use the following configuration:
|
||||
Gpio_select();
|
||||
|
||||
// Step 3. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
DINT;
|
||||
|
||||
// Initialize 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();
|
||||
|
||||
|
||||
// Step 4. Initialize all the Device Peripherals:
|
||||
// This function is found in DSP2833x_InitPeripherals.c
|
||||
// InitPeripherals(); // Not required for this example
|
||||
|
||||
// Step 5. User specific code:
|
||||
|
||||
#if EXAMPLE1
|
||||
|
||||
// This example uses DATA registers to toggle I/O's
|
||||
Gpio_example1();
|
||||
|
||||
#endif // - EXAMPLE1
|
||||
|
||||
#if EXAMPLE2
|
||||
|
||||
// This example uses SET/CLEAR registers to toggle I/O's
|
||||
Gpio_example2();
|
||||
|
||||
#endif
|
||||
|
||||
#if EXAMPLE3
|
||||
|
||||
// This example uses TOGGLE registers to toggle I/O's
|
||||
Gpio_example3();
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void delay_loop()
|
||||
{
|
||||
short i;
|
||||
for (i = 0; i < 1000; i++) {}
|
||||
}
|
||||
|
||||
|
||||
void Gpio_example1(void)
|
||||
{
|
||||
// Example 1:
|
||||
// Toggle I/Os using DATA registers
|
||||
|
||||
for(;;)
|
||||
{
|
||||
GpioDataRegs.GPADAT.all =0xAAAAAAAA;
|
||||
GpioDataRegs.GPBDAT.all =0x0000000A;
|
||||
|
||||
delay_loop();
|
||||
|
||||
GpioDataRegs.GPADAT.all =0x55555555;
|
||||
GpioDataRegs.GPBDAT.all =0x00000005;
|
||||
|
||||
delay_loop();
|
||||
}
|
||||
}
|
||||
|
||||
void Gpio_example2(void)
|
||||
{
|
||||
// Example 2:
|
||||
// Toggle I/Os using SET/CLEAR registers
|
||||
for(;;)
|
||||
{
|
||||
|
||||
GpioDataRegs.GPASET.all =0xAAAAAAAA;
|
||||
GpioDataRegs.GPACLEAR.all =0x55555555;
|
||||
|
||||
GpioDataRegs.GPBSET.all =0x0000000A;
|
||||
GpioDataRegs.GPBCLEAR.all =0x00000005;
|
||||
|
||||
delay_loop();
|
||||
|
||||
GpioDataRegs.GPACLEAR.all =0xAAAAAAAA;
|
||||
GpioDataRegs.GPASET.all =0x55555555;
|
||||
|
||||
GpioDataRegs.GPBCLEAR.all =0x0000000A;
|
||||
GpioDataRegs.GPBSET.all =0x00000005;
|
||||
|
||||
delay_loop();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Gpio_example3(void)
|
||||
{
|
||||
// Example 2:
|
||||
// Toggle I/Os using TOGGLE registers
|
||||
|
||||
// Set pins to a known state
|
||||
|
||||
GpioDataRegs.GPASET.all =0xAAAAAAAA;
|
||||
GpioDataRegs.GPACLEAR.all =0x55555555;
|
||||
|
||||
GpioDataRegs.GPBSET.all =0x0000000A;
|
||||
GpioDataRegs.GPBCLEAR.all =0x00000005;
|
||||
|
||||
// Use TOGGLE registers to flip the state of
|
||||
// the pins.
|
||||
// Any bit set to a 1 will flip state (toggle)
|
||||
// Any bit set to a 0 will not toggle.
|
||||
|
||||
for(;;)
|
||||
{
|
||||
GpioDataRegs.GPATOGGLE.all =0xFFFFFFFF;
|
||||
GpioDataRegs.GPBTOGGLE.all =0x0000000F;
|
||||
delay_loop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Gpio_select(void)
|
||||
{
|
||||
|
||||
|
||||
EALLOW;
|
||||
GpioCtrlRegs.GPAMUX1.all = 0x00000000; // All GPIO
|
||||
GpioCtrlRegs.GPAMUX2.all = 0x00000000; // All GPIO
|
||||
GpioCtrlRegs.GPAMUX1.all = 0x00000000; // All GPIO
|
||||
GpioCtrlRegs.GPADIR.all = 0xFFFFFFFF; // All outputs
|
||||
GpioCtrlRegs.GPBDIR.all = 0x0000000F; // All outputs
|
||||
EDIS;
|
||||
|
||||
}
|
||||
//===========================================================================
|
||||
// No more.
|
||||
//===========================================================================
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
// TI File $Revision: /main/5 $
|
||||
// Checkin $Date: August 9, 2007 17:16:50 $
|
||||
//###########################################################################
|
||||
//
|
||||
// This .gel file can be used to help load and build the example project.
|
||||
// It should be unloaded from Code Composer Studio before loading another
|
||||
// project.
|
||||
//
|
||||
//###########################################################################
|
||||
// $TI Release: DSP2833x/DSP2823x Header Files V1.20 $
|
||||
// $Release Date: August 1, 2008 $
|
||||
//###########################################################################
|
||||
*/
|
||||
|
||||
menuitem "DSP2833x GPIO Toggle Test"
|
||||
|
||||
hotmenu Load_and_Build_Project()
|
||||
{
|
||||
GEL_ProjectLoad("Example_2833xGpioToggle.pjt");
|
||||
GEL_ProjectBuild("Example_2833xGpioToggle.pjt");
|
||||
Setup_WatchWindow();
|
||||
}
|
||||
|
||||
hotmenu Load_Code()
|
||||
{
|
||||
GEL_Load(".\\debug\\Example_2833xGpioToggle.out");
|
||||
Setup_WatchWindow();
|
||||
}
|
||||
|
||||
hotmenu Setup_WatchWindow()
|
||||
{
|
||||
GEL_WatchReset();
|
||||
GEL_WatchAdd("GpioDataRegs,x");
|
||||
GEL_WatchAdd("GpioCtrlRegs,x");
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
; Code Composer Project File, Version 2.0 (do not modify or remove this line)
|
||||
|
||||
[Project Settings]
|
||||
ProjectName="DSP2833x"
|
||||
ProjectDir="C:\tidcs\c28\DSP2833x\v120\DSP2833x_examples\gpio_toggle\"
|
||||
ProjectType=Executable
|
||||
CPUFamily=TMS320C28XX
|
||||
Tool="Compiler"
|
||||
Tool="DspBiosBuilder"
|
||||
Tool="Linker"
|
||||
Config="Debug"
|
||||
Config="Release"
|
||||
|
||||
[Source Files]
|
||||
Source="..\..\DSP2833x_common\source\DSP2833x_ADC_cal.asm"
|
||||
Source="..\..\DSP2833x_common\source\DSP2833x_CodeStartBranch.asm"
|
||||
Source="..\..\DSP2833x_common\source\DSP2833x_DefaultIsr.c"
|
||||
Source="..\..\DSP2833x_common\source\DSP2833x_PieCtrl.c"
|
||||
Source="..\..\DSP2833x_common\source\DSP2833x_PieVect.c"
|
||||
Source="..\..\DSP2833x_common\source\DSP2833x_SysCtrl.c"
|
||||
Source="..\..\DSP2833x_common\source\DSP2833x_usDelay.asm"
|
||||
Source="..\..\DSP2833x_headers\source\DSP2833x_GlobalVariableDefs.c"
|
||||
Source="Example_2833xGpioToggle.c"
|
||||
Source="..\..\DSP2833x_common\cmd\28335_RAM_lnk.cmd"
|
||||
Source="..\..\DSP2833x_headers\cmd\DSP2833x_Headers_nonBIOS.cmd"
|
||||
|
||||
["Compiler" Settings: "Debug"]
|
||||
Options=-g -q -pdr -fr"C:\tidcs\c28\DSP2833x\v120\DSP2833x_examples\gpio_toggle\Debug" -fs"C:\tidcs\c28\DSP2833x\v120\DSP2833x_examples\gpio_toggle\Debug" -i"..\..\DSP2833x_headers\include" -i"..\..\DSP2833x_common\include" -d"_DEBUG" -d"LARGE_MODEL" --float_support=fpu32 -ml -mt -v28
|
||||
|
||||
["Compiler" Settings: "Release"]
|
||||
Options=-q -o3 -fr"C:\tidcs\c28\DSP2833x\v120\DSP2833x_examples\gpio_toggle\Release" -d"LARGE_MODEL" -ml -v28
|
||||
|
||||
["DspBiosBuilder" Settings: "Debug"]
|
||||
Options=-v28
|
||||
|
||||
["DspBiosBuilder" Settings: "Release"]
|
||||
Options=-v28
|
||||
|
||||
["Linker" Settings: "Debug"]
|
||||
Options=-q -c -ecode_start -m".\Debug\Example_2833xGpioToggle.map" -o".\Debug\Example_2833xGpioToggle.out" -stack0x200 -w -x -i"..\..\DSP2833x_headers\include" -l"rts2800_fpu32.lib"
|
||||
|
||||
["Linker" Settings: "Release"]
|
||||
Options=-q -c -o".\Release\Example_2833xGpioToggle.out" -x
|
||||
|
||||
Reference in New Issue
Block a user