MG32F10x Standard Peripherals Firmware Library
TIM 6Steps example
  *************** (C) COPYRIGHT 2020 - 2023 megawin Technology ***************
  * @file    TIM/TIM_6Steps/readme.txt 
  * @author  megawin Application Team
  * @version V0.1.10
  * @date    05-January-2023
  * @brief   Description of the TIM_6Steps example.
  ******************************************************************************
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  * TIME. AS A RESULT, MEGAWIN SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
  * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM
  * THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  ******************************************************************************
Example Description

This example shows how to configure the TIM1 peripheral to generate 6 Steps. The TIM1 peripheral offers the possibility to program in advance the configuration for the next TIM1 outputs behaviour (step) and change the configuration of all the channels at the same time. This operation is possible when the COM (commutation) event is used. The COM event can be generated by software by setting the COM bit in the TIM1_EGR register or by hardware (on TRC rising edge). In this example, a software COM event is generated each 100 ms: using the SysTick interrupt. The TIM1 is configured in Timing Mode, each time a COM event occurs, a new TIM1 configuration will be set in advance.

The break Polarity is used at High level.

The following Table describes the TIM1 Channels states:

              -----------------------------------------------
             | Step1 | Step2 | Step3 | Step4 | Step5 | Step6 |
   ----------------------------------------------------------
  |Channel1  |   1   |   0   |   0   |   0   |   0   |   1   |
   ----------------------------------------------------------
  |Channel1N |   0   |   0   |   1   |   1   |   0   |   0   |
   ----------------------------------------------------------
  |Channel2  |   0   |   0   |   0   |   1   |   1   |   0   |
   ----------------------------------------------------------
  |Channel2N |   1   |   1   |   0   |   0   |   0   |   0   |
   ----------------------------------------------------------
  |Channel3  |   0   |   1   |   1   |   0   |   0   |   0   |
   ----------------------------------------------------------
  |Channel3N |   0   |   0   |   0   |   0   |   1   |   1   |
   ----------------------------------------------------------
Directory contents
  • TIM/TIM_6Steps/TIM_6Steps.uvprojx MDK5 project file
  • TIM/TIM_6Steps/TIM_6Steps.uvoptx MDK5 project options file
  • TIM/TIM_6Steps/JLinkSettings.ini Jlink settings file
  • TIM/TIM_6Steps/main.c Main program
Hardware and Software environment
  • Hardware environment
    • HSE crystal is 8MHz
    • Connect the TIM1 pins to an oscilloscope to monitor the different waveforms:
      • TIM1_CH1 pin (PA8)
      • TIM1_CH1N pin (PB13)
      • TIM1_CH2 pin (PA9)
      • TIM1_CH2N pin (PB14)
      • TIM1_CH3 pin (PA10)
      • TIM1_CH3N pin (PB15)
    • Connect the TIM1 break pin TIM1_BKIN pin (PB12) to the GND. To generate a break event, switch this pin level from 0V to 3.3V.
How to use it ?

In order to make the program work, you must do the following :

  • Open TIM_6Steps.uvprojx from this example folder by Keil MDK5
  • Rebuild all files and load your image into target memory
  • Run the example

    © COPYRIGHT 2020 - 2023 megawin Technology