This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

changing buffer from data to xdata

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
}
}
}
}
}
}

0