Hi, @amir1374,
Thank you for using our toolbox.
A PWM signal can be read using a variety of techniques. We may have some applications that might help you in achieving your goal. Along with these examples, I'll make some suggestions that may be useful to you:
1. Use DIO (Digital Input-Output module)
You can read digital signals connected to your board using the DIO block from our toolbox, as you suggested. The DIO group is located within the S32K3_Examples folder and contains various applications that demonstrate the process of writing and reading digital signals. You can achieve your goal by connecting your PWM signal to a board pin configured for the DIO component, as well as performing some computation to determine the HIGH and LOW times of the signal. The GPT (general purpose timer) block can be used to calculate the ticks between the HIGH and LOW signal times.
2. Use ICU (Input Capture Unit)
The best component that fits your purpose is the ICU component that is specialized in reading signals characteristics.
Currently, the MBDT for S32K3xx does not support ICU but we will take these into consideration for our future planning, however, taking into consideration that we include the entire RTD drivers package, you can use the component in our toolbox.
- You need to add and configure it first in the external configuration tool.
- Now that the configuration of the component is completed, to call its API functions for implementing your application, you could start by using the custom code block provided by Simulink. Please note that you will also need to include the header files for the component to be able to use specific functions.
- Also, you will need to call the initialization function for the added component.
- Moreover, you have a good example for your use in s32k3xx_isr_custom_code_ebt, where the ICU component is used with custom code.
The RTD documentation goes into great detail about DIO or ICU configuration and usage. The Code Generation section of each block help contains a link to the component's RTD User Manual and, in some cases, a link to the AUTOSAR Specification if the component is AUTOSAR compliant.
Hope that my suggestions helped you.
Best regard,
Victor