background image

IMPORTANT NOTICE

The information given in this document shall in no

event be regarded as a guarantee of conditions or

characteristics (“Beschaffenheitsgarantie”) .
With respect to any examples, hints or any typical

values stated herein and/or any information

regarding the application of the product, Infineon

Technologies hereby disclaims any and all

warranties and liabilities of any kind, including

without limitation warranties of non-infringement

of intellectual property rights of any third party.
In addition, any information given in this

document is subject to customer’s compliance

with its obligations stated in this document and

any applicable legal requirements, norms and

standards concerning customer’s products and

any use of the product of Infineon Technologies in

customer’s applications.
The data contained in this document is exclusively

intended for technically trained staff. It is the

responsibility

of

customer’s

technical

departments to evaluate the suitability of the

product for the intended application and the

completeness of the product information given in

this document with respect to such application.

For further information on the product,

technology, delivery terms and conditions and

prices please contact your nearest Infineon

Technologies office (

www.infineon.com

).

WARNINGS

Due to technical requirements products may

contain dangerous substances. For information

on the types in question please contact your

nearest Infineon Technologies office.
Except as otherwise explicitly approved by

Infineon Technologies in a written document

signed by authorized representatives of Infineon

Technologies, Infineon Technologies’ products

may not be used in any applications where a

failure of the product or any consequences of the

use thereof can reasonably be expected to result

in personal injury.

Edition 2020-01

Published by

Infineon Technologies AG

81726 Munich, Germany

© 2020 Infineon Technologies AG.

All Rights Reserved.

Do you have a question about this

document?

Email: 

[email protected]

Document reference

CCU6_PWM_Capture_1

Trademarks

All referenced product or service names and trademarks are the property of their respective owners.

Содержание CCU6 PWM Capture 1

Страница 1: ...AURIX TC2xx Microcontroller Training V1 0 0 CCU6_PWM_Capture_1 CCU6 PWM signal capture Please read the Important Notice and Warnings at the end of this document ...

Страница 2: ...gnal and calculate its frequency and duty cycle A simple PWM signal is generated by toggling a port pin The resulting PWM frequency and duty cycle is measured by the Capture Control Unit 6 CCU6 2 2020 01 17 Copyright Infineon Technologies AG 2020 All rights reserved ...

Страница 3: ... with three capture compare channels and a timer T13 Block with one compare channel Among other features the CCU6 has the capability to capture external input signals In this example the Input Capture Unit and the timer T12 of the CCU6 module are used to capture a PWM signal and calculate its frequency and duty cycle 3 2020 01 17 Copyright Infineon Technologies AG 2020 All rights reserved ...

Страница 4: ...as been developed for the board KIT_AURIX_TC297_TFT_BC Step Connect the two pins P02 1 PWM signal and P02 0 CC60 input to each other PWM signal input pin A of CC60 4 2020 01 17 Copyright Infineon Technologies AG 2020 All rights reserved ...

Страница 5: ...u_initModuleConfig For capturing a PWM signal no changes to the default configuration are required therefore the module can be initialized with the default configuration by calling the function IfxCcu6_Icu_initModule After the successful initialization of the CCU6 module its handle structure IfxCcu6_Icu contains the configured capture frequency of the timer For further usage this parameter is stor...

Страница 6: ...y selecting the source the service request output its priority and the service provider In this example the CCU6 service request 0 is configured to trigger an interrupt on every rising edge at the input pin of capture compare channel 0 CC60 To calculate the duty cycle a shadow register filled when a falling edge occurs is used Therefore no interrupt is required for the falling edge Interrupt2 stru...

Страница 7: ...is selected multiInputCaptureEnabled Disable the multiple input capture mode After the initialization of the channel with the user configuration which is applied by calling the function IfxCcu6_Icu_initChannel the capture process is started by setting the run bit T12R through the function IfxCcu6_Icu_startCapture All functions and structures used for the configuration of the CCU6 channel can be fo...

Страница 8: ...upt on every rising edge at the input pin of capture compare channel 0 used to calculate the time between two rising edges and the PWM frequency the time between a rising edge and the falling edge and the PWM duty cycle The method implementing each ISR needs to be assigned a priority and a CPU core responsible for its execution This is done with the macro IFX_INTERRUPT isr vectabNum priority 8 202...

Страница 9: ... the timer T12 the time between two rising edges The PWM duty cycle is calculated as a percentage value between the amount of increments of the timer T12 between the rising and falling edge high level time and the total amount of increments between two rising edges period An overflow of timer T12 triggers the second interrupt CCU6_ICU_Period_Match_Int_Handler which is used for counting the overflo...

Страница 10: ... that the value of timer T12 is incremented every 1 28 µs 1 781250 Hz Overflow of timer T12 occurs after 0 084 s 65534 1 28 µs The total amount of increments can be calculated by comparing the current value of timer T12 with the value of timer T12 one PWM period ago e g 1000 Interrupt on each rising edge T12 count value is incremented with frequency of timer T12 PWM signal t t Period of timer T12 ...

Страница 11: ...culation of total amount of increments Increments before the first overflow 65534 1000 64534 Increments during the second and the last overflow 5 1 65534 262136 Increments after the last overflow 63955 Total amount of increments 64534 262136 63955 390625 Calculation of increments during high level time Increments before the first overflow 65534 1000 64534 Increments during the second and the last ...

Страница 12: ...ncrements Part 3 63955 increments after the last overflow 63955 counter value at rising edge Total increments between two rising edges 64534 262136 63955 390625 T12 count between 0 and 65534 PWM signal 2 Hz Period of PWM signal 0 5 s t t Interrupt on previous rising edge T12 counter value 1000 T12 counter value 63955 Interrupt on current rising edge 5 overflows of timer T12 during one PWM period P...

Страница 13: ... total increments Part 3 63955 increments after the last overflow 63955 counter value at rising edge Total increments between the rising and falling edges 64534 65534 65244 195312 T12 count between 0 and 65534 PWM signal 2 Hz Period of PWM signal 0 5 s t t Interrupt on previous rising edge T12 counter value 1000 T12 counter value 65244 Interrupt on current rising edge 2 overflows of timer T12 duri...

Страница 14: ...rt_State_low For changing the frequency and duty cycle of the generated PWM signal the global parameter g_generatedPwmFreq_Hz and g_generatedDutyCycle can be modified Depending on the frequency and duty cycle set to 50 two timeout values are calculated by software and passed to the wait function The two wait function calls are succeeding the two calls of the function IfxPort_setPinState The parame...

Страница 15: ...imilar to the parameter g_generatedPwmFreq_Hz 3 Change the parameter g_generatedPwmFreq_Hz and check if g_measuredPwmFreq_Hz changes accordingly 4 Check the parameter g_measuredPwmDutyCycle in the debugger the debug session should be suspended previously Its value should be similar to the parameter g_generatedPwmDutyCycle 5 Change the parameter g_generatedDutyCycle and check if g_measuredDutyCycle...

Страница 16: ... www infineon com aurix expert training AURIX Development Studio is available online https www infineon com aurixdevelopmentstudio Use the Import function to get access to more code examples For questions and support use the AURIX Forum https www infineonforums com forums 13 Aurix Forum 16 2020 01 17 Copyright Infineon Technologies AG 2020 All rights reserved ...

Страница 17: ...f the product for the intended application and the completeness of the product information given in this document with respect to such application For further information on the product technology delivery terms and conditions and prices please contact your nearest Infineon Technologies office www infineon com WARNINGS Due to technical requirements products may contain dangerous substances For inf...

Отзывы: