📄 v3k_fram_demo_4_datash_sdcc.c
字号:
//-------------------------------------------------------------------------------------------------------//
// V3K_FRAM_Use_Example_SDCC.c //
//------------------------------//
//
// This program show how to perform the following operations:
//
// -Enables the FRAM memory
// -Fill the FRAM with 0x55
// -Write 0x23 at address 0x9100 in FRAM
// -Read Content of address 0x9100 and place it into B register
// - Activate FRAM Write Protect
// -Show how to Read the FRAM Block protect configuration
//
// www.ramtron.com
//-------------------------------------------------------------------------------------------------------//
#include <VRS51L3074_SDCC.h>
//--Fram Protect Function prototype
void FramProtect(char);
//--Init pointer to FRAM base address
xdata at 0x8000 unsigned char frambase; //Init a char variable pointing to FRAM
xdata unsigned char * data framptr = &frambase ; //Init a pointer in IRAM pointing to the frambase var.
//////////////////////////////////////////////////////////////////
/////////////////////// MAIN FUNCTION ///////////////////////////
//////////////////////////////////////////////////////////////////
void main (void){
int cptr= 0x00; //general purpose counter
//int x;
DEVMEMCFG |= 0xC0; //Activate the FRAM
//--Fill the FRAM with 0x55
for(cptr = 0; cptr < 0x400; cptr++)
*(framptr+cptr) = 0x55;
//--Write 0x23 at address 0x9100 in FRAM
*(framptr + 0x9100) = 0x23;
//--Read Content of address 0x9100 and place it into B register
B = *(framptr + 0x9100);
//-- Activate FRAM Write Protect
FRAMCFG1 = 0x01; //Set FRAMWEL = 1 Enable Write (FRAMOP = 00)
while(!(FRAMCFG1&0x80)); //Wait FREADIDLE == 1 (FRAM IDLE)
FRAMCFG2 = 0x0C; //Configure FRAMCFG2 to protect the entire FRAM
FRAMCFG1 = 0x07; //Execute Transfert of FRAMCFG2 module to FRAM Module
while(!(FRAMCFG1&0x80)); //Wait FREADIDLE == 1 (FRAM IDLE)
FRAMCFG1 = 0x03; //Clear FRAMWEL (FRAMOP = 01)
while(!(FRAMCFG1&0x80)); //Wait FREADIDLE == 1 (FRAM IDLE)
//--Optional Read of the FRAM Block protect configuration
//read WEL (optional)
//FRAMCFG1 = 0x05; //read FRAMCFG2
//while(!(FRAMCFG1&0x80)); //Wait FREADIDLE == 1 (FRAM IDLE)
//x = FRAMCFG2 //Read the FRAMCFG2 register
//(...)
while(1);
}//end of Main
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -