当前位置:网站首页>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


边栏推荐
- LVS manual
- redis优势以及数据结构相关知识
- Introduction and advanced level of MySQL (10)
- Xiaobai must see the development route of software testing
- 112. Use the self-developed proxy server to solve the cross domain access error encountered when uploading files by SAP ui5 fileuploader
- Gateway入门
- Log base zap of go language series
- 1.3 linked list
- Ue5 gas learning notes 1.9 skill system global classes (abilitysystemglobals)
- 1.2、队列
猜你喜欢

NPM cannot recognize the "NPM" item as the name of a cmdlet, function, script file, or runnable program. Please check the spelling of the name. If the path is included, make sure the path is correct,

MYSQL入门与进阶(七)

广告推荐CTR点击率预测实践项目!

Interviewer: what are the usage scenarios of ThreadLocal? How to avoid memory leakage?

Chinese enterprise service industry market in 2022

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

数字经济时代的开源数据库创新 | 2022开放原子全球开源峰会数据库分论坛圆满召开

我的创作纪念日 -- 2022年7月25日

2022-07-27 第四小组 修身课 学习笔记(every day)

面试官:ThreadLocal使用场景有哪些?内存泄露问题如何避免?
随机推荐
MySQL date function
redis优势以及数据结构相关知识
MYSQL入门与进阶(四)
Meta Q2财报:营收首次下滑,Metaverse将与苹果竞争
Introduction and advanced level of MySQL (I)
广告推荐CTR点击率预测实践项目!
Is there any prospect and way out for software testing?
Introduction and advanced level of MySQL (6)
What if you don't understand the difference between modularity, componentization and plug-in?
Log base zap of go language series
EasyNLP中文文图生成模型带你秒变艺术家
十进制转二进制进阶版(可转化负数以及边界值)
先验、后验、似然
Ue5 gas learning notes 1.6 skills gameplay ability
2022-07-27 第四小组 修身课 学习笔记(every day)
1.1. Sparse array
APP为什么用JSON协议与服务端交互:序列化相关知识
Redis cache avalanche, penetration, breakdown, bloom filter, detailed explanation of distributed lock
LeetCode_ 1137_ Nth teponacci number
PyQt5快速开发与实战 5.3 多线程