How do I get the binary code of a function using MPC5604

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

How do I get the binary code of a function using MPC5604

3,133 次查看
1475849560
Contributor II

I want to convert a function to binary coded form, like this

1.bmp2.bmp

0 项奖励
回复
13 回复数

3,118 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

I don't know which IDE you use, but I'm sure it can generate s-record file - either by default or it can be enabled. The extension of file is .mot, .s3 or something like that.

Then I have command line tool which can convert s-record to c-array. See attached. Notice that I'm providing it with no guarantees and no support, it's not official tool. Use windows command line to see what the arguments are.

You can put a function to some specific segment, so you can easily extract it from the s-record file and then you can use the tool to create c-array if needed.

Regards,

Lukas

 

0 项奖励
回复

3,108 次查看
1475849560
Contributor II

Thanks,the IDE tool I use is CodeWarrior 10.5.

As you said, there is a MOT file but how do I use s2C?

2.bmp

1.bmp

How do I convert a function into an array using this instruction?

0 项奖励
回复

3,105 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

I do not have documentation for the tool, just follow the description of arguments. I believe you will figure it out after a couple of experiments. Example:

s2c 4 FF 100 test_c_array whatever.mot output.txt

And as I mentioned, put your function to some specific segment, so you can easily find in in the s-record ifle and then separate required part of the s-record to another file. This file then use with the tool.

Regards,

Lukas

 

 

 

 

0 项奖励
回复

3,073 次查看
1475849560
Contributor II

There is an error in the above image. Here is the updated image and the compiled result.

6.png

0 项奖励
回复

3,078 次查看
1475849560
Contributor II

Sorry, I have another problem, I can't put a function in a paragraph.I can only put one variable in a paragraph.Can you tell me how to put a function in a segment?Thank you very much!

3.png4.png

0 项奖励
回复

3,053 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,
this is how to put a function to specific flash segment and to specific RAM segment (the code is copied to RAM by startup files):

MEMORY
{
...
hello_test: org = ..., len = ... //flash segment
code_ram: org = ..., len = ... //RAM segment
...
}

SECTIONS
{
...
.__code_ram (VLECODE) : {} > code_ram
.__hello_test (VLECODE) LOAD(ADDR(hello_test)) : {} > hello_test
...
}

And in C file:

#pragma push
#pragma section code_type ".__hello_test" code_mode=far_abs
void test(void)
{
asm("nop");
}
#pragma pop

#pragma push
#pragma section code_type ".__code_ram" code_mode=far_abs
void test_ram(void)
{
asm("nop");
}
#pragma pop

Regards,
Lukas

 

0 项奖励
回复

3,103 次查看
1475849560
Contributor II

Thank you very much for your reply!
I want to try it as you said, but what do the second and third parameters mean?
How should the MPC5604B parameters be set?

0 项奖励
回复

3,103 次查看
1475849560
Contributor II
Thank you very much for your reply! I want to try it as you said, but what do the second and third parameters mean? How should the MPC5604B parameters be set?
0 项奖励
回复

3,096 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

If there's a gap in s-record file, the gap is filled with specified character (FF in my example above). Threshold then says what is the max size of such gap. If it is more then specified, the rest of the s-record is not used.

Regards,

Lukas

 

0 项奖励
回复

2,989 次查看
1475849560
Contributor II

Finally, I get an array by s2c

1475849560_0-1610024322736.png

 

 

test_fun didn't work properly.

 

Looking forward to your reply,Thank you very much.

 

 

 

 

 

0 项奖励
回复

2,990 次查看
1475849560
Contributor II

 

 

 

0 项奖励
回复

2,994 次查看
1475849560
Contributor II

The program did not work normally after s2c.exe conversion.

 

 

0 项奖励
回复

3,127 次查看
1475849560
Contributor II

I want to convert a function to binary coded form

0 项奖励
回复