We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I am trying to modify the example <apnt_180_test> from keil to exercise the ISP function.
When i add my golbal variables definition in boot loader, the application asm code will add one statment to jump to ?C_START, cause the program flow back to boot loader and can't return.
But declare the global variables only without giving them initial values, the jump statement won't be generated by complier, and program flow runs as expected.
i am wondering this might from the startup.asm. Does anyone having this problem before, and how to solve it?
Thanks very much. YC
Hi, Erik,
because i would like the app1.c to access to the global variables defined in boot.c, i add two variables: a1 and a2 to test if my intention can work.
result: It can't work if i given a1 and a2 the initial values, the control flow won't be able to jump to the routine: app_main.
the source comes from the keil example code "multi-application programming", see application note 180.
======boot.c==============================
extern void app_main (void); extern int app_func1 (int i1, int i2); int ar[4]; int a1 = 1; int a2 = 2; void boot_func1 (void) { int f1_a [5]; f1_a[0] = 0; } void boot_func2 (void) { int f2_a [5]; f2_a[0] = 0; } void main (void) { boot_func1 (); app_main (); // call main appliation function (initialize) boot_func2 (); ar[1] = app_func1 (3, 4); while (1) { ; } }
========app1.c=================
extern void boot_func1 (void); // function in Boot_Loader called from Application extern void boot_func2 (void); // function in Boot_Loader called from Application extern int a1; extern int a2; char c1, c2; char *p1 = &c1; char *p2 = &c2; void main (void) { p1 = &c1; p2 = &c2; *p1 = *p2; boot_func2 (); boot_func1 (); } int app_func1 (int i1, int i2) { return (i1 + i2); }
======== build message of application part====== Build target 'Application' compiling app1.c... assembling STARTUP_Lite.A51... assembling App1Call.Asm... linking... *** WARNING L16: UNCALLED FUNCTION, IGNORED FOR OVERLAY PROCESS NAME: MAIN/APP1 *** WARNING L16: UNCALLED FUNCTION, IGNORED FOR OVERLAY PROCESS NAME: ?C_INITSEG Program Size: data=16.0 xdata=0 const=0 code=65 ".\Object_App1\..\app1" - 0 Error(s), 2 Warning(s).
========= toolchain info======
IDE-Version: 猩ision3 V3.51 Copyright (c) Keil Elektronik GmbH / Keil Software, Inc. 1995 - 2007
Tool Version Numbers: Toolchain Path: C:\Keil\C51\BIN\ C Compiler: C51.Exe V8.08 Assembler: A51.Exe V8.00d Linker/Locator: LX51.Exe V4.10a Librarian: LIBX51.Exe V4.24 Hex Converter: OHX51.Exe V1.36b CPU DLL: S8051.DLL V3.11 Dialog DLL: DP51.DLL V2.49 Target DLL: BIN\MON51.DLL V2.41 Dialog DLL: TP51.DLL V2.49
try writing a small assembler module with the 2 variables you want and link it with both boot and app. You have total control in assembler, not in C
Erik