当前位置:网站首页>N32 replaces STM32. Don't ignore these details!
N32 replaces STM32. Don't ignore these details!
2022-07-28 18:55:00 【Embedded Linux,】
Preface
The current situation affects , Chip prices are rising , Procurement cycle becomes longer , As a result, it has become a general trend for domestic chips to replace imported chips , This article records the use of national technology N32 Replace STM32 Operation process of .
Don't talk much , Last step .
One 、 Engineering configuration
1. Install hardware Library
The hardware library provides information for manufacturers , As shown in the figure below , Double click installation , bring keil Can find the chip .

2. change J-Flash To configure
because Keil There is no official support for this chip , therefore J-Link The chip cannot be found when downloading , So you need to add chips manually . The change procedure is officially documented .

The main steps are :
modify JLinkDevices The configuration document
add to Nationstech Download algorithm file
add to Nationstech Of JFlash Engineering documents
Add unlock Nationstech Chip read protection L1 Hierarchical applications
After the above steps , start-up J-Flash Can scan and connect to the chip , But it's possible keil Of the link J-Flash And installed J-Flash Not a path , So the configured J-Flash File replacement keil Next Keil5\ARM\Segger Directory file , You can download and debug normally .
3. Change chip

4. Add driver file
take N32 Copy the underlying driver library of to the project directory , And will include Path added in .


5. Change global variables

6. Replace the startup file and driver file with N32 The library files

7. Will all stm32l1xx Replace with n32g45x
Two 、 Bottom driver function interface comparison table
Change code , take STM32 Replace the driver function of with N32 Driving function of , This part is complicated , It needs to be replaced slowly , The following is the replacement comparison table I sorted out .



3、 ... and 、 Record on pit
After the above replacement , It should be able to compile , But this indicates the beginning , The tragic pit war behind has just begun .
1. The simulation is stuck
Program simulation is stuck , One step debugging found that it was stuck OSInit() In the function , This function is OS Initialization function for , So it should be OS Configuration issues , After checking, it was found that it was in the startup file OS The startup item has not been changed , Change it as follows :

2.DMA Configuration error
After the program can enter the task , Debugging found that the serial port cannot be accessed to receive the interrupt , But there is data in the oscilloscope , And the interruption did not enter , It should be stuck in the interrupt with high priority , Investigation and discovery , yes DMA There is a problem with the configuration of sending interrupt , As a result, it has been stuck in DMA In interruption . Here is DMA Part of the configuration .


3.Flash To configure
Due to national chips and STM32 Chip FLASH The division is different , therefore FLASH The replacement of is a more troublesome part , First compare the difference between the two films :
STM32L151 Of flash part :

N32G455 Chip flash part :

It can be seen that STM32 Alone EEPROM Division , and N32 There is no , Only flash part . So we should pay attention to two points :
Flash Space problem ,STM32 The available space is larger than N32 Large space ;
Underlying interface functions ,STM32 There are operations EEPROM Function of , and N32 No, , Only use flash Operation function .
Here is flash Part of the operation :

4.bootloader transplant
As the project adopts bootloader The way to boot the main program , Therefore, pay attention to the configuration of the burning space , The configuration point is in the following position :

When debugging the program separately , Burning the program requires the whole flash erase , Or it doesn't work properly .
5.OS Initialization stuck
The program is stuck again , This is the main program , And the starting address of the main program is 0x8000000 It works well alone , But instead 0x8007000 use bootloader Jump over and get stuck , Also stuck in OS Initializing . Because it works well alone , So it's more difficult to check . The final positioning is that the stack and heap space settings are too large , After the setting is small, it can run . Change the location of this space as follows :

And the problem is not that the stack space is not enough , The space setting is too large . A little speechless .
6. The program does not work properly after jumping
This is the last question , The program can start from bootloader Jump , But it doesn't work properly , Consulted the manufacturer's technical personnel , According to the feedback of technicians, the way of decentralized loading can be used for troubleshooting , That is, let the chip start directly at the burning position of the main program , There are many distributed tutorials online , It is mainly necessary to set the address of burning domain and startup domain , also VTOR register ,
The configuration is as follows :

You need to write *.ini File change VTOR,ini The documentation is as follows :

stay keil Load in , After the software is started, the single-chip microcomputer is configured first :

Distributed loading can be realized after configuration , It can be that the program starts at the burning position , It is found that the program can run normally under decentralized loading , however bootloader Jump is abnormal , Therefore, it is necessary to check the problems in the jump part . Final positioning STM32 The vector table will not be restarted when the main program starts , and N32 Will restart the vector table , The starting position of the main program is changed as follows :

The jump code is as follows :

————————————————
Copyright notice : This paper is about CSDN Blogger 「 Demacia Wu Yanzu 」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement .
Link to the original text :https://blog.csdn.net/zhang421412170/article/details/116779169


边栏推荐
- AI has changed thousands of industries. How can developers devote themselves to the new "sound" state of AI voice
- Why app uses JSON protocol to interact with server: serialization related knowledge
- Redis cache avalanche, penetration, breakdown, bloom filter, detailed explanation of distributed lock
- [actual combat] realize page distortion correction with OpenCV
- Introduction and advanced level of MySQL (I)
- 数字经济时代的开源数据库创新 | 2022开放原子全球开源峰会数据库分论坛圆满召开
- The switching language of unity causes an error: system FormatException:String was not recognized as a valid DateTime.
- 湖上建仓全解析:如何打造湖仓一体数据平台 | DEEPNOVA技术荟系列公开课第四期
- JVM tuning
- Introduction and advanced MySQL (7)
猜你喜欢

Xiaobai must see the development route of software testing

Meta Q2 earnings: revenue fell for the first time, and metaverse will compete with apple

AI 改变千行万业,开发者如何投身 AI 语音新“声”态

Three minutes to understand, come to new media

kotlin:Nothing

2022年中国企业服务产业市场行情

CTR click through rate prediction practice project of advertising recommendation!

Apple develops a complete creation process of Apple certificate and description file

Introduction and advanced MySQL (7)

Example of observer mode of C -- ordering milk
随机推荐
It is said that software testing is the worst in the IT industry. Is that so?
4 年后,Debian 终夺回“debian.community”域名!
Configuration tutorial: how does the organizational structure of the new version of easycvr (v2.5.0) cascade to the superior platform?
Mongodb initialization
MYSQL入门与进阶(九)
Introduction and advanced level of MySQL (8)
十进制转二进制进阶版(可转化负数以及边界值)
How to use the white list function of the video fusion cloud service easycvr platform?
MySQL index usage and optimization
112. 使用自开发的代理服务器解决 SAP UI5 FileUploader 上传文件时遇到的跨域访问错误
LeetCode_63_不同路径Ⅱ
One Hot编码是什么?为什么要用它,什么时候用它?
EasyNLP中文文图生成模型带你秒变艺术家
2022-07-27 study notes of group 4 self-cultivation class (every day)
New upgrade! The 2022 white paper on cloud native architecture was released
What kind of knowledge payment system functions are more conducive to the development of the platform and lecturers?
MYSQL入门与进阶(四)
微信安装包11年膨胀575倍,UP主:“98%的文件是垃圾”;苹果应用商店被曝大量色情App;四大科技巨头呼吁废除闰秒|极客头条...
Gaode map realizes customized small blue dots, customized point markers, drawing polygon / circular areas, and displaying or hiding customized point markers according to the movement of the map
使用自开发的代理服务器解决 SAP UI5 FileUploader 上传文件时遇到的跨域访问错误试读版