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
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
Okay, here the whole assembly-code:
ASSEMBLY LISTING OF GENERATED OBJECT CODE ; FUNCTION main (BEGIN) ; SOURCE LINE # 35 ; SOURCE LINE # 36 0000 C2AF CLR EA ; SOURCE LINE # 39 0002 D2E8 SETB EUSB ; SOURCE LINE # 40 0004 900000 E MOV DPTR,#USBCS 0007 7404 MOV A,#04H 0009 F0 MOVX @DPTR,A ; SOURCE LINE # 41 000A 900000 E MOV DPTR,#USBIRQ 000D 741E MOV A,#01EH 000F F0 MOVX @DPTR,A ; SOURCE LINE # 42 0010 E4 CLR A 0011 900000 E MOV DPTR,#TOGCTL 0014 F0 MOVX @DPTR,A 0015 900000 E MOV DPTR,#IBNIEN 0018 F0 MOVX @DPTR,A 0019 900000 E MOV DPTR,#IBNIRQ 001C F0 MOVX @DPTR,A ; SOURCE LINE # 43 001D 900000 E MOV DPTR,#EPIO 0020 F0 MOVX @DPTR,A 0021 A3 INC DPTR 0022 740A MOV A,#0AH 0024 F0 MOVX @DPTR,A ; SOURCE LINE # 48 0025 D2AF SETB EA ; SOURCE LINE # 49 0027 D2A9 SETB ET0 ; SOURCE LINE # 50 0029 C28B CLR CT0 ; SOURCE LINE # 51 002B C291 CLR T0M ; SOURCE LINE # 52 002D E4 CLR A 002E F58A MOV TL0,A ; SOURCE LINE # 53 0030 F58C MOV TH0,A ; SOURCE LINE # 54 0032 D28C SETB TR0 ; SOURCE LINE # 56 0034 750001 R MOV LED_BLINK,#01H ; SOURCE LINE # 57 0037 750001 R MOV LED_COUNT,#01H ; SOURCE LINE # 59 003A 900000 E MOV DPTR,#PORTACFG 003D F0 MOVX @DPTR,A ; SOURCE LINE # 60 003E 900000 E MOV DPTR,#PORTCCFG 0041 F0 MOVX @DPTR,A ; SOURCE LINE # 61 0042 900000 E MOV DPTR,#OEA 0045 74FF MOV A,#0FFH 0047 F0 MOVX @DPTR,A ; SOURCE LINE # 62 0048 900000 E MOV DPTR,#OEC C51 COMPILER V8.17 MAIN 10/15/2009 20:15:02 PAGE 4 004B F0 MOVX @DPTR,A ; SOURCE LINE # 65 004C E4 CLR A 004D 90011B MOV DPTR,#var0 0050 F0 MOVX @DPTR,A ; SOURCE LINE # 66 0051 A3 INC DPTR 0052 F0 MOVX @DPTR,A ; SOURCE LINE # 67 0053 A3 INC DPTR 0054 F0 MOVX @DPTR,A ; SOURCE LINE # 68 0055 A3 INC DPTR 0056 F0 MOVX @DPTR,A ; SOURCE LINE # 69 0057 A3 INC DPTR 0058 F0 MOVX @DPTR,A ; SOURCE LINE # 70 0059 A3 INC DPTR 005A F0 MOVX @DPTR,A ; SOURCE LINE # 71 005B A3 INC DPTR 005C F0 MOVX @DPTR,A 005D ?C0001: ; SOURCE LINE # 74 ; SOURCE LINE # 75 ; SOURCE LINE # 76 005D 7800 R MOV R0,#LOW test 005F 7405 MOV A,#05H 0061 F2 MOVX @R0,A ; SOURCE LINE # 77 0062 90011E MOV DPTR,#var3 0065 E0 MOVX A,@DPTR 0066 04 INC A 0067 F0 MOVX @DPTR,A ; SOURCE LINE # 93 0068 80F3 SJMP ?C0001 006A 22 RET ; FUNCTION main (END) ; FUNCTION T0_isr (BEGIN) 0000 C0E0 PUSH ACC 0002 C083 PUSH DPH 0004 C082 PUSH DPL 0006 C0D0 PUSH PSW 0008 75D000 MOV PSW,#00H 000B C007 PUSH AR7 ; SOURCE LINE # 102 ; SOURCE LINE # 104 000D E500 R MOV A,LED_BLINK 000F 6011 JZ ?C0006 ; SOURCE LINE # 105 ; SOURCE LINE # 106 0011 AF00 R MOV R7,LED_COUNT 0013 1500 R DEC LED_COUNT 0015 EF MOV A,R7 0016 700A JNZ ?C0006 ; SOURCE LINE # 107 0018 750032 R MOV LED_COUNT,#032H ; SOURCE LINE # 108 001B 900000 E MOV DPTR,#OUTA 001E E0 MOVX A,@DPTR C51 COMPILER V8.17 MAIN 10/15/2009 20:15:02 PAGE 5 001F 6410 XRL A,#010H 0021 F0 MOVX @DPTR,A ; SOURCE LINE # 109 ; SOURCE LINE # 110 ; SOURCE LINE # 111 0022 ?C0006: 0022 D007 POP AR7 0024 D0D0 POP PSW 0026 D082 POP DPL 0028 D083 POP DPH 002A D0E0 POP ACC 002C 32 RETI ; FUNCTION T0_isr (END)