Reading FlexCan registers with memcpy()

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Reading FlexCan registers with memcpy()

1,238 次查看
davidzhou
Contributor V

Hi,

I have a K60. I tried to access FlexCan registers with a memcpy into a RAM buffer. But the program execution crashes as soon as memcpy is called.

//pCanReg=0x40024000

char buf[100];

memcpy((PCHAR)&(buf[0]), (PCHAR)&pCanReg->MCR, 0x20);

 

Do you know why?

Thank you,

 

David Zhou

标签 (1)
0 项奖励
回复
10 回复数

793 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello David,

What about this pointer PCHAR ? How about delete it like this :

memcpy(&(buf[0]), &pCanReg->MCR, 0x20);

if it still can not work , you can send you project to me , and tell me the part number of your chip .

Hope it helps

ALice

0 项奖励
回复

793 次查看
davidzhou
Contributor V

Hi Alice,

I tried without PCHAR or with (void*). It is the same. I was wandering it maybe lock the access by read. I don't know exactly how it is done but the access pCanReg->MB[0]->CS locks the mailbox. I tried that CS is not within the copy block address range. It still crashes. That's puzzling me.

Thank you,

David

0 项奖励
回复

793 次查看
davidzhou
Contributor V

Hi Alice,

I have zipped my project files for you but I don't know how to attach it. Sorry, I am newbie with NXP.

Thank you,

David Zhou

0 项奖励
回复

793 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi David,

Please attach it as this :

pastedImage_0.png

pastedImage_1.png

And do you want copy 0x20 byte ? it also said 8 registers ?

BR

Alice

0 项奖励
回复

793 次查看
davidzhou
Contributor V

pastedImage_0.png

I clicked Actions button, there is no Manage: Delete/Edit, etc. The only action available is Mark As Correct.

David

0 项奖励
回复

793 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

ello David,

I don't know why your side is like that , on my side ,it is

pastedImage_1.png

then click Actions , it can show Edit.

If you still have not solve it , you can send the project to my mailbox

alice.yang@nxp.com.

BR

Alice

0 项奖励
回复

793 次查看
davidzhou
Contributor V

Hi Alice,

The Action | Edit doesn't appear on my side. It might be related with IE setup. I may not pursue this issue anymore, because I am not planning to write some functions related with memcpy of CAN registers. So you can close this tick. In case if I need it again, I can repost the tick.

Thank you so much.

David Zhou

0 项奖励
回复

793 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

ok!

BR

Alice

0 项奖励
回复

793 次查看
Fan_xy
Contributor III

....

0 项奖励
回复

793 次查看
davidzhou
Contributor V

Hi Alice,

I want to copy as many as possible in one block, if there is no restriction. The mailbox (MB) structure CS is used for locking. It may not be able to be copied.@ !

In attached code, please find  "For Alice: 1. memcpy ok" in the KzMain.c. the memcpy is currently commented out.

Thank you,

David Zhou

0 项奖励
回复