test_flash.c

来自「silicon lab 单片机C8051F320的片内flash 读写程序」· C语言 代码 · 共 67 行

C
67
字号
				//-----------------------------------------------------------------------------
// 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 + =
减小字号Ctrl + -
显示快捷键?