Review of Domestic Alternatives to STM32 (3)

Review of Domestic Alternatives to STM32 (3)

Last week, the embedded ARM article “With the Soaring Prices of STM32, Reviewing Domestic Alternatives to STM32” received widespread attention. At the request of readers, embedded ARM will continue to introduce domestic products that can replace STM32.Today, we present the products that can perfectly replace STM32: the HK32F103VET6 and HK32F030M from Hangshun, the latter being the industry’s first 32-bit MCU product priced under 1 yuan.Hangshun was established in Shenzhen in 2014, fully compatible with imported MCU hardware and software. As a general MCU platform-level enterprise built by a world-class MCU R&D team, Hangshun aims to incubate over 100 specialized MCU manufacturers, creating a powerful MCU ecosystem and deeply cultivating the support of young technological talents to achieve the “Hangshun Boundless Technology Ecological Platform’s trillion-level strategic dream of a great global enterprise.”21ic forum user zeshoufx mentioned that by chance, in a group, a member shared “ST’s low-cost, high-performance alternative solution,” which led to an understanding of Hangshun Technology. Upon visiting their official website, he found it to be a very good domestic integrated circuit company: not only do they produce MCUs, but they also cover storage, power, drivers, and analog components, including both 32-bit and 8-bit MCUs, storage types like SPI flash and EEPROM, power solutions including DC-DC and LDO, and drivers mainly for LCDs, with analog devices primarily being various operational amplifiers.Review of Domestic Alternatives to STM32 (3)Without further ado, let’s look at some reviews from 21ic users regarding these two development boards:[Technical Document] HK32F103VET6 LED LightingUser: tlledThis is my first time using the HK32F103VET6 chip. Looking at the chip documentation, the pin and function compatibility with STM32F103VET6 is evident. The recent price hikes of ST’s chips have been outrageous, so I wanted to test this domestic chip as a replacement for STM32F103, supporting domestic chips.I couldn’t apply for the chip on the official website, so I purchased one on X treasure. The chip has an LQFP100 package, and I found that the pins of the purchased chip were not aligned correctly, but fortunately, there were no short circuits during soldering. I powered it on to run a simple LED lighting program.I also couldn’t find the chip SDK package file on the official website, but I found a link to download the materials in a forum post: https://bbs.21ic.com/icview-3055190-1-2.html1. Install Software PackageThe official website provides IAR and MDK corresponding pack files. I used MDK and downloaded the corresponding files.Review of Domestic Alternatives to STM32 (3)2. HardwareThe development board is self-designed, and the LED lighting hardware ports are PD3 and PE0.Review of Domestic Alternatives to STM32 (3) Review of Domestic Alternatives to STM32 (3)3. Program3.1 GPIO Port Application AnalysisWe learn about the application of the GPIO ports of the HK32F103 chip through the LED lighting program, referring to the HK32F103xCxDxE User Manual_V1.0.0 to understand the functions of the GPIO ports.Each bit of the GPIO port can be configured by software into various modes, with the configurable modes including: — Floating Input — Pull-up Input — Pull-down Input — Analog Input — Open-Drain Output — Push-Pull Output — Push-Pull Multiplexed Function — Open-Drain Multiplexed Function Each port can be configured according to the hardware functions.The corresponding program partReview of Domestic Alternatives to STM32 (3)My board’s external LED is connected with a pull-up resistor to the positive power supply, and the configurable port modes are open-drain output or push-pull output.The GPIO configuration of the HK32F103 chip is the same as that of the STM32F103 chip, and the code should be compatible for use.3.2 Running a Simple LED Lighting ProgramThe corresponding GPIO port is configured as output, and in the program, I configured it as push-pull output.Code: led.c

#include "led.h"
#include "delay.h"
void Led_Init(void){
    GPIO_InitTypeDef GPIO_InitStructure;
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOE, ENABLE);
    GPIO_InitStructure.GPIO_Pin = LED1_GPIO_PIN;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_Init(LED1_GPIO_PORT, &GPIO_InitStructure);
    GPIO_InitStructure.GPIO_Pin = LED0_GPIO_PIN;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_Init(LED0_GPIO_PORT, &GPIO_InitStructure);
    LED0_OFF;
    LED1_OFF;
}

Code: main.c Review of Domestic Alternatives to STM32 (3)3.3 Choosing Development Tools Review of Domestic Alternatives to STM32 (3) Review of Domestic Alternatives to STM32 (3)3.4 Program Code

Review of Domestic Alternatives to STM32 (3) HK32F103C8T6_template(Keil v5).rar (4.31 MB, download count: 4)

