c_rw_ram.c

来自「Embest EudKit-II教学系统配Samsung S3C44B0处理器的」· C语言 代码 · 共 49 行

C
49
字号
/*********************************************************************************************
* File:	c_ram_test.c
* Author:	embest R.X.Huang
* Desc:	Memory Read/Write test function
* History:	
*********************************************************************************************/
#include "rw_ram.h"

/*********************************************************************************************
* name:		c_ram_test
* func:		access memory by word, hard word, byte
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void c_ram_test(void)
{
	int i,nStep; 

    // Access by Word. 
    nStep = sizeof(int);            
    for(i = 0; i < RW_NUM/nStep; i++)          
	{
		(*(int *)(RW_BASE +i*nStep))     = 0x45563430;                   // write memory
		(*(int *)(RW_TARGET + i*nStep))  = (*(int *)(RW_BASE + i*nStep));// read memory
	}
    uart_printf("  Access Memory (Word) Times : %d\n",i); 

    // Access by half Word.
    nStep = sizeof(short);           
    for(i = 0; i < RW_NUM/nStep; i++)
	{
		(*(short *)(RW_BASE + i*nStep))  = 0x4B4F;                         // write memory
		(*(short *)(RW_TARGET +i*nStep)) = (*(short *)(RW_BASE + i*nStep));// read memory
	}
    uart_printf("  Access Memory (half Word) Times : %d\n",i);

	// Access by Byte.
    nStep = sizeof(char);
    for(i = 0; i < RW_NUM/nStep; i++)  
	{
		(*(char *)(RW_BASE + i*nStep))   = 0x59;                          // write memory
		(*(char *)(RW_TARGET + i*nStep)) = (*(char *)(RW_BASE + i*nStep));// read memory
	}
    uart_printf("  Access Memory (Byte) Times : %d\n",i); 
	
}

⌨️ 快捷键说明

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