Other Parts Discussed in Thread: STRIKE
Fellows,
Code below reads two continous sets of 32 bits over an SPI port, with CSB controlled by GPIO, and clock set at 7.5MHz. It takes 11.44us. Tivaware functions compiled to Flash, no optimizations.
IntMasterDisable(); GPIOPinWrite(gyroHW->GPIOFSSPort,gyroHW->GPIOFSSPin,0); // Lower CSB SSIDataPut(gyroHW->SSIBase, frameHigh); // Sends only the upper 16 bits while(SSIBusy(gyroHW->SSIBase)); // Flush first 16 bits SSIDataGet(gyroHW->SSIBase, &readCrap); // Read useless data SSIDataPut(gyroHW->SSIBase, (frameLow)); // This sends the other 16 bits while(SSIBusy(gyroHW->SSIBase)); // Flush second 16 bits GPIOPinWrite(gyroHW->GPIOFSSPort,gyroHW->GPIOFSSPin,gyroHW->GPIOFSSPin); // Raise CSB SSIDataGet(gyroHW->SSIBase, &readCrap); // Read useless data GPIOPinWrite(gyroHW->GPIOFSSPort,gyroHW->GPIOFSSPin,0); // Lower CSB SSIDataPut(gyroHW->SSIBase, frameHigh); // Flush third 16 bits while(SSIBusy(gyroHW->SSIBase)); // Wait for bits to be flushed out SSIDataGet(gyroHW->SSIBase, &read16High); // Read 16 bits SSIDataPut(gyroHW->SSIBase, frameLow); // Flush last 16 bits while(SSIBusy(gyroHW->SSIBase)); // Wait for bits to be flushed out SSIDataGet(gyroHW->SSIBase, &read16Low); // Read more data GPIOPinWrite(gyroHW->GPIOFSSPort,gyroHW->GPIOFSSPin,gyroHW->GPIOFSSPin); // Raise CSB IntMasterEnable();
While this exact version with all the API's called directly from ROM take 12.22us.
IntMasterDisable(); ROM_GPIOPinWrite(gyroHW->GPIOFSSPort,gyroHW->GPIOFSSPin,0); // Lower CSB ROM_SSIDataPut(gyroHW->SSIBase, frameHigh); // Sends only the upper 16 bits while(ROM_SSIBusy(gyroHW->SSIBase)); // Flush first 16 bits ROM_SSIDataGet(gyroHW->SSIBase, &readCrap); // Read useless data ROM_SSIDataPut(gyroHW->SSIBase, (frameLow)); // This sends the other 16 bits while(ROM_SSIBusy(gyroHW->SSIBase)); // Flush second 16 bits ROM_GPIOPinWrite(gyroHW->GPIOFSSPort,gyroHW->GPIOFSSPin,gyroHW->GPIOFSSPin); // Raise CSB ROM_SSIDataGet(gyroHW->SSIBase, &readCrap); // Read useless data ROM_GPIOPinWrite(gyroHW->GPIOFSSPort,gyroHW->GPIOFSSPin,0); // Lower CSB ROM_SSIDataPut(gyroHW->SSIBase, frameHigh); // Flush third 16 bits while(ROM_SSIBusy(gyroHW->SSIBase)); // Wait for bits to be flushed out ROM_SSIDataGet(gyroHW->SSIBase, &read16High); // Read 16 bits ROM_SSIDataPut(gyroHW->SSIBase, frameLow); // Flush last 16 bits while(ROM_SSIBusy(gyroHW->SSIBase)); // Wait for bits to be flushed out ROM_SSIDataGet(gyroHW->SSIBase, &read16Low); // Read more data ROM_GPIOPinWrite(gyroHW->GPIOFSSPort,gyroHW->GPIOFSSPin,gyroHW->GPIOFSSPin); // Raise CSB IntMasterEnable();
Not that this will kill anyone, but all discussions and documentations to date imply that ROM calls are faster. Any thoughts as the reason for the results above?
Regards
Bruno