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
main.cpp
00001 #include "mbed.h" 00002 #include <stm32l432xx.h> 00003 00004 00005 #define PWM_PERIOD_COUNT 1000 00006 00007 /* 00008 For register definitions see here: 00009 https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L432xC/device/stm32l432xx.h 00010 */ 00011 #define BUF_SIZE 99 00012 00013 // Using the MBED libraries to configure the PWM outputs (its easier than 00014 // calculating all of the register contents by hand) 00015 DigitalOut myled(LED1); 00016 PwmOut PhaATop(PA_8); 00017 00018 void initTimer1() 00019 { 00020 00021 TIM1->CR1 = 0; // make sure Counter is disabled before changing configuration 00022 TIM1->CR2 = 0; 00023 TIM1->PSC = 1; 00024 TIM1->ARR = PWM_PERIOD_COUNT; 00025 TIM1->CCR1 = PWM_PERIOD_COUNT/4; // 25% duty 00026 // Enable channel 1 00027 TIM1->CCER = 1; 00028 TIM1->SR = 0; // Clear flags. 00029 TIM1->CR1 |= 1; // enable counter 00030 00031 } 00032 00033 int main() { 00034 00035 initTimer1(); 00036 while(1) { 00037 00038 } 00039 }
Generated on Mon Jul 18 2022 03:50:42 by
1.7.2