(Download link:

https://bbs.21ic.com/forum.php?mod=attachment&aid=MTYwNTM3NHxmMGNkODViOXwxNjExMTI1OTQ2fDMwMjk2NTZ8MzA2MTE1Mg%3D%3D)

4. Program ExecutionAfter downloading the program, reset the board, and the two LEDs on the development board light up alternately. The actual video captured and converted into a GIF image shows the effect is not very clear, but the alternating lighting process can still be observed.

Review of Domestic Alternatives to STM32 (3)

[HK32F030M] A Rigorous Benchmark Test, An Unrigorous Frequency Tuning (Frequency), with Test Source Code AttachedUser:gdddddLet me briefly introduce the background: I previously used the HK32F030M for a CoreMark benchmark test, but at that time I had just acquired the chip and was not yet familiar with it. To adapt to the 2K RAM, I modified CoreMark, but this modification led to an incomplete benchmark project, resulting in an inflated score.Later tests revealed that the HK32F030M also has 4K RAM, leading to today’s complete and relatively rigorous benchmark score. However, since the HK32F030M does not have a PLL for frequency multiplication, the results at high frequencies, combined with flash wait times, are not as smooth as those of the STM32F030. Interested forum users can adjust the parameters in the source code for further tuning. Overall, it can compete below 54MHz.Alright, without further ado, let’s look at the results: the score per MHz is around 1.84, slightly higher than STM32F030’s score of around 1.67, which is still quite good and offers excellent cost performance.Review of Domestic Alternatives to STM32 (3)

Review of Domestic Alternatives to STM32 (3)

Review of Domestic Alternatives to STM32 (3)

Review of Domestic Alternatives to STM32 (3)

Next is the unrigorous frequency tuning. First, it should be noted that for actual product applications, do not use overclocking. In rare cases, such as when timing requirements are high (for GPIO simulating low-speed USB, 666.6667ns requires a main frequency of 48MHz), slight tuning can be considered.Moreover, the HK32F030M itself does not have a PLL for frequency multiplication; frequency adjustment relies on coarse tuning in RCC_CR and fine tuning in HSITRIM. The adjustment method is not the coarse adjustment of 2% and fine adjustment of 0.2% mentioned in the manual, but a non-linear ratio. I used a simple method (mainly because I was lazy, using an oscilloscope to check MCO output for precision) to adjust the frequency based on whether the serial output was garbled, as the serial port has a certain error rate range, so the adjustment results are quite imprecise.Another reason is that the HK32F030M chips I have all have a factory HSICAL of 0x1C, but the HSITRIM values differ, so this coarse and fine adjustment method has significant limitations. If the factory HSICAL value is not 0x1C, there will be a considerable frequency deviation.However, interested forum users can also modify parameters and play around. I managed to adjust it to a maximum of 108MHz, but the score was not impressive (high frequency, low performance), so I still have a lot to learn and am not rigorous enough. The source code is only for experimentation, so please don’t criticize me too harshly.Finally, here are two images showing the frequency adjustment points, with options set for 32M, 48M, 54M, 72M, 96M, and 108M. If you need other frequencies, you can experiment further.

Review of Domestic Alternatives to STM32 (3)

Review of Domestic Alternatives to STM32 (3)

In conclusion, this MCU is really impressive. The setting of VECT_TAB_OFFSET is very suitable for IAP, which is a feature of CORTEX M0+ and M3. Although the EEPROM is a bit limited, it is still very practical. If there were DMA, it would be even more powerful. I plan to study the USB book from Circle and create a USB-based IAP, which would be fantastic.Review of Domestic Alternatives to STM32 (3) HK32F030MF4P6_UpClock_Demo_coremark-loop.zip (316 KB, download count: 10)(Download link:https://bbs.21ic.com/forum.php?mod=attachment&aid=MTUyODUzMHxmMzhlYWYxN3wxNjExMTI3MjU4fDMwMjk2NTZ8MzAyMDY4Mg%3D%3D)Hangshun MCU Development Introduction and Common Issues Summary User: ifxz0123Question 0: What IDE, simulation debugging tools, and batch programming tools are required for Hangshun (HK) MCUs? Is there any documentation available?Answer: Development Environment (IDE): Keil (for ARM), IAR (for ARM). Anyone who has developed STM8, STM32, or STC51 is likely familiar with these two software tools, or at least has heard of them. Most of the popular 32-bit ARM architecture MCUs on the market use these two software tools.For STM8 chip development, ST’s own development tool (IDE) STVD can also be used for free. Of course, there are other IDEs available that I haven’t used, so I won’t mention them here. Interested users can search online for more information (Keil version V5 is recommended).Simulation Debugging Tools: Hangshun’s MCUs, like ST’s 32-bit MCUs, are based on ARM CortexM0 and CortexM3 cores, all supporting the SWD debugging interface. Therefore, ST’s 32-bit MCU debugging tools, such as J-LINK, U-Link, ST-Link, DAP-Link, etc., can be used.Other domestic 32-bit ARM CortexM0/CortexM3 chips can generally still use these debugging tools.Batch Programming Tools: Currently, it seems that Hangshun has not released its own batch programmer, and most are third-party tools. Review of Domestic Alternatives to STM32 (3) Third-party Programmer List_20200918.zip (5.57 KB, download count: 10)Hangshun has now also released its own offline batch programmerReview of Domestic Alternatives to STM32 (3) Hangshun RX-0001 Offline Programmer Manual v1.0.00.pdf (1.34 MB, download count: 2)(Please click to read the original text to download from the original post)Supplement:HK’s standalone online programming software:ST’s STVP software: only supports programming, reading and writing FLASH, reading and writing option bytes, and enabling or disabling read/write protection for the same model of Hangshun MCU.Review of Domestic Alternatives to STM32 (3)JLINK Flash V6.70e: supports programming for the entire series of Hangshun MCUs. It is important to note that the JLINK driver must be version 6.0 or higher and must have the Hangshun MCU patch applied.

Review of Domestic Alternatives to STM32 (3)

STM32 ST-LINK Utility: (Tested with HK32F030F4P6, code runs normally)

Review of Domestic Alternatives to STM32 (3)

HK Config: Hangshun 32 MCU programming configuration tool, developed by Hangshun, requires JLINK as a tool, and supports the entire series of Hangshun MCUs. It can perform programming, reading, and option byte configuration.

Review of Domestic Alternatives to STM32 (3)

Question 1: What does it mean that the software and hardware of Hangshun and ST’s same model MCUs are compatible? Is there no need to change hardware? No need to change software? Can ST’s programs be directly programmed into HK’s chips to run?Answer: Yes, basically no need to change the hardware circuit, and generally no need to modify the software code. You can directly program ST’s programs into HK’s chips to run because Hangshun’s chip core is the same as ST’s, and the registers and register addresses are also the same.You can use Keil + debugger, IAR + debugger to program HK’s chips. If the download is unsuccessful, please install HK’s MCU device library and set the project chip model to HK’s model, and set the project’s programming algorithm to HK’s programming algorithm, then compile, link, and download.Note that the ST model must correspond to the HK model, for example, STM32F030C8T6 -> HK32F030C8T6, STM32F103C8T6 -> HK32F103C8T6.If the program is directly downloaded to HK’s chip and there are issues when powered on, please refer to Hangshun’s chip application notes to make minor adjustments to ensure the chip operates correctly.

Review of Domestic Alternatives to STM32 (3)

Review of Domestic Alternatives to STM32 (3)

Review of Domestic Alternatives to STM32 (3)

Question 2: Can STM32MxCube be used to develop Hangshun’s microcontrollers?Answer: Yes, as long as it is a compatible model of Hangshun microcontroller with ST’s MCU, it can be developed using STM32MxCube. However, in applications, issues listed in Hangshun’s application notes may require manual addition or modification of some code to ensure proper operation of Hangshun’s chips.Currently, Hangshun’s F103/F030/F031 series is supported.Which models of Hangshun’s MCUs are supported for development using STM32MxCube? Please see the image below: (only a few commonly used models are listed)

Review of Domestic Alternatives to STM32 (3)

Appendix: Hangshun MCU Selection TableReview of Domestic Alternatives to STM32 (3) Hangshun MCU Selection Table_.zip (105.27 KB, download count: 2)Question 3: How to set up the development environment for Hangshun MCUs?Answer: Review of Domestic Alternatives to STM32 (3) Step-by-step guide to setting up the Hangshun MCU development environment, taking HK32F030MF4P6 as an example (Keil MDK).pdf (3.19 MB, download count: 6)(Please click to read the original text to download from the original post)Question 4: Where to download development materials? Who to contact for technical issues?Answer: Where to download development materials: Hangshun official website (www.hsxp-hk.com), Hangshun official website (www.hsxp-hk.com), Hangshun official website (www.hsxp-hk.com) (important things are said three times)Detailed reference manuals: please visit ST’s official download, please visit ST’s official download, please visit ST’s official download (important things are said three times)(I also find it difficult regarding HK’s datasheets and user manuals)Technical issues: chip agents, original manufacturers. (21ic forum -> Original Manufacturer Section -> Hangshun HK32 MCU Section, please find it yourself)SummaryAs a leader in domestic 32-bit MCUs, Hangshun chips have gained a rare opportunity in the rapid growth of the Chinese MCU market and the wave of chip localization in recent years. We expect the total sales of domestic MCU manufacturers to reach 50 billion yuan this year. Chip localization is no longer a trend but a reality that is happening every day, and Hangshun chips continue to receive consistent attention.As the US-China trade conflict intensifies and the US continues to pressure domestic technology companies, Hangshun chips, as a representative brand of 32-bit MCUs, will continue to invest in R&D to promote Chinese chips. In the future, Hangshun chips will accelerate the construction of an ecosystem, including the integration of IP, chip design, wafer fabs, packaging and testing plants, and other upstream and downstream resources in the industry chain, as well as the Hangshun University program to cultivate engineers familiar with their brand, incubating over 100 MCU brands and building a large ecological platform for Hangshun!

What do you think of this product?

ENDSource: 21ic Forum, Compiled by Fu BinRecommended ReadingCan domestic MCUs replace foreign products? What does the future of MCUs look like?With the soaring prices of STM32, reviewing domestic alternatives to STM32Choosing between microprocessors (MPU) and microcontrollers (MCU): a detailed explanation of the differences

Leave a Comment