Hi again. I have a custom 8051 processor which has defined a series of sfr, such as "sfr id_custom = 0x32" in the header reg51.h file. When I tried to access from C, throws the error "Error 146: Invalid Base Address". As I can do to disable this protection? or enabling the access to these registers? Thanks.
PS: Sorry about my english. =)
a custom 8051 processor which has defined a series of sfr, such as "sfr id_custom = 0x32" in the header reg51.h file.
Then you need to complain to whoever made that file --- it's broken. There is no SFR at that address.
"Then you need to complain to whoever made that file --- it's broken. There is no SFR at that address."
Note that the original post said "custom 8051 processor". So maybe someone did something less clever, when designing their own chip in programmable logic. Maybe this poor processor designer have placed a sfr in the middle of normal data addresses, just to make life interesting for the compiler/linker.
That's not true, if I compile with the $NOMOD51 param, in an assembly file, the sfr declared like that work well. Moreover, the entire soft was in A51, now I'm trying to pass it to C, and I encountered this little things... Gonzalo.
Maybe this poor processor designer have placed a sfr in the middle of normal data addresses
They can't have, because whatever they placed there is not an SFR. It's a memory-mapped peripheral in a spectacularly poorly chosen place, but not an SFR.
No, it does not.
By Definition, any thing at any address less that 0x80 is not an SFR.
Semantics (My Opinion)
However since the compiler will assume in is RAM you will have to reserve all of them so the compiler does not use them as RAM. This may make the compiler unhappy when it tries to setup the RAM and stack. You may have some issues with the small memory model.
ASM allows you to work around more things. Compilers have expectations.
A Look at how chip makers solved the same issue may help if it is your chip.
SiLabs use paging of the SFR space.
Triscend, IIRC, gave you the choice to have your custom peripherals appear as SFRs, or as memory-mapped in DATA or XDATA space...