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.
Fork of mbed-dev by
Diff: targets/hal/TARGET_NXP/TARGET_LPC81X/pwmout_api.c
- Revision:
- 137:28723fa54344
- Parent:
- 108:e46d5651bd87
- Child:
- 144:ef7eb2e8f9f7
--- a/targets/hal/TARGET_NXP/TARGET_LPC81X/pwmout_api.c Mon May 23 14:15:16 2016 +0100
+++ b/targets/hal/TARGET_NXP/TARGET_LPC81X/pwmout_api.c Mon May 23 15:15:12 2016 +0100
@@ -152,10 +152,18 @@
uint32_t t_off = (uint32_t)((float)(obj->pwm->MATCHREL[0].U) * value);
obj->pwm->MATCHREL[(obj->pwm_ch) + 1].U = t_off; // New endtime
+ // Clear OxRES (conflict resolution register) bit first, effect of simultaneous set and clear on output x
+ int offset = (obj->pwm_ch * 2);
+ obj->pwm->RES &= ~(0x3 << offset);
+
if (value == 0.0f) { // duty is 0%
+ // Clear output
+ obj->pwm->RES |= (0x2 << offset);
// Set CLR event to be same as SET event, makes output to be 0 (low)
obj->pwm->OUT[(obj->pwm_ch)].CLR = (1 << 0);
} else {
+ // Set output
+ obj->pwm->RES |= (0x1 << offset);
// Use normal CLR event (current SCT ch + 1)
obj->pwm->OUT[(obj->pwm_ch)].CLR = (1 << ((obj->pwm_ch) + 1));
}
