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

DPTR constantly reloaded

I have some code to transfer a large amount of data over a SPI port running at the system clock/2 so I need my code to be as fast as possible. The code generated for my current method does not seem to be as optimal as it could be. I am using optimization (8, speed) with the 7.07 C51. Here is a simplified version of my code:

//this variable set in buffer data function
static unsigned char xdata * data spiDataPtr;

void transferData(void) small {
     //do not want to store changes in
     //spiDataPtr so use temp pointer
     unsigned char xdata * tempPtr;
     unsigned char data i;
     unsigned char data temp;

     tempPtr = spiDataPtr;

     //transfer set block size
     for(i = 0xff; i != 0; i--) {
          SPIDATA = *tempPtr; //initiate transfer
          tempPtr++; //prepare for next send while busy transfering
          while(!SPITXDONE); //wait for transfer to complete
          temp = SPIDATA; //read to avoid colission error
     }
}

The compiler increments tempPtr in its data location and then reloads it into the DPTR each time tempPtr is increased. I do not need the final value of tempPtr. What I would like is for the DPTR to be loaded when tempPtr is initially set and then for the DPTR to be increased by INC DPTR. I figure this would be quicker even if the value of tempPtr was needed because the DPTR could be moved back into tempPtr at the end of the loop. Is there a way to get the compiler to do this short of assembly?

0