Register Read/Write
Libraries:
STM32 Microcontroller Blockset /
Utilities
Simulink Support Package for Arduino Hardware /
Common
Description
You can use the Register Read/Write block in STM32™ Microcontroller Blockset to read data from and write data to various bit fields of registers.
The Register Read/Write block depends on CMSIS-SVD files provided by STM32CubeCLT. If STM32CubeCLT is not registered, configure it through the hardware setup screens by running the stm32setup command.
You can also use the block to specify bit positions using custom bits. It accepts a cell
array where each element is a 1x2 array that specifies the start bit and
end bit.
Ports
Output
The outports depends on the number of bit fields selected when registers are accessed using specified bits. In the selected bit fields parameter, option All is selected by default which is visible as the output port. If any other bit field is selected, the outports will change depending on the selected bit fields.
The bit field All will access the entire register.
Note
In selected bit field parameter, you can either select option All or other specific bit fields.
The output ports are dynamic and depends on the number bit field selected. When registers are accessed using custom bits, it depends upon the length of cell array specified in the parameter Bits to process.
Data Types: uint16 | uint32
Input
The inports depends on the number bit field selected when registers are accessed using specified bits.
In the Register bit fields parameter, option All is selected by default which is visible as the input port. If any other bit field is selected, the inports will change depending on the selected bit fields.
The bit field All will access the entire register.
Note
In Register bit field parameter, you can either select option All or other specific bit fields.
The input ports are dynamic and depends on the number bit field selected. When registers are accessed using custom bits, it depends upon the length of cell array specified in the parameter Bits to process.
Dependencies
To enable this port, set the Operation
parameter to Write.
Data Types: uint16 | uint32
Parameters
Select the STM32 target hardware for which you want to access the registers.
Select the device ID for the Register Read/Write block.
Select the peripheral for the selected target hardware.
Select the register for the selected peripheral. The options are populated based on the device ID and peripheral selected.
Select access register using specified bits or custom bits.
Specified bits: Selecting specified bits will display all the registers bits fields in a table format in the select bit fields parameter.
Custom bit fields: Select custom bit fields when you want to access the bits position manually.
Read operation - Select when you want to read data from registers. Read operation will generate the selected bit fields in the parameter Register bit fields or the Bits to process parameter as outports.
Write operation - Select when you want to write data to registers. Write operation will generate the selected bit fields in the parameter Register bit fields or the Bits to process parameter as inports.
Bit to process parameter accepts the cell array where each element is a
1x2 array where the smaller number indicates the start bit
and larger number indicates the end bit. For example, when the custom bit is in
the following format {[1], [2 3], [ 5 10 ], [11
16]} then:
From the custom bits mentioned, you are accessing four different set of bits I.e.
Bit 1
Bit 2 and Bit 3
Bit 5 to 10
Bit 11 to 16
The specified custom bit will generate four different ports(inport or outport)
The corresponding ports generated for each element of cell array will access the range of bits between the start bit and end bit.
Note
The bit position should be less than the length of the register field accessed. Also there should not be any overlap of bit positions between any 2 entries of cell array.
Dependencies
To enable this parameter, set the Access register
using parameter to Custom bits.
Select bit field you want to access. The options for register bit fields are populated based on the selection of peripheral and register parameter.
Dependencies
To enable this parameter, set the Access register
using parameter to Specified bits.
Specify how often (in seconds) the status of enabled output ports are read if no input ports are selected. Enter a value greater than zero. When you specify this parameter as -1, Simulink® determines the best sample time for the block based on the block context within the model.
Dependencies
To enable this port, set the Operation parameter to
Read.
Programmatic Use
Block Parameter:
SampleTime |
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Version History
Introduced in R2026a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)