I would like to locate a table of constant values with application data (equipment information), preferably at the end of the vector table.
In startup.s
I do the following:
MODULE ?cstartup
;; Forward declaration of sections.
SECTION CSTACK:DATA:NOROOT(3)
SECTION .intvec:CODE:NOROOT(2)
EXTERN __iar_program_start
EXTERN SystemInit
PUBLIC __vector_table
PUBLIC _InfoEqData
DATA
__vector_table
DCD sfe(CSTACK)
DCD Reset_Handler ; Reset Handler
/* ............... */
DCD LCD_IRQHandler ; LCD
DCD USB_IRQHandler ; USB
__vector_table_end
_InfoEqData EQU __vector_table_end
In main.c
I do the following:
#pragma location = _InfoEqData
const EqIdentify_t eqIdentify = { ... }
When I compile the code shows the following (expected) error
Error[Pe020]: identifier "_InfoEqData" is undefined ... \tst_vBus_main.cpp 25
How do I tell the compiler to find that identifier from startup.s
?
Thanks in advance
The IAR toolchain supports #pragma location
1 only to fix data at absolute addresses given by literal numbers2 or segment names3.
From my point of view, you should define an own segment in the linker command file3 and locate it according to your requirements.
1 IAR C/C++ Compiler User Guide for the 8051Microcontroller Architecture (C8051-7), Seventh edition: March 2017, page 372.
2 ibid., Seventh edition: March 2017, page 260.
3 ibid., Seventh edition: March 2017, page 262.
4 IAR Linker and Library Tools Reference Guide (XLINK-5001), April 2010, page 21.