Using Matlab function in the MBD problems

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

Using Matlab function in the MBD problems

2,401 次查看
haoxue1027
Contributor V

Hello

There is a need to use some port timing config in my MBD simulink(devkit MPC5744P).

So I want to use matlab function. But I don't know how to config the time accurately,for example ,the t1  in the following picture.

I have used the nop() in my matlab function , but it seems not work.

haoxue1027_0-1600333952722.png

haoxue1027_1-1600333975671.png

Can you give me some advices? 

best regards

hao

 

0 项奖励
回复
5 回复数

2,396 次查看
haoxue1027
Contributor V

@constantinrazva @mariuslucianand @adriantudor 

Razvan,Marius,adrian

I'm sorry to bother you, but could you spare me a moment to help me with this problem?

thank you very much.

best regards

hao

0 项奖励
回复

2,387 次查看
mariuslucianand
NXP Employee
NXP Employee

Hello @haoxue1027 ,

I think you can achieve this exact timing using a PIT timer, channel 1.

Please have a look at one of our PIT examples. Basically you need to use a volatile declared flag, and inside your program, whenever you want to toggle the CLK pin you modify that flag.

This is one way of doing it!

Hope this helps,

Marius

0 项奖励
回复

2,350 次查看
haoxue1027
Contributor V

@mariuslucianand Hello,marius

I have tried to use matlab function to do the port timing.

But  it seemed not work.

In the matlab function ,The actual hardware pin voltage level does not change with the code.

If I used the PIT,how to realize it ?

Can you explain it a little bit more?

best regards

hao

 

0 项奖励
回复

2,372 次查看
haoxue1027
Contributor V

@mariuslucianand Hello marius

Can I used a C code “for loop” to implement that?

For example, If I want to have a time delay 500ns, I can use the for( i=0:i<10:i++)(MPC5744 one step 50ns).

Whether this method can be implemented for time dely?

best regards

hao

 

0 项奖励
回复

2,376 次查看
haoxue1027
Contributor V

@mariuslucianand Hello,marius

Thank you very much for replying.

What I want to know is that if have a C code(like _nop() or dely function) can be used in the  matlab function to make a accurate time dely.

Beacuse I want to config a port timing like following.

haoxue1027_0-1600345540112.png

If there is no such C code , can you tell me further how to implement it by the MBD.

I have used the stateflow to test it.

It seemed that the timing is not accurate.

Thank you very much.

best regards

hao

0 项奖励
回复