How to transmit data using SPI in simulink? (S32K148EVB)

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to transmit data using SPI in simulink? (S32K148EVB)

2,406件の閲覧回数
sfard
Contributor I

Hi,

I am very new to NXP model-based design toolbox. I am trying to communicate with an accelerometer which has an SPI interface; however I have a hard time to send a signal to the slave. I created the attached model, but when I checked the MOSI signal on a Logic Analyzer, the signal is not what I am trying to send.

My other question is about the step size of the model. If I want to send the signal at 1MHZ to the salve, does it mean that I should reduce the step size of the Simulink model to 1e-6? 

pastedImage_1.jpg

ラベル(1)
1 返信

2,124件の閲覧回数
constantinrazva
NXP Employee
NXP Employee

Hello sfard@multimatic.com‌,

All the blocks that you add generate code for one / more of the following:

- initialization - code that is ran 1 time, at the beginning

- step - code that is ran continuously, at every step period - you can control this for every model - so to answer your question, as long as you have code that is generated inside the step function, if you want it to be called at frequency you should set the step size to 1/f, so 1e-6 would be right [Note: this step function is controlled via a LPIT channel]

- interrupts - ISR blocks generate functions that are called on certain events, and only then -- so event-driven code here [Note: code generated for the subsystem that is triggered by the ISR block goes inside these functions]

As for why it does not seem to work, I'll take a look and get back to you tomorrow as I'm working through my queue - but I decided to give a very short description to know what to expect from our toolbox.

Please let us know if you have other questions regarding the toolbox functionality.

Kind regards,

Razvan.