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

📄 test_flash.c

📁 silicon lab 单片机C8051F320的片内flash 读写程序
💻 C
字号:
				//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include "flash.h"
#include <c8051F320.h>
//-----------------------------------------------------------------------------
// Structures, Unions, Enumerations, and Type Definitions
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Global Constants
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Function Prototypes
//-----------------------------------------------------------------------------
// FLASH read/write/erase routines
void PCA_Init();
void Oscillator_Init();
void Reset_Sources_Init();
//-----------------------------------------------------------------------------
// Global Variables
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// FLASH Routines
//-----------------------------------------------------------------------------

// Initialization function for device,
// Call Init_Device() from your main program
void main(void)
{ 
	 //unsigned int xdata *pwrite; 
	// unsigned int code *pread; 
	
	 PCA_Init();
	 Oscillator_Init();
	 Reset_Sources_Init();
	 FLASH_ByteRead(1000); 
	 FLASH_PageErase(1000);
	 FLASH_ByteRead(1000); 
	 FLASH_ByteWrite(1000, 0x055);
	 FLASH_ByteRead(1000);   
   	 while(1) ;
}

 

void Reset_Sources_Init()
{
    int i = 0;
    VDM0CN    = 0x80;
    for (i = 0; i < 350; i++);  // Wait 100us for initialization
    RSTSRC    = 0x02;
}

void PCA_Init()
{
    PCA0MD    &= ~0x40;
    PCA0MD    = 0x00;
}

void Oscillator_Init()
{
    int i = 0;
    OSCICN    = 0x83;
}


⌨️ 快捷键说明

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