The following code fragment has been running for three years on an Atmel 89c55 with no problems. Now that I have started a project using the Cypress EZ-USB FX chip I would like to move the fifo buffer from the default generic pointer in data space. #define FIFO0SIZE 10 BYTE *fifo0[FIFO0SIZE]; to xdata and increase the size using #define FIFO0SIZE 100 xdata BYTE *fifo0[FIFO0SIZE]; It compiles but continualy sends garbage out the serial port. I have tried pointer casting and changing to the large memory modle and a few other things, all with negative results. Can anyone shed some light on this problem. #define FIFO0FULL FIFO0SIZE-2 BYTE Que(new_ptr) BYTE *new_ptr; { BYTE idata Pass,i; Pass=0xff; for(i=0;i<FIFO0SIZE-1;i++){ // add new message to end of buffer if(!fifo0[i]){ // current position is empty go ahead and use it if(i>FIFO0FULL) SBuff0_Full=1; Pass=0; fifo0[i]=(BYTE xdata *) new_ptr; fifo0[i+1]=0; if(!out0_busy) TI=1; // kick start the uart break; } } return Pass; } void Serial_Port0(void) interrupt COM0_VECT { BYTE idata i; static BYTE data x=0; if(RI) { RI=0; // extract recieved byte Inkey(SBUF0); } if(TI) { TI=0; if(fifo0[0][x]) { SBUF0=(fifo0[0][x]); x++; out0_busy=1; } else out0_busy=0; // no character to send if(!fifo0[0][x]) { // end of string last character is being sent if(out0_busy) { // last character is being sent for(i=0;i<FIFO0SIZE-1;i++) { // rotate buffer if(fifo0[i]) { // if = 1 = buffer not empty fifo0[i]=fifo0[i+1]; x=0; } // if fifo0 buffer not empty else { if(i<2) SBuff0_Full=0; break; // end of buffer } } } } } }
Does anything in the Thread "Problem addressing XDATA memory above 100Hex" help? See: http://www.keil.com/forum/msgpage.asp?MsgID=861 BTW: your code would look better if you enclose it within <pre> and </pre> tags - see "Tips for Posting Messages" (link in the sidebar) http://www.keil.com/forum/tips.asp
I did look at the posting you refer to. But it did not help. This is a listing of the code. It looks like it should work. What am I overlooking ? I do not know what ?C?CLDOPTR does. I assume it extracts the byte at DPTR plus offset x and places the results in the A register. This is the C51 source.
451 2 if(fifo0[0][x]) { 452 3 SBUF0=(fifo0[0][x]);
; SOURCE LINE # 451 0031 900000 R MOV DPTR,#fifo0 0034 E0 MOVX A,@DPTR 0035 FB MOV R3,A 0036 A3 INC DPTR 0037 E0 MOVX A,@DPTR 0038 FA MOV R2,A 0039 A3 INC DPTR 003A E0 MOVX A,@DPTR 003B F9 MOV R1,A 003C 850082 R MOV DPL,x 003F 758300 MOV DPH,#00H 0042 120000 E LCALL ?C?CLDOPTR 0045 FF MOV R7,A 0046 6008 JZ ?C0076 ; SOURCE LINE # 452 0048 F599 MOV SBUF0,A