How to configure Tcsc and Tasc in SPI communication?

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

How to configure Tcsc and Tasc in SPI communication?

跳至解决方案
2,349 次查看
wbj5238
Contributor III

I am very new to NXP model-based design toolbox. I am trying to communicate with CAN TJA1154 which has an SPI interface. I use mpc5744 .I can't find a way to configure Tcsc and Tasc.What should I do?

12.jpg

1.png

1 解答
2,215 次查看
constantinrazva
NXP Employee
NXP Employee

Hello wbj5238@163.com ,

For now we don't have support for controlling PCS to SCK delay or other, but you can achieve that by inserting custom code, using NXP SDK. Let me know if you would be interested in adding this so I can walk you through the steps.

Kind regards,

Razvan.

在原帖中查看解决方案

0 项奖励
回复
6 回复数
2,216 次查看
constantinrazva
NXP Employee
NXP Employee

Hello wbj5238@163.com ,

For now we don't have support for controlling PCS to SCK delay or other, but you can achieve that by inserting custom code, using NXP SDK. Let me know if you would be interested in adding this so I can walk you through the steps.

Kind regards,

Razvan.

0 项奖励
回复
2,215 次查看
wbj5238
Contributor III

Thank you for your reply.I really want to know how to implement this function. Please tell me how to insert custom code.You'd better give me an example to  control PCS to SCK delay.

We are looking forward to your reply.

Kind regards,

Bingjian Wang.

0 项奖励
回复
2,215 次查看
constantinrazva
NXP Employee
NXP Employee

Hello wbj5238@163.com ,

For adding custom code to your Simulink models you have more options - one way of doing so you can find detailed in this article on our community - How to use your own C code in our Toolbox (Battery Management System example) .

I will cover another way of doing this, more suited in my opinion for this case where you only need to add 1 line.

Simulink has a block named System Start Function. You can use this block in the model you are using the SPI and there you can add the following line, in the System Start Function Exit Code section.

pastedImage_3.png

DSPI_MasterSetDelay(1, 100, 10, 20);

pastedImage_4.png

Let me go through the parameter list - you have, in order: instance, delayBetweenTransfers, delaySCKtoPCS, delayPCStoSCK 

So in my example, it will set the following:

1 - it will set the delay for SPI INSTANCE 1

100 - it will set the delay between transfer to a minimum of 100ms

10 - it will set the delay between SCK and PCS to minimum 10ms

20 - it will set the delay between the PCS and SCK to minimum 20ms

This is just an example, you will need to tune this parameters as for your needs.

One more thing I'd like to mention is that you will need to put it into the Function Exit Code section so it is guaranteed to be executed after the SPI has been initialized. If this were to be executed before, the application would crash.

This code is only executed once, in the initialization. If you want to add code that would be executed in the main loop, you would need to use a similar block name System Outputs Function.

You can read more details about the function in the NXP SDK doc (you can find it in {TOOLBOX_ROOT}\MPC_Platform_SDK\doc\Start_here.html).

pastedImage_7.png

Hope this helps.

Kind regards,

Razvan.

0 项奖励
回复
2,215 次查看
wbj5238
Contributor III

 Thank you for your reply. It works well. But I can't find the NXP SDK doc.There is no doc folder in {TOOLBOX_ROOT}\MPC_Platform_SDK.Can you send me a copy?

Kind regards,

Bingjian Wang.微信截图_20200818163156.png

2,215 次查看
constantinrazva
NXP Employee
NXP Employee

Hello wbj5238@163.com ,

It seems that the zip file is too large to be added here - I put this link instead.

Kind regards,

Razvan.

0 项奖励
回复
2,215 次查看
constantinrazva
NXP Employee
NXP Employee

Hello wbj5238@163.com ,

Sorry for the late reply - it seems that I no longer get emails for new replies on the community. I have attached here a zip containing the documentation for the SDK we are using in the MPC toolbox.

Kind regards,

Razvan.

0 项奖励
回复