PWMTimerWFF3.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024-2025, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*!*****************************************************************************
33  * @file PWMTimerWFF3.h
34  * @brief PWM driver implementation for Wi-Fi F3 devices
35  *
36  * # Overview #
37  * The general PWM API should be used in application code, i.e. PWM_open()
38  * should be used instead of PWMTimerWFF3_open(). The board file will define the device
39  * specific config, and casting in the general API will ensure that the correct
40  * device specific functions are called.
41  *
42  * # General Behavior #
43  * Before using PWM on WFF3:
44  * - The Timer HW is configured and system dependencies (for example IOs,
45  * power, etc.) are set by calling PWM_open().
46  *
47  * # Error handling #
48  * If unsupported arguments are provided to an API returning an error code, the
49  * PWM configuration will *not* be updated and PWM will stay in the mode it
50  * was already configured to.
51  *
52  * # Power Management #
53  * The SimpleLink power management framework will try to put the device into the most
54  * power efficient mode whenever possible. Please see the technical reference
55  * manual for further details on each power mode.
56  *
57  * The PWMTimerWFF3.h driver is not explicitly setting a power constraint when the
58  * PWM is running to prevent standby as this is assumed to be done in the
59  * underlying GPTimer driver.
60  * The following statements are valid:
61  * - After PWM_open(): The device is still allowed to enter Sleep. When the
62  * device is active the underlying GPTimer peripheral will
63  * be enabled and clocked.
64  * - After PWM_start(): The device can only go to Idle power mode since the
65  * system clock is needed for PWM operation:
66  * - After PWM_stop(): Conditions are equal as for after PWM_open
67  * - After PWM_close(): The underlying GPTimer is turned off and the device
68  * is allowed to go to sleep.
69  *
70  * # Accuracy #
71  * The PWM output period and duty cycle are limited by the underlying timer.
72  * For GPT counter widths see @ref ti_drivers_GPTimerWFF3_PeripheralProperties
73  * "GPT peripheral properties".
74  *
75  * The frequency of the underlying timer counter can be divided by configuring
76  * the preScalerDivision element of the @ref PWMTimerWFF3_HwAttrs struct.
77  * This configuration can be used to extend the PWM signal period but will
78  * decrease the accuracy.
79  * The minimum obtainable PWM signal frequency is dependent on the width of
80  * the counter for the GPT peripheral used and the configured preScalerDivision
81  * value. When using either the GPT0 or the GPT1 peripheral with the default
82  * preScalerDivision value of 1, the minimal frequency is
83  * 40MHz / (2^32-1) = 0.0093Hz (107.374sec).
84  *
85  * When using high output frequencies the duty cycle resolution is reduced
86  * correspondingly. For a 20MHz PWM only a 0%/50%/100% duty is available as
87  * the timer uses only counts 0 and 1.
88  * Similarly for a 10MHz period the duty cycle will be limited to a 12.5%
89  * resolution.
90  *
91  * @note The PWM signals are generated by the GPT peripheral using the
92  * timer clock which is dependent on the system clock.
93  *
94  * # Limitations #
95  * - The PWM output can currently not be synchronized with other PWM outputs.
96  * - The PWM driver does not support updating duty and period using DMA.
97  * - Attempts to change both the period and duty cycle at the same time
98  * for an active PWM signal, can cause pulses to be too long or short if
99  * the change is applied close to the end of the current counter cycle.
100  * This does not apply to changing only the period or only the duty cycle,
101  * as any of these separate changes will take effect on the next counter cycle.
102  * # PWM usage #
103  *
104  * ## Basic PWM output ##
105  * The below example will output a 8MHz PWM signal with 50% duty cycle.
106  * @code
107  * PWM_Handle pwmHandle;
108  * PWM_Params params;
109  *
110  * PWM_Params_init(&params);
111  * params.idleLevel = PWM_IDLE_LOW;
112  * params.periodUnits = PWM_PERIOD_HZ;
113  * params.periodValue = 8e6;
114  * params.dutyUnits = PWM_DUTY_FRACTION;
115  * params.dutyValue = PWM_DUTY_FRACTION_MAX / 2;
116  *
117  * pwmHandle = PWM_open(CONFIG_PWM0, &params);
118  * if(pwmHandle == NULL) {
119  * Log_error0("Failed to open PWM");
120  * Task_exit();
121  * }
122  * PWM_start(pwmHandle);
123  * @endcode
124  *
125  *
126  *******************************************************************************
127  */
128 #ifndef ti_drivers_pwm_PWMTimerWFF3__include
129 #define ti_drivers_pwm_PWMTimerWFF3__include
130 
131 #include <stdint.h>
132 #include <stdbool.h>
133 
134 #include <ti/drivers/PWM.h>
136 
137 #ifdef __cplusplus
138 extern "C" {
139 #endif
140 
141 /* PWM function table pointer */
143 
150 typedef struct PWMTimerWFF3_HwAttrs
151 {
152  uint8_t gpTimerInstance;
153  uint16_t preScalerDivision;
155 
165 typedef struct PWMTimerWFF3_Object
166 {
167  uint32_t periodValue;
168  uint32_t periodCounts;
169  uint32_t dutyValue;
170  uint32_t dutyCounts;
176  bool isOpen;
177  bool isRunning;
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 #endif /* ti_drivers_pwm_PWMTimerWFF3__include */
GPTimerWFF3_Handle hTimer
Definition: PWMTimerWFF3.h:171
uint32_t periodValue
Definition: PWMTimerWFF3.h:167
PWM_Duty_Units
PWM duty cycle unit definitions. Refer to device specific implementation if using PWM_DUTY_COUNTS (ra...
Definition: PWM.h:306
bool isOpen
Definition: PWMTimerWFF3.h:176
PWMTimerWFF3 Object.
Definition: PWMTimerWFF3.h:165
const PWM_FxnTable PWMTimerWFF3_fxnTable
uint16_t preScalerDivision
Definition: PWMTimerWFF3.h:153
Pulse Width Modulation (PWM) driver.
GPTimer Global configuration.
Definition: GPTimerWFF3.h:809
PWM_Period_Units
PWM period unit definitions. Refer to device specific implementation if using PWM_PERIOD_COUNTS (raw ...
Definition: PWM.h:294
PWM_Period_Units periodUnit
Definition: PWMTimerWFF3.h:172
GPTimerWFF3_ChannelNo
Definitions for supported GPTimer channel numbers.
Definition: GPTimerWFF3.h:283
The definition of a PWM function table that contains the required set of functions to control a speci...
Definition: PWM.h:409
struct PWMTimerWFF3_Object PWMTimerWFF3_Object
PWMTimerWFF3 Object.
GPTimerWFF3_ChannelNo chNumber
Definition: PWMTimerWFF3.h:174
GPTimer driver implementation for Wi-Fi F3 devices.
PWM_Duty_Units dutyUnit
Definition: PWMTimerWFF3.h:173
uint32_t dutyCounts
Definition: PWMTimerWFF3.h:170
PWMTimerWFF3 Hardware attributes.
Definition: PWMTimerWFF3.h:150
uint8_t gpTimerInstance
Definition: PWMTimerWFF3.h:152
uint32_t dutyValue
Definition: PWMTimerWFF3.h:169
struct PWMTimerWFF3_HwAttrs PWMTimerWFF3_HwAttrs
PWMTimerWFF3 Hardware attributes.
PWM_IdleLevel
Idle output level when PWM is not running (stopped / not started).
Definition: PWM.h:321
bool isRunning
Definition: PWMTimerWFF3.h:177
uint32_t periodCounts
Definition: PWMTimerWFF3.h:168
PWM_IdleLevel idleLevel
Definition: PWMTimerWFF3.h:175
© Copyright 1995-2026, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale