当前位置:网站首页>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语言之分草莓
- 2837xd code generation module learning (4) -- idle_ task、Simulink Coder
- 逆变器simulink模型——处理器在环测试(PIL)
- C语言之数据插入
- 2837xd 代码生成——补充(1)
- c语言编程题
- CKEditor 4.10.1 上传图片提示“不正确的服务器响应” 问题解决
- College Students' CET-4 and CET-6 composition template (self created version, successfully crossed CET-6)
- Operation and application of stack and queue
- 2837xd 代码生成——补充(2)
猜你喜欢

2837xd代码生成模块学习(3)——IIC、eCAN、SCI、Watchdog、eCAP模块

The latest progress and development trend of 2022 intelligent voice technology

Alibaba cloud ack introduction

How to use PHP spoole to implement millisecond scheduled tasks

虚幻——动画蓝图、状态机制作人物走跑跳动作

JDBC review

2837xd代码生成模块学习(2)——ADC、ePWM模块、Timer0

Idempotent design of Internet API interface

Kinect DK obtains color RGB images in cv:: mat format (used in openpose)

Typora installation package sharing
随机推荐
MySQL transaction
Memories of a chat
C language: making barrels
MySQL index
C language strawberry
YOLO物体识别,生成数据用到的工具
阿里云短信服务
Inverter Simulink model -- processor in the loop test (PIL)
Required request body is missing: (cross domain problem)
JDBC review
图像识别-数据采集
阿里云ack介绍
Read Day5 30 minutes before going to bed every day_ All key values in the map, how to obtain all value values
C语言之判断直角三角形
kinect dk 获取CV::Mat格式的彩色RGB图像(openpose中使用)
2837xd代码生成模块学习(1)——GPIO模块
2837xd code generation module learning (4) -- idle_ task、Simulink Coder
三相并网逆变器PI控制——离网模式
滲透測試的介紹和防範
虚幻——动画蓝图、状态机制作人物走跑跳动作