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