STM32 replacement note: It is easy to replace domestic chips!
[Copy link]
This post was last edited by Hot Ximixiu on 2021-11-15 20:46
I have several boards for STM32F103RET6 applications, and I am asked by purchasers all day whether they can be replaced by domestic ones. The cost is almost unbearable. This time I got a sample from HK as an alternative and gave it a try.
At first, I didn't make any changes. The program ran as soon as I downloaded it. I complained a lot, thinking that I might have taken the wrong film. Later, I calmed down and tested the functional modules in detail.
There are still some minor problems, but it is very easy to modify. As an emergency replacement, it should not be a big problem. Therefore, I will write a preface to inform you that this replacement is extremely easy. If you have the same needs, feel free to do it!
The sad thing that followed was that most of my work in the past few days became taking photos and keeping them as souvenirs. There was not much technical content, and as I had a basic understanding of ST usage, I basically did not need to consult manuals or other documents, so there was no pressure at all.
The alternative steps and technical challenges that were originally prepared turned into the following "travel memoirs".
1. Change the chip first.
Before changing it, keep an image of the ST and change it in a moment.
After changing it, I took it back to my office. My welding skills are pretty good. But the alcohol has dried, the impurities have not been cleaned up, and the pins are a little white.
All is ready, what to do next? It sounds so good online, can I just burn the ST program?
2. Directly burn the original ST program
I was speechless. I could just burn the original ST program without any modification and it would work. What else could I play?
I was ready for all the operations, but in the end, I was stuck at the start~~~~The red power indicator and the blue flashing program running indicator.
Am I hallucinating? This is my first time using Hangshun, how could it be so smooth?
I opened MDK to confirm that the ST program was indeed burned into the HK film, and it ran directly. I was originally planning to find some faults...
Well, now that this is the case, let's go back and see what resources were used in the STM32.
The whole program is based on the HAL library, the hardware initialization part.
The program was developed by a colleague. I am currently just trying to verify whether the conditions for chip replacement are met. During the program development process, some products were compatible and the initialized resources were a little more than actually used. The following is to verify whether the modules used are normal.
GOIO:PC13
DMA1: 后来程序测试的过程中,发现并没有使用DMA
ADC1: ADC_CHANNEL_9 , ADC_CHANNEL_10,ADC_CHANNEL_11
USART: COM1 COM4
Timer(PWM) : TIM3
SPI2:这个实际没有用到,作为预留功能的。
DAC: DAC_CHANNEL_1
3. Now that the program is running, I suddenly feel like I have nothing to do, so I verify the resources currently being used to see if they are working normally.
3.1 IO output (PC13)
Directly look at the program running status indicator, the flashing frequency is normal. Other IOs are also used, and there is no big problem with pure IO use.
3.2 Serial Port
Data transmission and reception are normal.
3.3 DAC Output Detection
The voltage output is controllable and normal. (I am starting to get anxious. Is this normal? If everything is normal, where can I find the problem?) The measured DAC output is normal, but in the HK application notes, I found the following precautions. I think I should refer to the application notes in the application.
3.4 ADC Detection
I didn't pay attention at first, but when I saw the ADC sampling data, it seemed normal, so I almost missed it. However, I used three channels 9, 10, and 11. So, the problem came. My previous sampling order was 10, 9, and 11. In actual testing, I found that the channel order was messed up, which caused my sampling data to be messed up.
Haha, I finally found the problem, I can vent and complain~~~ Until here, I just started looking for HK resources. First change the HK pack, compile and try, the settings and chip selection are as follows:
Choose M3
So far, the problem has not been solved after compiling and downloading. It is not the problem of PACK package.
Then I saw some descriptions of the process of using multi-channel ADC in the application notes of HK.
Well, I followed the application note and tried adding a delay. The result was not what I wanted. I can only rely on myself now. Please don't embarrass me.
Where else? Since the channel order is messed up, then, in ADC initialization~
So far, after the change, the sampling values of several ADC channels are normal! ! Take a breath, I almost let it go after bragging for a long time~
But to be honest, I still don't understand why. I even found an ST board to verify it. My previous settings were fine with the ST chip, but I need to change it with the HK one. Which great god has debugged the ADC? I hope to give me some advice~
After this, I will look at the HK manual again. Since the current adc value is normal, I will skip it here.
3.5 I have lost my patience, and I have simply verified the basic modules used. I directly installed them into the whole machine to see the effect.
Replace the original equipment position, inspect the whole machine, work for 2 hours, the equipment status is stable~~~~ It is temporarily considered that the replacement is successful, and the subsequent verification will be handed over to the quality department.
3.6 fooled a colleague and asked him to try it on his board.
Since the replacement is easier than I thought, I gave it to my colleague, who replaced the chip on his board. The feedback I got was:
1. The program can be used by downloading it directly.
2. Serial port and timer are OK.
3. There is an i2c device, but the data cannot be read (the program uses hardware i2c, which should not be a big deal. It is mentioned in the application notes. If it doesn't work, IO simulation can also solve it.)
4. Browse Hangshun official website
It seems that everything is done, and the official website is not opened, which is a bit inappropriate. I can't help the lazy elf shouting in my head, "Can we use ST to develop it and then simply modify it?"
However, if I want the hardworking elf to win, I still have to go back to the official website to check it out~~
http://www.hsxp-hk.com/companyfile/23/
Download the F103 PACK package here, and you can also download the user manual and data sheet according to your needs. Hangshun's official website is very neat and the information is easy to find.
Selection table, this is something many people will ask, what is the use of it when it is not in use. When you want to find it, you can't find it. Remember to save it by the way, or contact technical support to chat.
Later on, I should gradually transition to the Haohangshun library. After all, when you use someone's products, you have to use their "soul".
5. Summary
Maybe it was due to limited resources or good luck. The replacement process was very easy, and I didn't have to look at HK manuals and application notes too much.
The program can be run directly after downloading. During the detailed testing of the functional modules, it was found that the channel acquisition order was not consistent with the expectations during ADC multi-channel acquisition. It was also a simple correction of the initialization part to make it work normally.
I feel that if the product has been finalized and you are looking for chip replacement, it is really worth considering. The hardware does not need to be modified, and the functional modules can be tested in the software. If the requirements are strict, testing the entire machine and the environmental adaptability should not be a problem.
During the test, I selected ST and HK packs for compilation, and no incompatibility was found for the time being. However, this is a preliminary test, and it can be used as a reference for emergency use. In the later replacement process, it should be slowly transferred to the HK library.
Download HK's application notes for reference
HK32F103应用笔记V1.0.32.pdf
(1.28 MB, downloads: 2)
HK32F103xCxDxE应用笔记V1.0.12.pdf
(878.78 KB, downloads: 1)
|