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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1,328 Views
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

Labels (1)
1 Reply

1,046 Views
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.