Hi all
Right now I'm using Keil C51 to compile the 8051 core which is inside the
T5 microcontroller.
I want to compile via SDCC. Tell me what should I do?
I have such an archive that is copied to the root of keil uv 5
In a nutshell, you have to identify Keil-specific features used by your code base and translate the respective parts to SDCC's syntax or – better still – use device/include/mcs51/compiler.h to create somewhat portable code.
The main purpose of compiler.h is to abstract compiler differences away so that you can use the same code base with multiple compilers, going forward.
You can take a look at that file and SDCC's manual for details.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the answer.
I studied the source code of the configuration file (.CDB).
It looks like a regular 8051
All I need is transfer these parameters to SDCC ?
No, you will almost certainly have to alter the source code itself, too.
Specifically, e.g. everything that tells the compiler to put something in a particular address space (like __data in SDCC) will have a slightly different notation.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I read about changing the code. There are no problems with this. Now I'm more concerned about setting parameters (CLOCK(24000000) MODC2 PMW DPC BSE MDU_R515, etc.). I'm still looking for documentation on this.
UPD: Do I understand correctly that setting the processor frequency is needed only for debugging?
Other directives (MODC2 PMW DPC BSE MDU_R515) are also not needed in SDCC?
Last edit: Miroslav 2023-03-06
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Unfortunately, I did not immediately notice the main page https://sdcc.sourceforge.net/ and the documentation that is there.
I ported (described the registers) for this unusual (for me) 8051 T5 controller.
However, the generated file does not run on my debug board.
I would be grateful if you help me.
This is just a sketch, so the code is not pretty https://www.sendspace.com/file/nvetts
It works in Keil C51 UV5.
I cannot help you much with MCS-51 programming, but the combination --xram-loc 0x8000 --xram-size 0xFFFF looks a bit fishy to me, especially because it does not align with Off-chip Xdata memory, Ram: Start:0x8000 Size:0x8000.
If the startup code from SDCC's own library is not sufficient, SDCC also has the __sdcc_external_startup mechanism (called _sdcc_external_startup until recently), where the startup code calls a function of that name if it is present.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The srec_cat warning is just that, a (very pedantic IMHO) warning. Srec_cat is perfectly capable of reordering the data. As long as it does not find overlapping data you should be fine.
I don't know what HDATA is. Look it up in the Keil manual. But I doubt you will need it.
You don't need to create the LJMP C_START.
If you need those constant bytes in code memory you can use:
Hi all
Right now I'm using Keil C51 to compile the 8051 core which is inside the
T5 microcontroller.
I want to compile via SDCC. Tell me what should I do?
I have such an archive that is copied to the root of keil uv 5
https://www.sendspace.com/file/p17cnb
In a nutshell, you have to identify Keil-specific features used by your code base and translate the respective parts to SDCC's syntax or – better still – use
device/include/mcs51/compiler.h
to create somewhat portable code.The main purpose of
compiler.h
is to abstract compiler differences away so that you can use the same code base with multiple compilers, going forward.You can take a look at that file and SDCC's manual for details.
Thanks for the answer.
I studied the source code of the configuration file (.CDB).
It looks like a regular 8051
All I need is transfer these parameters to SDCC ?
No, you will almost certainly have to alter the source code itself, too.
Specifically, e.g. everything that tells the compiler to put something in a particular address space (like
__data
in SDCC) will have a slightly different notation.I read about changing the code. There are no problems with this. Now I'm more concerned about setting parameters (
CLOCK(24000000) MODC2 PMW DPC BSE MDU_R515
, etc.). I'm still looking for documentation on this.UPD: Do I understand correctly that setting the processor frequency is needed only for debugging?
Other directives (MODC2 PMW DPC BSE MDU_R515) are also not needed in SDCC?
Last edit: Miroslav 2023-03-06
Unfortunately, I did not immediately notice the main page https://sdcc.sourceforge.net/ and the documentation that is there.
I ported (described the registers) for this unusual (for me) 8051 T5 controller.
However, the generated file does not run on my debug board.
I would be grateful if you help me.
This is just a sketch, so the code is not pretty https://www.sendspace.com/file/nvetts
It works in Keil C51 UV5.
I think it's in the compiler settings.
Keil has the following settings:
HDATA - what does this mean for SDCC?
For SDCC I created a build.bat file
There is a feature, srec_cat.exe issues:
When compiling hex from Keil, there is no such warning.
Keil also has STARTUP_M5.A51:
How can I add this to SDCC?
Unfortunately, I don't know how it works yet and I don't know assembler.
Last edit: Miroslav 2023-03-06
I cannot help you much with MCS-51 programming, but the combination
--xram-loc 0x8000 --xram-size 0xFFFF
looks a bit fishy to me, especially because it does not align withOff-chip Xdata memory, Ram: Start:0x8000 Size:0x8000
.If the startup code from SDCC's own library is not sufficient, SDCC also has the
__sdcc_external_startup
mechanism (called_sdcc_external_startup
until recently), where the startup code calls a function of that name if it is present.The srec_cat warning is just that, a (very pedantic IMHO) warning. Srec_cat is perfectly capable of reordering the data. As long as it does not find overlapping data you should be fine.
I don't know what HDATA is. Look it up in the Keil manual. But I doubt you will need it.
You don't need to create the LJMP C_START.
If you need those constant bytes in code memory you can use: