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.
Dependencies: mbed
Revision 0:18d54d648967, committed 2019-03-26
- Comitter:
- f3d
- Date:
- Tue Mar 26 12:37:18 2019 +0000
- Commit message:
- Simple single channel PWM for the STM32L432KC Nucleo board
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Mar 26 12:37:18 2019 +0000
@@ -0,0 +1,39 @@
+#include "mbed.h"
+#include <stm32l432xx.h>
+
+
+#define PWM_PERIOD_COUNT 1000
+
+/*
+For register definitions see here:
+https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L432xC/device/stm32l432xx.h
+*/
+#define BUF_SIZE 99
+
+// Using the MBED libraries to configure the PWM outputs (its easier than
+// calculating all of the register contents by hand)
+DigitalOut myled(LED1);
+PwmOut PhaATop(PA_8);
+
+void initTimer1()
+{
+
+ TIM1->CR1 = 0; // make sure Counter is disabled before changing configuration
+ TIM1->CR2 = 0;
+ TIM1->PSC = 1;
+ TIM1->ARR = PWM_PERIOD_COUNT;
+ TIM1->CCR1 = PWM_PERIOD_COUNT/4; // 25% duty
+ // Enable channel 1
+ TIM1->CCER = 1;
+ TIM1->SR = 0; // Clear flags.
+ TIM1->CR1 |= 1; // enable counter
+
+}
+
+int main() {
+
+ initTimer1();
+ while(1) {
+
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Mar 26 12:37:18 2019 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/aa5281ff4a02 \ No newline at end of file