打印
[牛人杂谈]

Nuvoton微控制器的闪存编程

[复制链接]
1269|8
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
ddw315|  楼主 | 2023-11-10 10:30 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式


前言:
现代微控制器利用闪存代替EEPROM作为代码存储器,实现了代码存储器编程,而无需独立的程序员。
本文将介绍Nuvoton MCU的原理和使用代码存储器编程的多种方式,同时请注意,不同品牌可能对下面使用的技术术语有不同的定义

基本知识
ICE
ICE通过外部调试探针(如Nu-Link, ST-LINK, J-Link或其他东西)启用处理器核心寄存器和内存访问。它可以帮助开发人员在不影响目标电路功能的情况下跟踪微控制器的执行状态。ICE的通用接口是ARM调试接口架构规范中规定的串行线调试端口(SW-DP或SWD)和JTAG-DP。Nuvoton的芯片通常提供SWD作为ICE接口。


闪存控制器(FMC)
FMC是系统存储器和片上闪存之间的接口,它允许我们通过FMC寄存器访问闪存,该寄存器已经位于系统内存映射中。




闪存组织
Flash memory organizationNuvoton的大部分芯片都有三种不同的闪存,包括approm、LDROM和Data flash。一般来说,APROM用于存储提供给目标应用程序的程序,LDROM用于存储将在应用程序之前执行的引导加载程序。数据Flash与approm共享,由DFBA在配置位中确定,用户可以编程,并且可以通过ISP命令编程,不需要解锁approm的写权限。


Chip Booting Selection (CBS)
配置位中的CBS决定了芯片的启动方式,有四种启动方式,包括带IAP的LDROM、不带IAP的LDROM、带IAP的APROM和不带IAP的APROM。如果芯片启动没有IAP模式,approm和LDROM将只有一个出现在系统内存映射中,这意味着只能在CPU执行其中的代码时自行访问它们。

Memory map
在大多数Nuvoton的芯片中,Flash Memory Map与System Memory Map不同。Flash Memory Map用于FMC访问Flash。系统内存映射就是CPU所要查看的。闪存可以映射到系统内存映射中,映射地址是通过配置位中的芯片引导选择(CBS)设置的。例如,LDROM的Flash Memory Map从0x00100000开始,可以通过在CBS中选择Boot from LDROM without IAP mode来映射到System Memory Map中的0x00000000。


In-System Programming (ISP)
FMC provide ISP Commands include read, erase, program, and vector remap. Accessing the FMC registers with corresponding commands and data via firmware or ICE can produce the flash memory programing. If you are doing APROM update by the firmware, it usually has a separate firmware called bootloader which located in LDROM to interact between FMC and the others peripheral such like UART, USB, CAN.
In-Circuit Programming (ICP)
ICP utilize the memory access feature of ICE, sending the ISP Commands direct to the FMC registers without firmware. It needs a programming tool (software) to handle the commands and data between host computer, debug probe and FMC registers. Nuvoton provide NuMicro ICP Programming Tool which can be download from their website. If you are using a brand-new chip, it’s supposed to to use the ICP to program your code.
In-Application Programming (IAP)
IAP brings more flexibility to the developers. If the IAP function is enabled by the CBS[0], the whole flash memory will appear in System Memory Map. This means CPU can executing the code in APROM, LDROM even the SRAM without rebooting the chip. IAP mode also let the APROM, LDROM even the SRAM able to map into a 512-byte of Vector Map Space. The Vector Map Space used for the Cortex-M Vector table which contains the reset value of the main stack pointer, the start addresse, and interrupt vector table. IAP brings more flexibility to the developers to customize the code executing location and the interrupt service routine.


Performing firmware updateNuMicro ICP Programming ToolNuMicro ISP Programming ToolISP bootloaderUARTUSBCANOpenOCD

参考代码
https://github.com/ZaleYu/OpenOCD-Nuvoton



TRM_M0A21_M0A23_Series_EN_Rev1.02.pdf

8.74 MB

使用特权

评论回复
沙发
yiy| | 2023-11-11 15:54 | 只看该作者
LDROM里出厂自带的有ISP吗

使用特权

评论回复
板凳
tpgf| | 2023-12-2 16:49 | 只看该作者
新唐的闪存编程有什么特别的地方吗

使用特权

评论回复
地板
wiba| | 2023-12-2 17:22 | 只看该作者
闪存编程需要的最低工作电压是多少啊

使用特权

评论回复
5
kxsi| | 2023-12-2 20:02 | 只看该作者
对闪存编程的好处或者说是优势是什么呢

使用特权

评论回复
6
coshi| | 2023-12-2 20:41 | 只看该作者
不是很能理解这个外部调试探针是什么概念

使用特权

评论回复
7
drer| | 2023-12-2 21:23 | 只看该作者
闪存和eeprom的区别是什么呢

使用特权

评论回复
8
qcliu| | 2023-12-2 22:11 | 只看该作者
为什么都是英文资料 没有中文版本的吗

使用特权

评论回复
9
EmmaTT| | 2023-12-6 10:33 | 只看该作者
qcliu 发表于 2023-12-2 22:11
为什么都是英文资料 没有中文版本的吗

跟国际接轨

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:原厂技术支持

71

主题

402

帖子

5

粉丝