![]() The function works fine, but one issue is about clock. I try the same thing on STM32L432KC Nucleo board. The frequency of both PWM channel is around 100Hz, duty cycle is 40% and out of phase. The waveform of the two PIN is shown like this, captured by an logic analyzer: _HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_2, pwm2) // compare counter with pwm2 _HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_1, pwm1) // compare counter with pwm1 Pwm2 = 60 //determine the duty cycle, 1-pwm2/period = 0.4, because polarity is LOW. Pwm1 = 40 //determine the duty cycle, pwm1/period = 0.4 HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2) //start TIM2_CH2 HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1) //start TIM2_CH1 If (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) SConfigOC.OCPolarity = TIM_OCPOLARITY_LOW If (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) SConfigOC.OCFastMode = TIM_OCFAST_DISABLE SConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH If (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK) SMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE SMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET Next, generate code and open project in CubeIDE.Ĭheck the generated code has the TIM2_Init(). This is to make sure Channel 2 will be outof phase. Set CH Polarity of Channel 1 and 2 to be High and Low, respectively.In a word, the PWM’s frequency related to the system clock, prescalar and period. This means that TIMER2 will take 100us (99 + 1) = 10ms, which is 100Hz. This will make the center of two channel align to each other, rather than edge aligned. Set counter mode to be “Center Aligned Mode 1”.This number makes the clock for the TIMER2 is 4MHz/(399+1)=10kHz, which means 100us. Select “PWM Generation CH1/2” in Channel 1/2.Then selectim TIM2 in the left bar to configure the TIM2 settings. Go to Clock Configuration panel and set the clock to be HCLK=8MHZ. Here, we select PA5 and PA1, which is TIM2_CH1 and TIM2_CH2, respectively. After initialization, we set two PINs to be our desired PWM channel. This blog it to show how to use CubeIDE (which is an Eclipse distribution for ARM MCU devemopment) to deploy two out-of-phase PWM waveforms by change setting of TIMER.įirstly, open CubeMX software, create “new project” and select the board “Nucleo F411RE”. The reason is to eliminate the case when both PWM is in HIGH level, which is burn the circuit! This Blog The duty cycle of both PWM is the same and less than 50%. The input to the LC driver circuit is two out of phase PWM waveform. The ideal input and output waveform is like this: The amplitude of the AC signal depends on the Vdc (source). The purpose of this circuit is to provide the liquid crystal cell an alternative current waveform of around 100 Hz. One of my current project is to create a compact version of device taht consists of a STM32 MCU, a PIR sensor, a Bluetooth module, a temperature/humidity sensor, and a LC driver.įor a LC driver, the electrical schematic is looks like this Mbed Code #include "mbed.Using CubeIDE create PWM waves on Nucleo F411RE Board ![]() Below is my Mbed code which serves webpage on request. ESP8266's power lines are connected to 3.3v and GND. ESP8266's Rx and Tx is connected to UART1 lines available on D2 and D8 of nucleo board. Grove temperature sensor is connected to "A0" of Nucleo board. There are lot tutorials available on internet on how to update the ESP8266's FW. Communication with ESP8266 WiFi module is using "AT" commands over UART lines. I used Mbed framework which is easier for prototyping. I connected Grove temperature sensor along with ultra low cost ESP8266 WiFi module to use as web-server to fetch realtime temperature. Click on "Yes>" which will initiated the update procedure.Īfter update the debugger FW, I used this board to achieve something meaningful. This step also retrieves the current debugger FW version. First Install the drivers and then run the debugger FW update software "ST-LinkUpgrade.exe" and click on "connect device", which will recognise any ST Link debugger connected to host system. To get started, download the ST Link drivers and then download ST Link FW update software. This platform is Mbed enabled and the on board ST Link debugger provides standard Mbed interface such as drag-drop programming with virtual serial port connected to USART2 too. The only drawback I noticed was missing USB OTG connector for STM32F411RE. Overall board looks good and worth it's price with powerful STM32F411RE and on board ST Link debugger. ![]() I received my STM32F411RE Nucleo board last weekend (Thanks to Carissa for selecting my idea).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |