- Home
- :
- NXP Model-Based Design Tools
- :
- NXP Model-Based Design Tools
- :
- Using Matlab function in the MBD problems

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Using Matlab function in the MBD problems

09-17-2020
02:14 AM

223 Views

haoxue1027

Contributor IV

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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.

Can you give me some advices?

best regards

hao

5 Replies

09-17-2020
02:58 AM

218 Views

haoxue1027

Contributor IV

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

@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

09-17-2020
04:09 AM

209 Views

mariuslucianand

NXP Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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

09-18-2020
12:39 AM

172 Views

haoxue1027

Contributor IV

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

@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

09-17-2020
05:47 AM

194 Views

haoxue1027

Contributor IV

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

@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

09-17-2020
05:28 AM

198 Views

haoxue1027

Contributor IV

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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

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