Using Matlab function in the MBD problems

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Matlab function in the MBD problems

223 Views
Contributor IV

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 Kudos
5 Replies

218 Views
Contributor IV

@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 Kudos

209 Views
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 Kudos

172 Views
Contributor IV

@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 Kudos

194 Views
Contributor IV

@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 Kudos

198 Views
Contributor IV

@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 Kudos