{"id":249,"date":"2017-11-23T00:13:34","date_gmt":"2017-11-22T23:13:34","guid":{"rendered":"http:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=249"},"modified":"2023-03-05T00:03:41","modified_gmt":"2023-03-04T23:03:41","slug":"25-pwm-library-stm32f4","status":"publish","type":"page","link":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=249","title":{"rendered":"25-PWM-Library (STM32F4)"},"content":{"rendered":"<p><div id=\"nav-below\" class=\"navigation\"><div class=\"nav-previous\"><a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=247\" title=\"24-DAC_DMA-Library (STM32F4)\"><span class=\"meta-nav\">\u2190<\/span> 24-DAC_DMA-Library (STM32F4)<\/a><\/div><\/div><!-- #nav-below --><div id=\"nav-below\" class=\"navigation\"><div class=\"nav-next\"><a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=251\" title=\"26-Logview-Library (STM32F4)\">26-Logview-Library (STM32F4) <span class=\"meta-nav\">&rarr;<\/span><\/a><\/div><\/div><!-- #nav-below --><\/p>\n<p>Um die PWM-Funktionen vom STM32F4 benutzen zu k\u00f6nnen, habe ich diese Library(s) geschrieben.<\/p>\n<p>Der STM32F4 hat sehr viele Timer (14) und fast alle haben eine PWM funktion. Um den Aufwand etwas einzugrenzen hab ich mich f\u00fcr die 4 \u201cGeneral Purpose Timer\u201d (TIM2, TIM3, TIM4, TIM5) entschieden, weil diese pro Timer 4 Kan\u00e4le besitzen.<br \/>\nIch habe f\u00fcr jeden Timer eine eigene Library geschrieben, die bis auf die Namen der Funktionen und Variabeln gleich sind.<\/p>\n<p>Somit kann man also, wenn man alle 4 Librarys benutzt und je 4 Kan\u00e4le aktiviert, maximal 16 PWMs realisieren.<\/p>\n<p>Die Anzahl und Namen der PWMs die benutzt werden sollen, m\u00fc\u00dfen im H-File deklariert und im C-File den entsprechenden Port-Pins zugeordnet werden.<br \/>\n(bei den Beispielen hab ich immer nur zwei PWMs pro Timer aktiviert)<\/p>\n<p>Im H-File wird auch pro Timer die gew\u00fcnschte Aufl\u00f6sung und die PWM-Frequenz eingestellt. Diese gilt dann f\u00fcr alle 4 Kan\u00e4le die mit diesem Timer betrieben werden.<br \/>\nAuch wird im H-File die Polarit\u00e4t vom PWM fesgelegt.<\/p>\n<p><strong>Beispielbild :<\/strong><\/p>\n<p><a href=\"http:\/\/mikrocontroller.bplaced.net\/wordpress\/wp-content\/uploads\/2013\/03\/pwm.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1082\" src=\"http:\/\/mikrocontroller.bplaced.net\/wordpress\/wp-content\/uploads\/2013\/03\/pwm-300x179.jpg\" alt=\"pwm\" width=\"300\" height=\"179\" \/><\/a><\/p>\n<p><strong>Voraussetzungen :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">Benutzte Module der CooCox-IDE : GPIO, TIM\r\nBenutzte Librarys : keine<\/pre>\n<p><strong>Enumerationen (f\u00fcr PWM mit TIM2) :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">typedef enum\u00a0{\r\n\u00a0 PWM_T2_PB11 = 0, \u00a0\/\/ PWM per TIM2 an PB11\r\n\u00a0 PWM_T2_PA2 \u00a0= 1 \u00a0 \/\/ PWM per TIM2 an PA2\r\n}PWM_TIM2_NAME_t;<\/pre>\n<p><strong>Funktionen (<strong>f\u00fcr PWM mit TIM2<\/strong>) :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">void UB_PWM_TIM2_Init(void);                                 \/\/ um den PWM mit TIM2 zu initialisieren\r\nvoid UB_PWM_TIM2_SetPWM(PWM_TIM2_NAME_t pwm, uint16_t wert); \/\/ zum einstellen eines PWM wertes<\/pre>\n<p><strong>Beispiel :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">\/\/--------------------------------------------------------------\r\n\/\/ File     : main.c\r\n\/\/ Datum    : 26.03.2013\r\n\/\/ Version  : 1.0\r\n\/\/ Autor    : UB\r\n\/\/ EMail    : mc-4u(@)t-online.de\r\n\/\/ Web      : www.mikrocontroller-4u.de\r\n\/\/ CPU      : STM32F4\r\n\/\/ IDE      : CooCox CoIDE 1.7.0\r\n\/\/ Module   : CMSIS_BOOT, M4_CMSIS_CORE\r\n\/\/ Funktion : Demo der PWM-Library\r\n\/\/ Hinweis  : Diese zwei Files muessen auf 8MHz stehen\r\n\/\/              \"cmsis_boot\/stm32f4xx.h\"\r\n\/\/              \"cmsis_boot\/system_stm32f4xx.c\"\r\n\/\/--------------------------------------------------------------\r\n\r\n#include \"main.h\"\r\n#include \"stm32_ub_pwm_tim4.h\"\r\n#include \"stm32_ub_adc1_single.h\"\r\n\r\nint main(void)\r\n{\r\n  uint16_t ad_wert;\r\n\r\n  SystemInit(); \/\/ Quarz Einstellungen aktivieren\r\n\r\n  \/\/ init vom ADC\r\n  UB_ADC1_SINGLE_Init();\r\n\r\n  \/\/ Init vom PWM mit Timer4\r\n  \/\/ Settings vom H-File :\r\n  \/\/   Aufl\u00f6sung = 8bit (0...255)\r\n  \/\/   Frequenz = 1kHz\r\n  \/\/   Kanal1 an PD12\r\n  \/\/   Kanal2 an PD14\r\n  UB_PWM_TIM4_Init();\r\n\r\n  \/\/ PD12 auf 25% einstellen\r\n  UB_PWM_TIM4_SetPWM(PWM_T4_PD12,64);\r\n\r\n  \/\/ PD14 auf 50% einstellen\r\n  UB_PWM_TIM4_SetPWM(PWM_T4_PD14,128);\r\n\r\n  while(1)\r\n  {\r\n    \/\/ AD-Wert an PA3 lesen\r\n    ad_wert=UB_ADC1_SINGLE_Read_MW(ADC_PA3);\r\n    \/\/ von 12bit in 8bit umwandeln\r\n    ad_wert=(ad_wert&gt;&gt;4);\r\n    \/\/ als PWM Wert an PD12 ausgeben;\r\n    UB_PWM_TIM4_SetPWM(PWM_T4_PD12,ad_wert);\r\n  }\r\n}\r\n<\/pre>\n<p>Hier die Library zum\u00a0<strong>Download :<\/strong><\/p>\n<p><a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/wp-content\/uploads\/2013\/03\/ub_stm32f4_pwm_v100.zip\">ub_stm32f4_pwm_v100<\/a><\/p>\n<p>Hier der komplette CooCox-Projektordner zum\u00a0<strong>Download :<\/strong><\/p>\n<p><a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/wp-content\/uploads\/2013\/03\/Demo_25_PWM.zip\">Demo_25_PWM<\/a><\/p>\n<h3 id=\"comments-title\">16 Antworten auf <em>25-PWM-Library (STM32F4)<\/em><\/h3>\n<ol class=\"commentlist\">\n<li id=\"li-comment-1018\" class=\"comment even thread-even depth-1\">\n<div id=\"comment-1018\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/86226d47d0f541a09bc0a0dfc1ec0d43?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Robert<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">11. November 2013 um 21:18<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Hallo,<br \/>\nvielen Dank f\u00fcr diese und alle anderen Libs! Einige benutze ich schon erfolgreich. Bei dieser habe ich jedoch zum ersten Mal ein Problem:<\/p>\n<p>Die PWM an PD12 hat immer 25%, egal welchen Wert ich einstelle:<br \/>\n\/\/ PD12 auf 25% einstellen<br \/>\nUB_PWM_TIM4_SetPWM(PWM_T4_PD12,64);<\/p>\n<p>In der n\u00e4chsten Zeile f\u00fcr PD14 funktioniert\u2019s perfekt!<\/p>\n<p>Au\u00dferdem bekomme ich es nicht hin, die 2 weiteren PWMs zu aktivieren. Ich habe im h-File eingetragen:<br \/>\ntypedef enum<br \/>\n{<br \/>\nPWM_T4_PD12 = 0, \/\/ PWM per TIM4 an PD12<br \/>\nPWM_T4_PD14 = 1, \/\/ PWM per TIM4 an PD14<br \/>\nPWM_T4_PD13 = 2, \/\/ PWM per TIM4 an PD13<br \/>\nPWM_T4_PD15 = 3 \/\/ PWM per TIM4 an PD15<br \/>\n}PWM_TIM4_NAME_t;<\/p>\n<p>#define PWM_TIM4_ANZ 4 \/\/ Anzahl von PWM_TIM4_NAME_t<\/p>\n<p>Aber PD13 und PD15 bleiben tot. Was muss ich noch tun?<\/p>\n<p>Nochmals vielen Dank!<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1022\" class=\"comment byuser comment-author-admin_ub bypostauthor odd alt depth-2\">\n<div id=\"comment-1022\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">12. November 2013 um 19:32<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>das H-File hast du richtig ge\u00e4ndert. Aber im C-File m\u00fcssen die beiden neuen PWMs auch noch eingetragen werden.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\">PWM_TIM4_t PWM_TIM4[] = {\r\n  \/\/ Name     ,Channel, PORT , PIN       , CLOCK               , Source         , Init\r\n  {PWM_T4_PD12,1      ,GPIOD ,GPIO_Pin_12,RCC_AHB1Periph_GPIOD ,GPIO_PinSource12,  64},\r\n  {PWM_T4_PD14,3      ,GPIOD ,GPIO_Pin_14,RCC_AHB1Periph_GPIOD ,GPIO_PinSource14,  128},\r\n  {PWM_T4_PD13,2      ,GPIOD ,GPIO_Pin_13,RCC_AHB1Periph_GPIOD ,GPIO_PinSource13,  64},\r\n  {PWM_T4_PD15,4      ,GPIOD ,GPIO_Pin_15,RCC_AHB1Periph_GPIOD ,GPIO_PinSource15,  128},\r\n};\r\n<\/pre>\n<p>probier mal aus ob damit der Fehler weg ist und alle 4 PWMs funktionieren.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-1028\" class=\"comment even thread-odd thread-alt depth-1\">\n<div id=\"comment-1028\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/86226d47d0f541a09bc0a0dfc1ec0d43?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Robert<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">12. November 2013 um 19:56<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Super, danke!<br \/>\nJetzt kommt aus allen 4 Pins etwas raus <img decoding=\"async\" class=\"wp-smiley\" src=\"wp-includes\/images\/smilies\/icon_smile.gif\" alt=\":)\" \/><\/p>\n<p>Allerdings ist die PWM auf PD12 noch immer nicht einstellbar, sondern fest bei 25%.<br \/>\nDie anderen 3 lassen sich prima einstellen.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1029\" class=\"comment byuser comment-author-admin_ub bypostauthor odd alt depth-2\">\n<div id=\"comment-1029\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">12. November 2013 um 20:59<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>du benutzt aber nicht das Beispielprogramm von hier oder ? \u2026weil da wird PD12 in der while st\u00e4ndig mit einem Wert beschrieben !!<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-1030\" class=\"comment even thread-even depth-1\">\n<div id=\"comment-1030\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/86226d47d0f541a09bc0a0dfc1ec0d43?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Robert<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">12. November 2013 um 21:51<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Aaaaah!<br \/>\nWer guckt denn schon in die while?<\/p>\n<p>Oh man, danke!<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-2765\" class=\"comment odd alt depth-2\">\n<div id=\"comment-2765\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/7ca48c5d8311a3200fd3274afb632c2e?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\"><a class=\"url\" href=\"http:\/\/man3ref.ma\/\" rel=\"external nofollow\">man3ref.ma<\/a><\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">23. Dezember 2014 um 14:19<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>kann sein, dass du 4 PWMs f\u00fcr einen Quadcopter brauchst?<br \/>\nWenn ja, wie ist der Stand bei Dir?<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-1287\" class=\"comment even thread-odd thread-alt depth-1\">\n<div id=\"comment-1287\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/af5be9fa3f95b3ec9c424ed130b7f2d3?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Cortex-Einsteiger<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">20. Januar 2014 um 21:16<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>zur Info:<br \/>\nWenn mann mehrere PWM-Timer gleichzeitig benutzen m\u00f6chte, meckert der Compiler.<br \/>\nDie internen Funktionen werden in jeden File neu erstellt: P_PWM_InitIO(); P_PWM_InitTIM();<\/p>\n<p>Ich habe die Funkionen jeweils mit einem Index des Timers versehen, so dass kein Name mehr doppelt vorkommt, es scheint zu laufen.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-1560\" class=\"comment odd alt thread-even depth-1\">\n<div id=\"comment-1560\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/b894d67379dd0647dd316009f47155d2?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Joerg B<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">16. April 2014 um 07:42<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Muss ich etwas besonderes beachten wenn ich Pf9 \/Tim14 Channel1 benutzen will?<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-1561\" class=\"comment even thread-odd thread-alt depth-1\">\n<div id=\"comment-1561\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/b894d67379dd0647dd316009f47155d2?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Joerg B<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">16. April 2014 um 08:10<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Ok funktioniert Problemlos.<br \/>\nWichtig ist bei der Nutzung mehrerer Timer die Funktionsnamen anzupassen.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-2766\" class=\"comment odd alt thread-even depth-1\">\n<div id=\"comment-2766\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/7ca48c5d8311a3200fd3274afb632c2e?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\"><a class=\"url\" href=\"http:\/\/man3ref.ma\/\" rel=\"external nofollow\">man3ref.ma<\/a><\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">23. Dezember 2014 um 14:21<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Hallo admin_ub,<\/p>\n<p>ich wollte zwischen Demo_84_SPI_LIS3DSH und Demo_25_PWM ein Kombination erstellen. Ich habe dir \u201cneueren\u201d Header-Dateien eingepflegt aber er wollte dann nicht mehr compilieren.<br \/>\nMein Ziel ist je nach Neigung des Sensors den Tastverh\u00e4ltnis der unterschiedlichen 4PWM zu \u00e4ndern.<\/p>\n<p>Auf eine Antwort freue ich mich.<br \/>\nDanke!<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-2772\" class=\"comment byuser comment-author-admin_ub bypostauthor even depth-2\">\n<div id=\"comment-2772\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">27. Dezember 2014 um 11:58<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>mit der Fehlermeldung \u201cer wollte dann nicht mehr compilieren\u201d kann ich nichts anfangen.<br \/>\n1. Neues \u201cleeres\u201d projekt anlegen<br \/>\n2. Files von LIS3DSH, SPI1, PWM hinzuf\u00fcgen.<br \/>\n3. Compiler darf keinen Fehler melden<br \/>\n4. Erst jetzt eigenen Code hinzuf\u00fcgen<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-3324\" class=\"comment odd alt thread-odd thread-alt depth-1\">\n<div id=\"comment-3324\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/2a234226734164d889af8d486d1a5c0d?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Jens<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">11. Juni 2015 um 09:51<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Hallo,<\/p>\n<p>wie bekomme ich (bei PE10) z.B. den \u201cTIM1_CH_2N\u201d zum laufen?<br \/>\nDer \u201cTIM1_CH_2\u2033 (PE11) funktioniert einwandfrei.<\/p>\n<p>Ich m\u00f6chte quasi 2 PWM-Signale erzeugen, die um 180\u00b0 versetzt sind, um ein Encoder-Signal zu simulieren.<\/p>\n<p>Vielen Dank f\u00fcr die baldige Antwort <img decoding=\"async\" class=\"wp-smiley\" src=\"wp-includes\/images\/smilies\/icon_smile.gif\" alt=\":)\" \/><br \/>\nGru\u00df Jens<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-3325\" class=\"comment byuser comment-author-admin_ub bypostauthor even depth-2\">\n<div id=\"comment-3325\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">11. Juni 2015 um 12:31<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>den Pin in der PWM-Struktur eintragen, damit er als GPIO konfiguriert wird<\/p>\n<p>in der OCInitStructure m\u00fcssen dann noch zwei Werte gesetzt werden :<br \/>\n<code><br \/>\nTIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable;<br \/>\nTIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_High;<br \/>\n<\/code><br \/>\npolarit\u00e4t entweder \u201cTIM_OCNPolarity_High\u201d oder \u201cTIM_OCNPolarity_Low\u201d<br \/>\ndas \u201cTIM_CtrlPWMOutputs(TIM1, ENABLE);\u201d darf bei Timer-1<br \/>\nauch nicht vergessen werden.<\/p>\n<p>Hinweis : Encoder-Signale sind nicht invertiert sondern<br \/>\n90\u00b0 Phasenverschoben<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-3330\" class=\"comment odd alt depth-3\">\n<div id=\"comment-3330\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/2a234226734164d889af8d486d1a5c0d?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Jens<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">12. Juni 2015 um 13:01<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>vielen Dank f\u00fcr die schnelle Antwort.<\/p>\n<p>Ja das meinte ich, die Phasenverschiebung. Habe mich einfach bescheuert ausgedr\u00fcckt.<\/p>\n<p>Ist deine L\u00f6sung f\u00fcr die Phasenverschiebung?<\/p>\n<p>Gru\u00df Jens<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-3333\" class=\"comment byuser comment-author-admin_ub bypostauthor even depth-4\">\n<div id=\"comment-3333\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">12. Juni 2015 um 18:36<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>mach es anders. Nimm das original Beispiel von hier mit Timer-2 per CH3 und CH4. Dann \u00e4ndere bei allen Kan\u00e4len den Timer-Mode von \u201cPWM\u201d in \u201cToggle\u201d also die Zeilen :<br \/>\n<code><br \/>\nTIM_OCInitStructure.TIM_OCMode = TIM_OCMode_Toggle;<br \/>\n<\/code><br \/>\ndamit ergeben sich zwei Rechtecksignale,<br \/>\nderen Tastverh\u00e4ltnis immer 50\/50 ist aber<br \/>\ndie Phasenlage untereinander l\u00e4sst sich \u00fcber die<br \/>\nPulswerte einstellen.<br \/>\nStell CH4 auf einen Pulswert von 1 und CH3<br \/>\nauf einen Pulswert von 128 dann sind sie um 90\u00b0<br \/>\nversetzt.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-3359\" class=\"comment odd alt depth-5\">\n<div id=\"comment-3359\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/2a234226734164d889af8d486d1a5c0d?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Jens<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">25. Juni 2015 um 09:29<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Hallo,<\/p>\n<p>Danke!<br \/>\nIch habe es mit der PWM nun doch zum Laufen gebracht.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Um die PWM-Funktionen vom STM32F4 benutzen zu k\u00f6nnen, habe ich diese Library(s) geschrieben. Der STM32F4 hat sehr viele Timer (14) und fast alle haben eine PWM funktion. Um den Aufwand etwas einzugrenzen hab ich mich f\u00fcr die 4 \u201cGeneral Purpose &hellip; <a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=249\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":144,"menu_order":25,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[128],"tags":[9,57,7],"class_list":["post-249","page","type-page","status-publish","hentry","category-stm32f4","tag-library","tag-pwm","tag-stm32f4"],"_links":{"self":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=249"}],"version-history":[{"count":4,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/249\/revisions"}],"predecessor-version":[{"id":3678,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/249\/revisions\/3678"}],"up":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/144"}],"wp:attachment":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}