(*(void(*)())0) () Explanation - Alternative reset of MCU

Publisher:创意航海Latest update time:2015-07-02 Source: 51heiKeywords:void Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The hardware address jumps to 0

(*(void(*)())0) ();

 

Prerequisites

float (*h)();

Indicates that h is a pointer to a function that returns a float value.

(float(*)())

A type conversion symbol that represents a "pointer to a function that returns a float value"

 

 

Assuming fp is a function pointer, how to call the function pointed to by fp is as follows:

 (*fp)();

 

According to people's habitual thinking, we can write

(*0)();

 

The above formula does not work because the operator * must take a pointer as an operand, and this pointer must be a function pointer. So we have to force 0 to be converted into a function pointer (a pointer to a function with a return value of type void)

 

Assume fp is a float pointer, declared as follows

float * fp;

 

Force 0 to be converted into a float pointer (just remove the variable fp)

(float *)0;

 

similar:

Assume that fp is a pointer to a function of type void), the declaration is as follows:

void (*fp)();     

 

Force 0 to be converted into the function pointer (just remove the variable fp)

(void(*)())0

 

Finally, replace fp with (void(*)())0 to get the usage of calling

(*(void(*)())0) ();

 

 

 

 

Typedef can be used to simplify function pointers

For example:

typedef char * string;

 

string test="hello";

 

similar

typedef void(*func)(); // In this way, func represents the type of a function pointer

 

(*(func)0)();

 

 

example

method one:

typedef void (*pfunction)(void);

 

 void FMI_Jump(void)
{   
  pfunction jump;
  jump=(pfunction)(0x80000);
  jump();
  
}

 

 Method Two:

((void(code *)(void))0xF400)();

Keywords:void Reference address:(*(void(*)())0) () Explanation - Alternative reset of MCU

Previous article:Problems with while(1) in C language for microcontrollers
Next article:Time scheduling architecture, good stuff

Recommended ReadingLatest update time:2024-11-16 22:25

61-Heart rate and pulse measurement based on 51 single chip microcomputer and Bluetooth APP upload design
Specific implementation functions The system consists of STC89C52 single-chip microcomputer circuit + LCD1602 liquid crystal display circuit + pulse/heart rate sensor circuit + LM393 comparator module circuit + DS18B20 temperature sensor circuit + power supply circuit. (1) Detect pulse/heart rate through pulse/heart
[Microcontroller]
61-Heart rate and pulse measurement based on 51 single chip microcomputer and Bluetooth APP upload design
Design of a mobile phone Bluetooth remote control car controlled by 51 single chip microcomputer
Without further ado, here are the pictures of the real thing 1. Project Components List 1. Buy a smart car chassis from Taobao (my car is four-wheel drive, so it has four motors, two acrylic plates and some accessory screws) 2. Two L298n modules (one 298 controls two motors) 3. HC-06 Bluetooth module 4. Battery bo
[Microcontroller]
Design of a mobile phone Bluetooth remote control car controlled by 51 single chip microcomputer
ATmega 16 MCU SPI related registers (Part 9)
1.SPCR——SPI Control Register          SPIE SPE DORD MSTR CPOL CPHA SPR1 SPR0 Bit 7 - SPIE: Enable SPI Interrupt When set, an SPI interrupt is triggered whenever the SPIF bit in the SPSR register and the global interrupt enable bit in the SREG register are set. Bit 6 - SPE: Enable SPI Setting SPE enables the SPI.
[Microcontroller]
LED Graphic Display Screen Control System Based on MCU and FPGA
  introduction   At present, small and medium-sized LED display systems on the market generally use traditional single-chip microcomputers as the main control chip. For large-screen LED display screens, due to the large amount of data transmission, fast scanning speed is required, while the internal resources of the
[Microcontroller]
LED Graphic Display Screen Control System Based on MCU and FPGA
C51 MCU————Timer Counter
51 MCU timer/counter Timing (timing control, measurement, delay, etc.) and counting (counting the number of external events). Software Timing | Digital Circuit Timing | Programmable Timer/Counter How are they achieved? Uh! Guess . . . Software Timing The machine executes a program that has no other use but to dela
[Microcontroller]
C51 MCU————Timer Counter
Can the MCU get out of the recession in Q2?
In 2023, the new energy vehicle market will be in sharp contrast to the weak demand in the consumer electronics market. 新能源汽车的强势发展也带动了车规级 MCU 的大量市场需求。MCU在各种 嵌入式 控制和运算设备上应用广泛,包括汽车系统、 传感器 上的成长显著。2019年,MCU产值全球疲软,年减7%,2020年因新冠肺炎影响,产值再度减少2%。不过MCU在2021年迎来强势反弹,达到202亿美元,年增27%,增幅创下2000年以来新高,而且平均售价(ASP)年增12%,为1990年中期以来最大的增幅。
[Automotive Electronics]
Can the MCU get out of the recession in Q2?
atmega48 microcontroller features atmega48 low power design
This article mainly introduces the characteristics of atmega48 microcontroller, puts forward the general method of its low power design, and takes the design of timing control system as an example to specifically explain the low power design scheme of atmega48. With the development of microelectronics and computer t
[Microcontroller]
atmega48 microcontroller features atmega48 low power design
Design of electronic alarm clock based on single chip microcomputer
1. System Function Requirements The task requirements of the computer clock are: once the system is running, it starts timing from 00:00:00, and displays the current values ​​of hours, minutes, and seconds on the digital tube. 2. System Overall Plan 1. Clarify the tasks Basic working principle: ever
[Microcontroller]
Design of electronic alarm clock based on single chip microcomputer
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号