I have been trying to increase the efficiency of my MCU by optimizing my code. I have changed all my variables in situations that I can to type byte. Now, I am facing another bottleneck in this section.
I have a variable declared in a structured array:
Code: Select all
Structure TFile
Data(250) As Byte
End Structure
Dim A as TFile
Code: Select all
Dim B as byte
Dim C as bit
C = B.bits(Index)
Code: Select all
If SeekResponse($FE) = $FE Then // Read start token
Index = 0
If pBuffer Then
FSR0 = @Shared.CurrentSectorBuffer
Repeat // Read data block
#if SD_SPI = SW // Software SPI version - use SendByte
POSTINC0 = ReceiveByte()
#elseif SD_SPI = MSSP // MSSP version - use inline routine to optimise speed
SSPIF = 0
SSPBuffer = $FF
Repeat
ClrWDT
Until SSPIF = 1
POSTINC0 = SSPBuffer
#endif
Inc(Index)
Until Index = $200
Else
1. I am not sure if we can use this sort of indirect addressing on my array variable, or will it speed it up.
2. Any issues to expect if we use FSR directly? I have noticed that Steven had a thread with David on this earlier.
3. Can anyone enlighten me more on the specific function of FSR and its related registers: POSTINC, POSTDEC, INDIF and PREINC. I am not very sure if I have understood them well enough, eventhough I have read the datasheet a few times.
Thanks
Regards,
Liak