当前位置:网站首页>2837xd code generation module learning (3) -- IIC, ECAN, SCI, watchdog, ECAP modules
2837xd code generation module learning (3) -- IIC, ECAN, SCI, watchdog, ECAP modules
2022-07-02 09:55:00 【Quikk】
Module learning
Model links : link
1 IIC modular
1.1 Model function
Implementation to address 0x50 Write data from the slave (100 ,1), Then detect when the written data changes , Begin with ( The slave address is 0x50) Space to read the data just written .
It can be seen that the above figure is mainly divided into three parts :1. Definition of global variables .2. Write data .3. Reading data .
1. Global variables are defined using Data Store Memory modular , There is also Data Store Write and Data Store Read The module is used to read and write the open space , Its Data Store Memory Set as follows :
2. The write data sub module is shown in the figure below , What we use here is Enable Subsystem, And Trigger Subsystem The difference is Enable Subsystem yes Level trigger and Trigger Subsystem yes edge-triggered . Here is to splice the data and address, and then give Transmit Module to send .
3. The read data module is sent to the device address , then do…while Wait in the loop I2caRegs.I2CFFTX.all The sign is ready (TXFFST The length of received data will be displayed in ), Then enable the receiving module to receive data , Then store the data in global variables A and B in
do…while Situation in the module :
2 eCAN modular
eCAN The module is divided into receiving module and sending module , The parameters of the receiving module are as follows ( At present, enter the receive interrupt service function to execute , There's something else .):
eCAN The receiving module comes with an interface that triggers the execution of a function , In modeling , I connected to a LED Flipped sub modules . That is, after receiving the message ,LED It's going to flip .
eCAN The parameters of the sending module are as follows , because CAN The largest data frame is 8 Byte length , So we must pay attention that the largest data given to him is an unsigned 64 A data .
Here, the ports for data transmission of octet transmission and four byte transmission are built . Pay attention here , Need modification Constant The output type of the module .
After that, it needs to be in Configuration Parameters Chinese vs eCAN_A Make relevant settings :
2.1 experimental result
The hardware used here is USB turn CAN, The software is CANTest The test conducted by the upper computer , You can see the sending ID by 0x01 The data of ,dsp After receiving LED Flip . Then the observation data is big / This point of the phenomenon of small end storage needs attention . The data format can also be clearly seen in the serial port debugging assistant , Starting standard + Data length +ID+ The format of the data .
3 SCI modular
The interrupt function is SCIA Interrupt service number of :9.1. The interior is as follows
This is achieved SCI Receive interrupt , Return the sent data .
SCI The module also has two modules, receive and send : Receiving module configuration :
Send module configuration :
After that, it needs to be in Configuration Parameters Chinese vs SCI_A Make relevant settings :
3.1 experimental result
You can see that the sent data can be returned normally .
4 Watchdog module
The watchdog module can effectively prevent the program from flying in the actual program . stay Simulink You need to start with Configuration Parameters The relevant settings are made in , The cycle in the figure below is the watchdog overflow time ( That is, if there is no dog feeding operation within this time , Will reset the entire system ).
Corresponding in Simulink There is ,Watchdog modular ( For feeding dogs ) Here the -1 It means the same as the simulation step time . Dog feeding time can also be set here , However, it must be noted that the dog feeding time must be less than that in Target hardware resources Time set in , In this way, it is normal to feed dogs .
5 eCAP modular
eCAP The mode is input capture module , It can be used to test the signal cycle and other information . It can also be used as APWM Mode output PWM wave .
Pictured above , stay Configuration Parameters Can be set in eCAP Patterns and APWM Pins of the model .
5.1 APWM Pattern
Make corresponding settings in the tab .
experimental result :
5.2 eCAP Pattern
The tab can be set as follows , At this time, the module has an output interface TS, If set as shown in the figure , The first time to capture the rising edge , Second capture falling edge , Capture the rising edge for the third time . That is, the duty cycle of the square wave signal can be calculated . Then output is directly utilized DeMux The module can get the counter array of three times respectively , Array times TCLK Get time .
边栏推荐
- C语言之判断直角三角形
- BugkuCTF-web24(解题思路及步骤)
- 2837xd code generation - stateflow (2)
- Error reporting on the first day of work (incomplete awvs unloading)
- Int to string, int to qstring
- 在SQL注入中,为什么union联合查询,id必须等于0
- Introduction to go language
- What is the function of laravel facade
- Creation and jump of activity
- 攻防世界-Web进阶区-unserialize3
猜你喜欢
2837xd code generation - Supplement (2)
Illusion -- Animation blueprint, state machine production, character walking, running and jumping action
How to use PHP spoole to implement millisecond scheduled tasks
Navicat remote connection MySQL reports an error 1045 - access denied for user 'root' @ '222.173.220.236' (using password: yes)
Image recognition - data annotation
Mysql索引
The latest progress and development trend of 2022 intelligent voice technology
Required request body is missing:(跨域问题)
2837xd code generation - stateflow (4)
2837xd代码生成模块学习(2)——ADC、ePWM模块、Timer0
随机推荐
2837xd Code Generation - stateflow (4)
上班第一天的报错(Nessus安装winpcap报错)
三相逆变器离网控制——PR控制
记录一下初次使用Xray的有趣过程
Cmake command - Official Document
Summary of demand R & D process nodes and key outputs
MySQL index
C语言之判断直角三角形
Memories of a chat
保存视频 opencv::VideoWriter
c语言编程题
BugkuCTF-web21(详细解题思路及步骤)
道阻且长,行则将至
JDBC review
C语言之数据插入
【UE5】蓝图制作简单地雷教程
阿里云短信服务
2837xd code generation - stateflow (3)
Tinyxml2 reading and modifying files
2837xd 代码生成——补充(2)