⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example_281xwatchdog.c

📁 本程序通过F2812实现SPWM,开发平台CCS
💻 C
字号:
#include "DSP281x_Device.h"     // DSP281x Headerfile Include File
#include "DSP281x_Examples.h"   // DSP281x Examples Include File
volatile long int DataAddr1;
volatile int  i;
volatile long j;
volatile int DataBuf1;//sindata 
volatile long int Dataram;
//延时
void delay_us1(void)
{j=1000;
 while(j>0)
 j--;
}

void delay_loop(void)
{i=2;
 while (i>0)
 i--;
}
void erase_flash(void)
{
//start, initial the state: 片选ce=1, 输出读信号oe=1, 写信号we=1.低电平有效
//erase flash1     
//step1-step6
//step1  
   DataAddr1=0x085555;
   delay_loop();
   DataBuf1=0xAA; 
   *(long*)DataAddr1=DataBuf1;
   delay_loop();
//step2
   DataAddr1=0x082AAA;
   delay_loop();
   DataBuf1=0x55;
   *(long*)DataAddr1=DataBuf1;
   delay_loop();
//step3   
   DataAddr1=0x085555;
   delay_loop();
   DataBuf1=0x80;
   *(long*)DataAddr1=DataBuf1;
   delay_loop();
//step4
   DataAddr1=0x085555;
   delay_loop();
   DataBuf1=0xAA;
   *(long*)DataAddr1=DataBuf1;
   delay_loop();
//step5
   DataAddr1=0x082AAA;
   DataBuf1=0x55;
   //delay_loop();
   *(long*)DataAddr1=DataBuf1;
   delay_loop();
//step6
   DataAddr1=0x085555;
   delay_loop();
   DataBuf1=0x10;
   *(long*)DataAddr1=DataBuf1;
   delay_loop();
//erase wait         
   for(i=0;i<1100;i++)//wait 15s 至少100ms
   delay_us1();
}
void word_program(void)
{  
   DataAddr1=0x085555;
   delay_loop();
   DataBuf1=0xAA; 
   *(long*)DataAddr1=DataBuf1;
   delay_loop();
 //step2
   DataAddr1=0x082AAA;
   delay_loop();
   DataBuf1=0x55;
   *(long*)DataAddr1=DataBuf1;
   delay_loop();  
 //step3   
   DataAddr1=0x085555;
   delay_loop();
   DataBuf1=0xA0;
   *(long*)DataAddr1=DataBuf1;
   delay_loop(); 
 //step4
   DataAddr1=0x080000;
   delay_loop();
   DataBuf1=0x1234;
   *(long*)DataAddr1=DataBuf1;
   //delay_loop();
   delay_us1();  
}
void main(void)
{
// 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();
   erase_flash();
   word_program();
   for(;;)
   {};
}
 	


//===========================================================================
// No more.
//===========================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -