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 all, I have to include an ASM file into my C project, this ASM file cannot be modified since it is also a part of another project using this same file. the ASM file is asm_inc.h and contains only some defines : FW_VERSION EQU 0 FW_SUB_VERSION EQU 9 HW_VERSION EQU 1 I need to use these defines into a C table, defined as follow : unsigned char code identity[] = { FW_VERSION,FW_SUB_VERSION,HW_VERSION }; The problem is that I cannot see these defines from my C file : error C202: 'FW_VERSION': undefined identifier error C202: 'FW_SUB_VERSION': undefined identifier error C202: 'HW_VERSION': undefined identifier I've tried to include this asm file directly into my C file with no success How can I include this ASM definitions into my C file ? thanks to all J
EQU is not part of the 'C' programming language (nor even Keil's extensions) so there is no way you can use this in a 'C' source file! "I need to use these defines into a C table, defined as follow:"
unsigned char code identity[] = { FW_VERSION,FW_SUB_VERSION,HW_VERSION };
extern char code identity[];
While the C51 compiler cannot handle assembly language EQUates, the Ax51 assembler can handle C preprocessor #defines. Try: #define FW_VERSION 0 #define FW_SUB_VERSION 9 #define HW_VERSION EQU 1 I'd declare the information in C with a struct rather than an array.
typedef struct { U8 firmwareVersion; U8 firmwareSubVersion; U8 hardwareVersion; } VersionInfo; extern VersionInfo versionInfo;
"Define the actual table in a .c or .a51 file as you prefer." If you need to fix this table at a certain address, it will be easier to use .a51.
When declaring the array in assembler I get memory overlap issues : C declaration using the BL51 locate directive doenst produce these memory overlaps : EXEMPLE 1 : C DECLARATION ************************* header file is : ---------------- #define FW_VERSION 0 #define FW_SUB_VERSION 9 C file is : ----------- unsigned char code identity[] = { FW_VERSION,FW_SUB_VERSION}; then I use ?CO?IDENTITY(00080h) in project -> OPTION -> BL51 LOCATE -> CODE in order to compile identity[] at fixed code address 0x0080 >> This doesnt produce any memory overlap and works fine EXEMPLE 2 : ASM DECLARATION *************************** ASM file is : ------------- FW_VERSION EQU 0 FW_SUB_VERSION EQU 9 public identity ORG 80H identity: DB FW_VERSION,FW_SUB_VERSION END C file is : ----------- extern unsigned char code identity[]; This second example results in memory overlaps, this is what I do not understand since the BL51 locate directive used with the 'C' declarartion method doesnt produce this overlaps and should do the same thing ... Any idea greatly appreciated thanks
what overlaps?
*** WARNING L5: CODE SPACE MEMORY OVERLAP FROM: 0000H TO: 0002H *** WARNING L5: CODE SPACE MEMORY OVERLAP FROM: 000BH TO: 008AH *** WARNING L5: CODE SPACE MEMORY OVERLAP FROM: 0023H TO: 008AH *** WARNING L5: CODE SPACE MEMORY OVERLAP FROM: 0033H TO: 008AH *** WARNING L5: CODE SPACE MEMORY OVERLAP FROM: 003BH TO: 008AH *** WARNING L5: CODE SPACE MEMORY OVERLAP FROM: 0043H TO: 008AH *** WARNING L5: CODE SPACE MEMORY OVERLAP FROM: 004BH TO: 008AH Program Size: data=222.7 xdata=1756 code=6546 creating hex file from "ez_usb_v10"... User command #1: HEX2BIX.EXE -i -o ez_usb_v10_B2.iic ez_usb_v10.hex Intel Hex file to EZ-USB Binary file conversion utility Copyright (c) 1997-1999, Cypress Semiconductor Inc. 6474 Bytes written. Total Code Bytes = 6418 Conversion completed successfully.
You need to look more deeply into the map file to see precisely what is overlapping.
Looks like you have defined the interrupt and startup vectors in more than just one assembler source file. Note that the C51 compiler will add the STARTUP.A51 file that also contains a startup vector.