New RAM Section "myCodeInRAM" is created in the ram and i am able to assign specific object to this memory section with below code.
#pragma section ".myCodeInRAM" data_mode=far_abs __declspec(section ".myCodeInRAM") unsigned char data0;
Now i have Number of variables which need to be assigned to this section. Is there a mechanism by which i can avoid specifying __declspec(section ".myCodeInRAM") as prefix for every variable?
已解决! 转到解答。
Hi,
I found the root cause of your problem. You have to place the declaration of the variables to the pragma. So delete the pragma from file SPIR_Interface.c and place it to SPIR_Interface.h
In SPIR_Interface C will be following code:
uint16_t VaSPIR_Cnt_CellVolt[360];
uint16_t VaSPIR_Cnt_CellVoltPEC[120];
uint16_t VeSPIR_Cnt_StrVolt;
uint8_t VeSPIR_Cnt_StrVoltSt;
uint16_t VeSPIR_Cnt_LinkVolt;
uint8_t VeSPIR_Cnt_LinkVoltSt;
and in SPIR_Interface.h will be:
#pragma push
#pragma section all_types ".__my_ram" ".__my_ram" data_mode=far_abs code_mode=far_abs
extern uint16_t VaSPIR_Cnt_CellVolt[360];
extern uint16_t VaSPIR_Cnt_CellVoltPEC[120];
extern uint16_t VeSPIR_Cnt_StrVolt;
extern uint8_t VeSPIR_Cnt_StrVoltSt;
extern uint16_t VeSPIR_Cnt_LinkVolt;
extern uint8_t VeSPIR_Cnt_LinkVoltSt;
#pragma pop
Regards,
Martin
Hi,
I am not able to reproduce your issue on my side. Could you please create simple example and post it here? I will try to investigate deeper. From the files you shared, I am not able to reproduce it.
I tried to use your variables and insert to my project. I had to place the variables to FORCEACTIVE in linker file because of linker garbage collector, but I see the variables placed in correct section.
Regards,
Martin
Hello martin,
As Requested I am attaching Sample project. Following are observation.
I have used #pragma section in Main.c file. All that variable are correctly allocated in RAM
Same #pragma used in BSW/SPIR_Interface.c However at this time those variables are assigned to .bss Section
Appreciate all your Support.
Thanks and Best Regards,
Makarand Phadke
Embedded Software Engineer
Hi,
I found the root cause of your problem. You have to place the declaration of the variables to the pragma. So delete the pragma from file SPIR_Interface.c and place it to SPIR_Interface.h
In SPIR_Interface C will be following code:
uint16_t VaSPIR_Cnt_CellVolt[360];
uint16_t VaSPIR_Cnt_CellVoltPEC[120];
uint16_t VeSPIR_Cnt_StrVolt;
uint8_t VeSPIR_Cnt_StrVoltSt;
uint16_t VeSPIR_Cnt_LinkVolt;
uint8_t VeSPIR_Cnt_LinkVoltSt;
and in SPIR_Interface.h will be:
#pragma push
#pragma section all_types ".__my_ram" ".__my_ram" data_mode=far_abs code_mode=far_abs
extern uint16_t VaSPIR_Cnt_CellVolt[360];
extern uint16_t VaSPIR_Cnt_CellVoltPEC[120];
extern uint16_t VeSPIR_Cnt_StrVolt;
extern uint8_t VeSPIR_Cnt_StrVoltSt;
extern uint16_t VeSPIR_Cnt_LinkVolt;
extern uint8_t VeSPIR_Cnt_LinkVoltSt;
#pragma pop
Regards,
Martin
Hi,
you can use following construction:
#pragma push
#pragma section all_types ".__myRAM" ".__myRAM"
unsigned int my_var1;
unsigned int my_var2;
unsigned int my_var3;
#pragma pop
Instead of all_types you can specify section data type, for example data_type, sdata_type, etc.
If you have any other questions, please feel free to write me back.
Regards,
Martin
Hello Martin,
Below Solution did not work. I tried with both sdata_type and data_type. Linker is placing this variables in “.bss” section instead of ".__myRAM"
Does it require some Compiler setting?
Thanks and Best Regards,
Makarand Phadke
Hi,
because you mix different data types (not all of them are sdata) in your section, I recommend you to use #pragma section all_types ".__myRAM" ".__myRAM" instead of sdata_type.
Regards,
Martin
Used all_types as suggested still the same results. No variable is assigned to ".__my_ram" section.
#pragma push
#pragma section all_types ".__my_ram" ".__my_ram" data_mode=far_abs code_mode=far_abs