|
|||||||||||
Technical Support Support Resources
Product Information |
C51: Call C Functions within Startup CodeInformation in this article applies to:
QUESTIONI am using a 80C51RD with on-chip Flash and XRAM. In addition, I have an 32KByte external XDATA RAM. The external XDATA RAM is connected to an FPGA which requires programming before I can access it. This FPGA programming routine is part of the initialization code that I do at the beginning of the C main function. However, I am now facing a problem: The initializations of xdata variables in this external XDATA RAM is performed within the INIT.A51 file, and since it is called before main from the STARTUP.A51 code, my initialization fails. Since I would prefer to stay in C with the FPGA initialization, I have a question: Is it possible to call a C function within the STARTUP code before the INIT.A51 gets executed? ANSWERYes, you can basically call a C function after you have set the stack pointer (done in STARTUP.A51 with the instruction MOV SP,#?STACK). Change the STARTUP.A51 file as follows and add it to your project.
Note: You may remove the stack pointer initialization at the end of the STARTUP file since it is moved to the beginning of the startup code. SEE ALSOLast Reviewed: Thursday, February 25, 2021 | ||||||||||
|
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.