Hello,
is it possible to write a program with the small-memory-model, to declare some variables as xdata and to declare an char array[256] of pdata?
Best regards, Stefan
It's all in the Manual:
http://www.keil.com/support/man/docs/c51/c51_le_memmodels.htm
http://www.keil.com/support/man/docs/c51/c51_xc_memmodel.htm
But why does the following program not work?! When I choose "xdata" for the array "dscrc_table" in the file "crc.c", the program works properly, but with "pdata" it doesn't.
Downlooad-Link: www.fileuploadx.de/223225
Because there's a bug in your software, or Because there's a bug in your hardware, or Both of the above!
Please post your source here - taking care to follow the instructions - rather than some site laden with advertising pop-ups.
:-(
What size is the array?
dscrc_table is surely constant data. You should be able to declare it as const and locate it in code space (usually rom).
"...to declare an char array[256] of pdata?"
Yes, but in doing so, you will be consuming all of the memory space permitted to the pdata memory class.
See:
http://www.keil.com/support/man/docs/c51/c51_le_pdata.htm
C allows pointers to point one step past the last element of an array. I wonter what C51 does in this case.
The pdata type uses the @Rn for access, so it's almost certainly going to wrap around to the start of the 256 byte block.
Okay, I tried it with "code" and now it works (at least it seems to work ;-))... But I still do not understand why it causes problems to declare this array of 256 bytes an pdata. I do not need any more pdata-variables (maybe the compiler needs morre pdata-space, but I don't think so...)
Many controllers with "internal external RAM" have special addressing schemes (usually a SFR) for the high byte of movx @Ri. Some of those may not be supported by the compiler.
Erik
As Erik suggested, are you sure that your PDATA works correctly?
If your PDATA isn't working (properly) then, obviously, you will get problems with anything that you place into PDATA...!
Hm... I don't know how to test this... I use the AN2131 from Cypress and it has an 8151-core, maybe you know wether pdata is supportet or not ;-)
In that case, you need to ask Cypress!
do a oneliner that uses one pdata variable and have a look at the generated assembler. Then have a look in the Cypress datasheet and see if the generated code access pdata the correct way for this chip.
Hi, i tried it with a single pdata-variable and the result is the following:
005D 7800 R MOV R0,#LOW test 005F 7405 MOV A,#05H 0061 F2 MOVX @R0,A
I'm not experienced in assembler, so do you think this access is right? Note: Itried it also with an array... with a char array[11] the program works, with a char array[12] it doesn't...
... you can not use pdata AND xdata in the same project.
the reason could be that you do not show the whole assembly (the complete 'C' would be nice too), otherwise
Look up in the manuals if I am right "PDATA requires that the high address register/port/SFR is zero THROUGHOUT the project"
ALSO, it seems that you have an address of yout PDATA variable greater than 256, otherwise why the #LOW