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.
Dependents: Mecatro_Gyro_Programme_Codeur_HC06
Diff: Device/FastPWM_LPC1768.cpp
- Revision:
- 0:731591dec10a
diff -r 000000000000 -r 731591dec10a Device/FastPWM_LPC1768.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Device/FastPWM_LPC1768.cpp Fri Apr 16 09:26:06 2021 +0000 @@ -0,0 +1,34 @@ +#ifdef TARGET_LPC176X + +#include "FastPWM.h" + +void FastPWM::initFastPWM( void ) { + //Set clock source + LPC_SC->PCLKSEL0|=1<<12; + bits = 32; +} + +void FastPWM::pulsewidth_ticks( uint32_t ticks ) { + *(_pwm.MR) = ticks; + LPC_PWM1->LER |= 1 << _pwm.pwm; +} + +void FastPWM::period_ticks( uint32_t ticks ) { + LPC_PWM1->MR0 = ticks; + LPC_PWM1->LER |= 1 << 0; +} + +uint32_t FastPWM::getPeriod( void ) { + return LPC_PWM1->MR0; +} + +//Maybe implemented later, but needing to change the prescaler for a 32-bit +//timer used in PWM mode is kinda unlikely. +//If you really need to do it, rejoice, you can make it run so slow a period is over 40,000 year +uint32_t FastPWM::setPrescaler(uint32_t reqScale) { + //Disable dynamic prescaling + dynamicPrescaler = false; + + return 1; +} +#endif \ No newline at end of file