This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Starterware: DMTIMER

Tool/software: Starterware

Hello,

Iam Using mmap function to access dmtimer_1ms register and read the TCRR , My code is:

int fd = open("/dev/mem",O_RDWR | O_SYNC);

ulong* dmtimer2_regs = (ulong*) mmap(NULL, 0x4,PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x44E31000);

t0 = dmtimer2_regs[0x28 /4]; // divide by 4 as the offset address in regidters is by byte not by bit .. ulong is 32 bit log ,, also the register is 32bit long
sleep(1);
t1 = dmtimer2_regs[0x28 /4];
cout << t1 - t0 << endl;  // output is around 24 Mhz as expected by default.

Now, i want o select the external rtc 32khz clock , so i tried this code: 

int main(){

int32_t t0;
int32_t t1;

int fd0= open("/dev/mem",O_RDWR | O_SYNC);
ulong* clk_sel = (ulong*) mmap(0xb6ff5000, 0x4,PROT_READ|PROT_WRITE, MAP_SHARED, fd0, 0x44E00500);

clk_sel[0x28 /4] &= 0xFFFC;
clk_sel[0x28 /4] |= 0x4;   // select the 32khy clk    

int fd = open("/dev/mem",O_RDWR | O_SYNC);

ulong* dmtimer2_regs = (ulong*) mmap(NULL, 0x4,PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x44E31000)

t0 = dmtimer2_regs[0x28 /4]; // divide by 4 as the offset address in regidters is by byte not by bit .. ulong is 32 bit log ,, also the register is 32bit long
sleep(1);
t1 = dmtimer2_regs[0x28 /4];
cout << t1 - t0 << endl; // typically 5 clock ticks (each clock tick is ~41ns)

the problem is there is segmentation fault error all the time on this line:

ulong* clk_sel = (ulong*) mmap(0xb6ff5000, 0x4,PROT_READ|PROT_WRITE, MAP_SHARED, fd0, 0x44E00400);

Does any body know the reason, how can i solve?