Use SoC Blockset Pass-Through Block Simulation
When you use the SoC Blockset™ product, STM32F4xx board blocks provide a pass-through signal in simulation that enables the SoC Blockset peripheral interface blocks to provide data during simulation.
Digital Port Read
To use a Digital Port Read block in simulation, follow these steps.
Create or open a Simulink® model using an STM32F4xx based hardware board.
Open the
stm32f4xxblockslib
block library and add the Digital Port Read block to the model.Open the block mask and select the Enable simulation parameter. The block generates a new input port, Pin(s) Msg.
Add a Digital IO Interface (SoC Blockset) block from SoC Blockset to the model and connect that block to the Digital Port Read block.
Add appropriate source and sink blocks to the model.
To simulate the model, on the Simulation tab, click Run. The output signal of the Digital Port Read block matches the input from the Digital IO Interface block in simulation.
Note
Code generation automatically eliminates the Digital IO Interface block leaving the expected driver code behavior.
Digital Port Write
To use a Digital Port Write block in simulation, follow these steps.
Create or open a Simulink model using an STM32F4xx based hardware board.
Open the
stm32f4xxblockslib
block library and add the Digital Port Write block to the model.Open the block mask and select the Enable simulation parameter. The block generates a new output port, Pin(s) Msg.
Add a Digital IO Interface (SoC Blockset) block from SoC Blockset to the model and connect that block to the Digital Port Write block.
Add appropriate source and sink blocks to the model.
To simulate the model, on the Simulation tab, click Run. The output signal of the Digital Port Write block matches the output from the Digital IO Interface block in simulation.
Note
Code generation automatically eliminates the Digital IO Interface block leaving the expected driver code behavior.
ADC Port Read
To use a Analog to Digital Converter block in simulation, follow these steps.
Create or open a Simulink model using an STM32F4xx based hardware board.
Open the
stm32f4xxblockslib
block library and add the Analog to Digital Converter block to the model.Open the block mask and select the Enable simulation parameter. The block generates a new input port, Pin(s) Msg.
Add an ADC Interface (SoC Blockset) block from SoC Blockset to the model and connect that block to the Analog to Digital Converter block.
Note
The number of channels that are selected in the ADC Interface block must match the Number of Conversions parameter in the STMicroelectronics® driver block.
Add appropriate source and sink blocks to the model.
To simulate the model, on the Simulation tab, click Run. The output signal of the Analog to Digital Converter block matches the converted input from the ADC Interface block in simulation.
Note
Code generation automatically eliminates the ADC Interface block leaving the expected driver code behavior.
PWM Port Write
To use a PWM Output block in simulation, follow these steps.
Create or open a Simulink model using an STM32F4xx based hardware board.
Open the
stm32f4xxblockslib
block library and add the PWM Output block to the model.Open the block mask and select the Enable simulation parameter. The block generates a new output port, Msg CH1.
Add a PWM Interface (SoC Blockset) block to the model and connect it to the Digital Port Write block.
Note
On the PWM Output block, the Duty cycle unit parameter only supports
Percentage
.Add appropriate source and sink blocks to the model.
To simulate the model, on the Simulation tab, click Run. The output signal of the PWM Interface block matches the input from the source block in simulation.
Note
In code generation, the PWM Interface block is automatically eliminated, leaving the expected driver code behavior.
Interrupts
To use a Hardware Interrupt block in simulation, follow these steps.
Create or open a Simulink model using an STM32F4xx based hardware board.
Open the
stm32f4xxblockslib
block library and add the Hardware Interrupt block to the model.Open the block mask and select the Enable simulation parameter. The block generates a new input port,
name
Event Task, wherename
is the name of the interrupt.Add a Function-Call Generator block to the model and connect it to the Hardware Interrupt block.
Connect the Hardware Interrupt to an appropriate Function-Call Subsystem block.
To simulate the model, on the Simulation tab, click Run. The Function-Call Subsystem block executes each time the Function-Call Generator block triggers a function-call.
See Also
Digital Port Read | Digital Port Write | Analog to Digital Converter | PWM Output | Hardware Interrupt