• AVR Freaks

Hot!Simulink blockset: SPI configuration

Disco Stenz
New Member
  • Total Posts : 11
  • Reward points : 0
  • Joined: 2007/03/12 13:00:07
  • Location: Germany
  • Status: offline
2019/01/29 14:46:57 (permalink)

Simulink blockset: SPI configuration

Hi All,

Is there any documentation or user manual available on how to configure the SPI block properly ?
I'm trying to understand how to configure this block using the edit window along with the commands and key words provided.
All I want to do is, send 16 bit of data once during initialization phase and then another 16 bit periodically with
the sample time of 0.01 s.
My understanding is that I need 2 sets of commands separated by the key words 'Initial-Configuration' and
'Update-Configuration' to define what commands are executed only once and what are executed periodically
(see attached picture).
When I run the code and monitor the SPI signals with a logic analyzer, the tx data is not as expected.

There is also the keyword with 3 dashes '---' that has some effect I don't know.
Even the provided examples (UDB5_33FJ256GP710A_SPI_MPU6000_SensorTest.slx) are no help at all.
These examples don't use the key words. Instead they use 2 instances of the SPI configuraiton block with different sample rates (inf and 0.001).
Any suggestion is highly appreciated.
Best Regards from Troisdorf, Patrick

Attached Image(s)


1 Reply Related Threads

    • Total Posts : 360
    • Reward points : 5
    • Joined: 2007/03/31 07:38:15
    • Location: Bayonne, France
    • Status: offline
    Re: Simulink blockset: SPI configuration 2019/01/30 06:29:53 (permalink)
    Hi Patrick,
    The SPI block allows to modify the SPI peripheral settings in the middle of a sequence. This is useful for example when addressing sensors with various SPI clock capabilities. Sometimes, you have to initialize one sensor using a low SPI clock, then you can go with a higher clock.
    Thus Update-Configuration sequence allows to modify the SPI peripheral settings on the fly. 
    You do not need this feature. Remove all these Update-Configuration from your sequence.
    The dash '---' have no effects. Just for sequence clarity
    Then let go to a solution:
    Duplicate your SPI block. 
    In a first block, let the initialization sequence and set the sampling time to "inf" thus the block will be executed only once at startup.
    In a second block, let the sampling rate to 0.01s and let the sequence to be executed periodically.
    This is what you will find in examples provided.
    I would advise removing the "blocking mode" option. The peripheral driver is handled in background to free most of the CPU time to calculation.
    Jump to:
    © 2019 APG vNext Commercial Version 4.5