Recently, some customers reported that he encountered the following problems when using STM32F103C8T6:
I2C1 uses PB6 and PB7 ports, and the timer TIM3 uses PB0\PB1\PB4\PB5 for 4-channel PWM. But in the process of using, if only the timer is initialized, there is no problem, but once I2C1 is initialized, the timer channel 2 (PB5) cannot generate the PWM wave, but keeps the high level.
Customers refer to the manual and know that the default multiplexing function of PB5 is the SMBA pin of I2C1, but its I2C1 is initialized to I2C mode, not to SMBAS mode, and the same method is available for testing on F0. It was originally developed with the standard library, and then tried to use STM32CubeMx for hardware configuration, and use the HAL library to create a new project, but the same problem still exists.
Regarding the above problem, I checked some of the codes related to the pwm initialization of I2C1 and TIM3d, and found nothing wrong. First of all, it is important to doubt whether the configuration of I2C1 is wrong, and worry that the customer configures the SMBAS mode when configuring I2C1. With the help of the library code, further tracking down to check the underlying register configuration, the related register operation did not find any problems.
Here several pins of the PWM output of TIM3 are involved in remapping [REMAP]. From the pin assignment of the data sheet, if the SMBA mode of I2C1 is not turned on, there should be no conflicts.
Here again, STM32CubeMx is used for the same configuration based on STM32F103C8, and the result is the same as the customer's feedback above. When I2C1 is not turned on, all pins of TIM3 function normally; after I2C1 is turned on, some pins of TIM3 PB5 function abnormally. I feel that the problem may lie in the remap of TIM3. Open the important book based on the STM32F1 series---reference manual RM0008, and check the introduction of the TIM3 pin multiplexing REMAP function.
Now the customer is implementing the partial remap function of TIM3 [partial remap]. From the above table, the current code configuration is no problem. After all, there is nothing unusual about TIM3 if I2C1 is not turned on at present, so I came to check this place, and I didn't expect to find obvious errors from here, but I was looking forward to finding some additional tips or reminders from nearby. No, the lower part of the table uses a small text to clearly remind: the above REMAP operation is only applicable to 64-pin, 100-pin and 144-pin packaged chips. Now the chip used by the customer is STM32F103C8 with 48 pins. In other words, it It does not support the REMAP operation of the TIM3 multiplexed function pin. At this point, the problem should be said to have found the cause.
After a few days, the customer sent an email again to continue consulting on the issue. He asked, since the 48-pin chip STM32F1 does not support the REMAP operation of TIM3, why after doing the REMAP operation, if I2C1 is not turned on, the PWM function of the 4 pins of TIM3 is normal; or even if I2C1 and PB4 are turned on at the same time The function is still normal. REMAP came over, but the function of PB5 is abnormal. I hope I will give further explanation here.
From the user's point of view, it is normal for someone to ask similar questions. In fact, since the manual clearly stipulates that the 48-pin STM32F1 chip does not support the REMAP of the TIM3 function pin, it has its own reasons and reasons. If you operate in violation of the manual, the correctness of the results cannot be guaranteed. Sometimes REMAP is okay, but it doesn’t mean that REMAP is okay at any time. Just like discussing a certain proposition, local and individual situations are true, but it cannot be said that it is always true. For example, A is 10 years old this year, and B is 20 years old this year. That is, B is 10 years older than A, and B's age this year is twice that of A. Obviously, both conclusions are valid this year, and next year, the latter two-fold theory will no longer be valid.
In the application process of ST MCU, there are often similar operations that violate the manual and the resulting questions. For example, some people found that when using the flash inside the STM32 chip, it seems that they can use the space outside the manual. When users use it in this way, the functions or features of the chip cannot be guaranteed. As a manufacturer, they can only guarantee the quality of the area specified in the chip manual. For example, we know that most of the ST MCU chips have UIDs, but some people send out some chips that do not have UIDs even though the manual clearly shows them. They seem to find that such chips still have UIDs or even use them, and ask what is going on. Is it reliable? Similarly, for similar situations, the manufacturer can only guarantee the characteristics specified in the manual. Applications beyond the regulations in the manual are only the responsibility of the user.
Okay, go back to the topic above.
We should say that we have found a clear regulation or answer from the reference manual of the chip application. We can also check for more detailed errata based on the chip. Later, I found the corresponding errata manual on the official website [Note: The errata manual is often based on the chip model, that is, a series may have multiple errata manuals], we also see the detailed description of the above issues in the errata manual, which should be regarded as Further supplement to the reference manual.
At this point, the cause of the problem is basically clear. Some people may also ask that the above mentioned use of STM32CubeMx for engineering configuration, the configuration process did not find anomalies, or that the configuration process did not encounter the above obstacles. Since the reference manual stipulates that the TIM3 remap operation of the STM32F103C8 chip is not allowed, when i2c1 is turned on, an illegal prompt should appear when configuring the REMAP function of TIM3 through cubeMx?
The version of CUBEMX I used is 4.22.0. When I2C1 is turned on, and when I configure it according to the part of REMAP of TIM3, I can’t say that no reminder is given, I can only say that the reminder is not clear enough. The reminder may be easily overlooked, and then it can be configured all the way.
The configuration of STM32CubeMx is as shown in the figure below. There is a yellow warning in the place of I2C1, and there is a text prompt when the mouse is placed over [not everyone will notice]:
It can be said that CubeMx is still not rigorous enough or considered poorly. If I2C1 is turned on, when the user tries to configure PB5 as an output, it will directly warn in red and reject the remap of TIM3. But in this way, it may affect another type of user population. They don't care about PB5 at all, but only pay attention to PB4 can be used as PWM output. It's a bit difficult to adjust. The reference manual clearly does not support the REMAP operation of the 48-pin TIM3 of the STM32F1 series. At the same time, it is supplemented with the errata manual to meet different application requirements as much as possible.
After all, the STM32CubeMX project is huge, and there must be areas that need to be improved, especially similar details. However, we believe it will become more and more perfect. In any case, we cannot completely put the chip manual aside at any time. For example, we know that ST officially released a firmware library based on each STM32 series, and various sample projects in the library greatly facilitate your study and research and development. It is not difficult to imagine that these firmware library projects are also relatively large, it is inevitable that there will be bugs, and they are constantly being improved. If you encounter any doubts in the process of using them, you may wish to check the relevant data manual or development reference manual for further comparison and confirmation. If you feel that the description in the manual is not clear enough, you can look for the errata manual of the corresponding chip to see if there is any further supplementary description of the related issues.
Electric Junction Box,Waterproof Junction Box,Junction Box Wiring,Pvc Junction Box
CIXI MEMBRANE SWITCH FACTORY , https://www.cnjunma.com