Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
CT32B0_PWM.cpp File Reference
Small driver to user CT32B0 for PWM. More...
Go to the source code of this file.
| static volatile uint8_t | stage = 0 |
| Stage identifier for mat2/3 swap. | |
| static volatile uint32_t | period = 0 |
| PWM Period register. | |
| static volatile uint32_t | mat [4] |
| PWM Mat output registers. | |
| static volatile uint32_t | default_period_us |
| Given period in us. | |
| static volatile uint32_t | defaultstate |
| Default PWM state on init. | |
| void | CT32B0_initpwm (uint32_t period_us, uint32_t defaultstate) |
| Initializes PWM. | |
| void | CT32B0_reinitpwm (void) |
| Re-Initializes PWM. | |
| void | CT32B0_start (void) |
| Start PWM. | |
| void | CT32B0_deinit (uint8_t state) |
| Stop PWM. | |
| void | CT32B0_stage (uint8_t stagearg) |
| Set stage. | |
| void | CT32B0_reload_mat (void) |
| Reload all match compare registers. | |
| void | CT32B0_set (uint8_t matnr, uint32_t value) |
| Set channel PWM. | |
| void | CT32B0_wait_refresh (void) |
| Wait for timer to reach 0. | |
Detailed Description
Small driver to user CT32B0 for PWM.
- Date:
- Oktober 2013
- Note:
- Since only one timer is used to supply 4 PWM channels a problem occurs because CT32B0 only support 3 PWM channels.
Since this software is designed for a H-Bridge implementation only 2 of 4 PWM channels are required to be active simultaneously.
This is where the stage variable comes in: Stage 0: PWM enabled on MAT 0, MAT 1 and MAT 2. Stage 1: PWM enabled on MAT 0, MAT 1 and MAT 3. Unused MAT outputs will be pullled down.
Definition in file CT32B0_PWM.cpp.
Function Documentation
| void CT32B0_deinit | ( | uint8_t | state ) |
Stop PWM.
- Parameters:
-
[in] state PWM output state when pwm disabled
Definition at line 111 of file CT32B0_PWM.cpp.
| void CT32B0_initpwm | ( | uint32_t | period_us, |
| uint32_t | defaultstate | ||
| ) |
Initializes PWM.
- Parameters:
-
[in] period_us Period in us, when prescaler is 48 [in] defaultstate State after initializing
- Note:
- Run Start() to start pwm
Definition at line 40 of file CT32B0_PWM.cpp.
| void CT32B0_reinitpwm | ( | void | ) |
Re-Initializes PWM.
Definition at line 96 of file CT32B0_PWM.cpp.
| void CT32B0_reload_mat | ( | void | ) |
Reload all match compare registers.
Definition at line 158 of file CT32B0_PWM.cpp.
| void CT32B0_set | ( | uint8_t | matnr, |
| uint32_t | value | ||
| ) |
Set channel PWM.
Definition at line 171 of file CT32B0_PWM.cpp.
| void CT32B0_stage | ( | uint8_t | stagearg ) |
| void CT32B0_start | ( | void | ) |
Start PWM.
Definition at line 103 of file CT32B0_PWM.cpp.
| void CT32B0_wait_refresh | ( | void | ) |
Wait for timer to reach 0.
Definition at line 179 of file CT32B0_PWM.cpp.
Variable Documentation
volatile uint32_t default_period_us [static] |
Given period in us.
Definition at line 30 of file CT32B0_PWM.cpp.
volatile uint32_t defaultstate [static] |
Default PWM state on init.
Definition at line 31 of file CT32B0_PWM.cpp.
volatile uint32_t mat[4] [static] |
PWM Mat output registers.
Definition at line 29 of file CT32B0_PWM.cpp.
volatile uint32_t period = 0 [static] |
PWM Period register.
Definition at line 28 of file CT32B0_PWM.cpp.
volatile uint8_t stage = 0 [static] |
Stage identifier for mat2/3 swap.
Definition at line 27 of file CT32B0_PWM.cpp.
Generated on Mon Jul 18 2022 01:28:39 by
1.7.2