안녕하십니까..
EZ-X5보드에 외부SRAM을 2개연결하여 16비트로 데이터를 읽고 쓰려고 합니다..

인터넷 상에 있는 프로그램을 다음과 같이 변형하여 사용하였습니다.
그런데 8비트 데이터는 읽고 쓸수 있는 데 16비트 데이터를 쓰거나 읽으면 에
러가 발생합니다.. 무엇이 잘못되었는지를 가르쳐 주십시요...
다음의 프로그램은 8비트에 대해서는 잘동작됩니다...

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

/********* THIS SHOULD BE IN THE HEADER FILE ***********/
#define SRAM_BASE 0x0C000000 // Ram physical addr.
#define VIR_SARAM 0xf3000000
#define SRAM_SIZE 0x8000 // 512K

unsigned char *sram_open(void);
unsigned char *sram_base_ptr;

/******************************************************/

int main(void)
{
int i,c=0;
unsigned char *ptr;
FILE *fp;

fp = fopen("Test.txt","wb");
sram_base_ptr = sram_open(); // Do all the magic!



printf(".... Proram is Start ....
");

printf("Physical Address = 0x%x
", SRAM_BASE);
printf("Virtual Address = 0x%x
", sram_base_ptr);

for(i=1;i<=100;i++,iptr++) *(sram_base_ptr+i) = 0xaa;

for(i=1;i<=100;i++,iptr++)
{
c = *(sram_base_ptr+i);
fprintf(fp,"i = %d c = 0x%x
",i,c);
}
printf(".... Proram is done ....
");
fclose(fp);

return 0;
}


unsigned char* sram_open(void) {
int mem_fd;
unsigned char *sram_mem;

/* open character device(1,1) '/dev/mem' */
if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) {
printf("sram_open: can't open /dev/mem
");
exit (-1);
}

/* malloc space in our memory */
if ((sram_mem = malloc(SRAM_SIZE + (PAGE_SIZE-1))) == NULL) {
printf("sram_open: malloc allocation error
");
exit (-1);
}
if ((unsigned long)sram_mem % PAGE_SIZE) {
sram_mem += PAGE_SIZE - ((unsigned long)sram_mem %
PAGE_SIZE);
}
printf("sram_mem = 0x%x
",sram_mem);

/* mmap static ram into our memory space */
sram_mem = (unsigned char *)mmap(
(caddr_t)sram_mem,
SRAM_SIZE,
PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FIXED,
mem_fd,
SRAM_BASE
);
if ((long)sram_mem < 0) {
printf("sram_open: mmap error
");
exit (-1);
}
return sram_mem;
}