📄 example_ram.c
字号:
//###########################################################################
//
// FILE: Example_I2C.c
//
// TITLE: Example_I2C TEST
//
// ASSUMPTIONS:
//
// This program requires the DSP281x V1.00 header files.
// As supplied, this project is configured for "boot to H0" operation.
//
// Other then boot mode pin configuration, no other hardware configuration
// is required.
//
// 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.
//
// DESCRIPTION:
//
// Toggle all of the GPIO PORT pins
//
// The pins can be observed using Oscilloscope.
//
//
//###########################################################################
//
// Original by S.S.
//
// Ver | dd mmm yyyy | Who | Description of changes
// =====|=============|======|===============================================
// 1.00 | 11 Sep 2003 | L.H. | First Release
//###########################################################################
#include "DSP281x_Device.h" // DSP281x Headerfile Include File
#include "DSP281x_Examples.h" // DSP281x Examples Include File
// Select the example to compile in. Only one example should be set as 1
// the rest should be set as 0.
void Delay_loop();
Uint16 RamCheck();
Uint16 Delay_count=1;
Uint16 GportVariable,Input[2],Output[2],HighSpeedIn,HighSpeedOut,DzValue[128];
Uchar i2c_value;
void main(void)
{
Uint16 flag;
/*------------------------------------------------------------------
To use the F2812, F2811 or F2810 Flash API, the following steps
must be followed:
1. Modify Flash281x_API.config.h for your targets operating
conditions.
2. Include Flash281x_API_Library.h in the application.
3. Add the approparite Flash API library to the project.
The user's code is responsible for the following:
4. Initalize the PLL to the proper CPU operating frequency.
5. If required, copy the flash API functions into on-chip zero waitstate
RAM.
6. Initalize the Flash_CPUScaleFactor variable to SCALE_FACTOR
7. Optional: Run the Toggle test to confirm proper frequency configuration
of the API.
8. Optional: Unlock the CSM.
9. Call the API functions: Flash_Erase(), Flash_Program(), Flash_Verify()
The API functions will:
Disable the watchdog
Check the device revision (REVID). This API is for Revision C silicon
Perform the desired operation and return status
------------------------------------------------------------------*/
volatile Uint16 iVol;
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP281x_SysCtrl.c file.
InitSysCtrl();
// Step 2. Initalize GPIO:
// This example function is found in the DSP281x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
InitGpio(); // Skipped for this example
// 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 DSP281x_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 DSP281x_DefaultIsr.c.
// This function is found in DSP281x_PieVect.c.
InitPieVectTable();
// Enable interrupts required for this example
XIntruptRegs.XINT1CR.bit.ENABLE=1; //enable xint1
XIntruptRegs.XINT1CR.bit.POLARITY=0;// on a falling edge
PieCtrlRegs.PIEIER1.bit.INTx4=1; // PIE Group 1, INT4
IER = 0x001; // Enable CPU INT1
// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP281x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
// Step 5. User specific code:
EnableInterrupts();
for(;;)
{
flag=RamCheck();
}
}
void Delay_loop()
{
Uint16 j,i,sum;
j=0;
sum=0;
for (i = 0; i < Delay_count; i++) {
for(j=0;j<1;j++)
sum=sum+1;
}
}
Uint16 RamCheck(void)
{
Uint16* ShadowRamAddressPoint;
Uint16 flag;
Uint32 i;
ShadowRamAddressPoint=(Uint16*)0x80000;
flag=0xff;
for(i=0;i<10000;i++)
{
*ShadowRamAddressPoint++=0x5555;
}
ShadowRamAddressPoint=( Uint16*)0x80000;
for(i=0;i<10000;i++)
{
if(*ShadowRamAddressPoint!=0x5555)
flag=0;
ShadowRamAddressPoint++;
}
ShadowRamAddressPoint=( Uint16*)0x80000;
for(i=0;i<10000;i++)
{
*ShadowRamAddressPoint++=0xAAAA;
}
ShadowRamAddressPoint=( Uint16*)0x80000;
for(i=0;i<10000;i++)
{
if(*ShadowRamAddressPoint!=0xAAAA)
flag=0;
ShadowRamAddressPoint++;
}
ShadowRamAddressPoint=( Uint16*)0x80000;
for(i=0;i<10000;i++)
{
*ShadowRamAddressPoint++=0;
}
return flag;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -