Please enable JavaScript to view this site.

Navigation: ESP32 target > Utilities

IRQ custom code block

Scroll Prev Top Next More

How this block appears in a Simulink model?

irq_custom_code_block_1

What can be configured?

irq_custom_code_block_2

Configuration Parameter

Selectable Option/Value

Description

Mask display name

 

Enter display name which appears on the block display.

Path for include files (*.h)

 

Browse to the directory where the header files are located.

Path for source files (*.c)

 

Browse to the directory where the source files are located.

Included header file names

 

When the respective Edit button is pressed it will show the available header files specified in the include directory above. Select the header files that are needed for the block. When building, Waijung2 will automatically copy these files from the folder to the build folder.

Included source file names

 

When the respective Edit button is pressed it will show the available source files specified in the source directory above. Select the source files that are needed for the block. When building, Waijung2 will automatically copy these files from the folder to the build folder.

Initial function call string

 

Custom function call once MCU startup.

Enable function call string

 

Custom function call when the Block is enabled.

IRQ handler name

 

Function prototype of the interrupt handler (without semi-colon ";" )

Add additional content to the IRQ handler

on--off

Enable/disable the ability to customize the content of the IRQ handler. If this is Unchecked only the code generated from the Function-call subsystem which is connected to the IRQ output port, will be placed inside the IRQ handler.

IRQ handler content...

 

When Add additional content to the IRQ handler is Checked This text area could be used to customize the content of the IRQ handler. %[function-call subsystem] keyword should be placed to the point where the code generated from the Function-call subsystem which is connected to the IRQ output is placed.

Disable function call string

 

Custom function call script for when the block is disabled.

INPUT/ OUTPUT Port

Port Name

Port Type

Date Type

Description

IRQ

Scalar

Function-call

This output port should be connected to a Function-call subsystem

When to use this block?

When you want to add your own custom asynchronous (interrupt) C code to the system.

How does this block work?

See Basic Custom Code Block for an explanation of the Mask parameters of the block.

Demo

Demo file : esp32_irq_customcode_demo.slx

irq_custom_code_block_3

Description

This example shows how to use the IRQ Custom Code Block on ESP32 by implementing a timer interrupt. To observe the interrupt, a GPIO is toggled within the interrupt service routine.

Setup

First, download the irq_customcode_demo_lib.zip and extract the content. Copy the extracted folder to the same folder as the model file. Open the model file from Matlab. In the IRQ Custom Code block mask, browse the Path for include files (*.h) and Path for source files (*.c) to the extracted folder.

An oscilloscope should be connected to the GPIO pin specified in the model (in the example GPIO Pin 2 is selected.)

What should be happening?

After the model file is compiled and uploaded to the ESP32 board, the following output can be seen on the oscilloscope.

irq_custom_code_block_4

Copyright 2022 Aimagin Co.,Ltd. Rev.339