重置在嵌入式系统中会发生什么? [英] On reset what happens in embedded system?

查看:182
本文介绍了重置在嵌入式系统中会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于上电,我对有关复位有疑问:



1.我知道微控制器是硬连线的,可以从某些特定的内存位置开始说0000H的电源向上。在0000h,中断服务程序是否被写入复位(堆栈指针和程序计数器等的初始化)或复位地址在0000h(例如7000),以便微控制器跳转到7000地址,堆栈和PC的初始化被写入。



2.写这个重置服务程序?是微控制器芯片(英特尔还是微芯片等)的制造商,还是任何程序员都可以改变这个复位服务程序(例如,程序员将电脑从7000h升级到4000h,导致从4000取代第一条指令, 7000)。



3.将堆栈指针和程序计数器初始化为相应的初始地址,因为上电时微控制器不处于堆栈的状态指针和程序计数器寄存器(直到复位服务程序没有初始化)。


  1. 考虑到所有可能性,重置服务程序中的步骤应该如何?

提前感谢

解决方案

参考您的编号:


  1. 硬件复位过程取决于处理器,将在该部分的数据手册或参考手册中完整描述,但您的描述通常<


  2. 虽然一些微控制器包括一个基于ROM的引导加载程序,可能包含启动代码,通常这样的引导程序仅用于通过通信端口加载代码,直接对闪存进行编程,或者将辅助引导加载程序加载到RAM,然后再对程序闪存进行编程。就C运行时启动而言,这可以是编译器/工具链提供的,也可以在汇编程序中自己编写。通常即使编译器供应商提供启动代码,它也将作为源组合提供,并与应用程序链接。编译器供应商不能总是知道存储器映射,SDRAM映射和时序,或者处理器时钟速度,或者硬件中使用什么振荡器晶体的东西,因此启动代码通常需要通过初始化存根进行定制或扩展,您必须实现您的硬件。


  3. 在ARM Cortex-M设备上,实际上初始的PC和堆栈指针实际上由硬件加载,它们存储在复位地址并加电上电。然而,在一般情况下,您是正确的,复位地址包含启动代码或启动代码的向量,在Cortex ARM架构之前,复位地址实际上包含跳转指令而不是真正的向量地址。无论哪种方式,C / C ++运行时的启动代码至少要初始化堆栈指针,初始化静态数据,执行任何必需的C库初始化并跳转到main()。在C ++的情况下,它还必须在调用main()之前执行任何全局静态对象的构造函数。



I have a doubt regarding the reset due to power up:

1.As i know that microcontroller is hardwired to start with some particular memory location say 0000H on power up. At 0000h, whether interrupt service routine is written for reset(intialization of stack pointer and program counter etc) or the reset address is there at 0000h(say 7000) so that micro controller jumps at 7000 address and there initialization of stack and PC is written.

2.Who writes this reset service routine? Is it the manufacturer of microcontroller chip(Intel or microchip etc) or any programmer can change this reset service routine(For example, programmer changed the PC to 4000h from 7000h on power up reset resulting into the first instruction to be fetched from 4000 instead of 7000).

3.how the stack pointer and program counter are initialized to the respective inital addresses as on power up microcontroller is not in the state to put the address into stack pointer and program counter registers(there is no intialization done till reset service routine).

  1. What should be the steps in the reset service routine considering all possibilities?

Thanks in advance

解决方案

With reference to your numbering:

  1. The hardware reset process is processor dependent and will be fully described in the data sheet or reference manual for the part, but your description is generally the case - different architectures may have subtle variations.

  2. While some microcontrollers include a ROM based boot-loader that may contain start-up code, typically such bootloaders are only used to load code over a communications port, either to program flash memory directly or to load and execute a secondary bootloader to RAM that then programs flash memory. As far as C runtime start-up goes, this is either provided with the compiler/toolchain, or you write it yourself in assembler. Normally even when start-up code is provided by the compiler vendor, it is supplied as source to be assembled and linked with your application. The compiler vendor cannot always know things like memory map, SDRAM mapping and timing, or processor clock speed or what oscillator crystal is used in your hardware, so the start-up code will generally need customisation or extension through initialisation stubs that you must implement for your hardware.

  3. On ARM Cortex-M devices in fact the initial PC and stack-pointer are in fact loaded by hardware, they are stored at the reset address and loaded on power-up. However in the general case you are right, the reset address either contains the start-up code or a vector to the start-up code, on pre-Cortex ARM architectures, the reset address actually contains a jump instruction rather than a true vector address. Either way, the start-up code for a C/C++ runtime must at least initialise the stack pointer, initialise static data, perform any necessary C library initialisation and jump to main(). In the case of C++ it must also execute the constructors of any global static objects before calling main().

这篇关于重置在嵌入式系统中会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