File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
hal/targets/hal/TARGET_NXP/TARGET_LPC81X Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -152,10 +152,18 @@ void pwmout_write(pwmout_t* obj, float value) {
152
152
uint32_t t_off = (uint32_t )((float )(obj -> pwm -> MATCHREL [0 ].U ) * value );
153
153
obj -> pwm -> MATCHREL [(obj -> pwm_ch ) + 1 ].U = t_off ; // New endtime
154
154
155
+ // Clear OxRES (conflict resolution register) bit first, effect of simultaneous set and clear on output x
156
+ int offset = (obj -> pwm_ch * 2 );
157
+ obj -> pwm -> RES &= ~(0x3 << offset );
158
+
155
159
if (value == 0.0f ) { // duty is 0%
160
+ // Clear output
161
+ obj -> pwm -> RES |= (0x2 << offset );
156
162
// Set CLR event to be same as SET event, makes output to be 0 (low)
157
163
obj -> pwm -> OUT [(obj -> pwm_ch )].CLR = (1 << 0 );
158
164
} else {
165
+ // Set output
166
+ obj -> pwm -> RES |= (0x1 << offset );
159
167
// Use normal CLR event (current SCT ch + 1)
160
168
obj -> pwm -> OUT [(obj -> pwm_ch )].CLR = (1 << ((obj -> pwm_ch ) + 1 ));
161
169
}
You can’t perform that action at this time.
0 commit comments