Guys,
May not be the solution for Art's project, but this post interested me because I was also stumped trying to shift bytes of data FIFO and ended up making something work for me.
I liked the FOR/NEXT approach given here and thought I would try it since it looked faster and smaller since I'm really collecting 32 bytes instead of 12 in this example.
My kludge: This scheme uses 24 words and takes 12.5us
Code:
DEFINE OSC 8
RX VAR BYTE ' Buffer data
XYZ_val VAR BYTE[12] ' Accelerometer XYZ data
TC_OUT VAR PORTC.4 ' Test point to measure loop time
Load_array:
TC_OUT = 1
XYZ_val[0] = XYZ_val[1] ' Oldest data
XYZ_val[1] = XYZ_val[2]
XYZ_val[2] = XYZ_val[3]
XYZ_val[3] = XYZ_val[4]
XYZ_val[4] = XYZ_val[5]
XYZ_val[5] = XYZ_val[6]
XYZ_val[6] = XYZ_val[7]
XYZ_val[7] = XYZ_val[8]
XYZ_val[8] = XYZ_val[9]
XYZ_val[9] = XYZ_val[10]
XYZ_val[10] = XYZ_val[11]
XYZ_val[11] = RX ' Newest data
TC_OUT = 0
RETURN
Was surprised to to find that this scheme uses 43 words and takes 216us:
Code:
DEFINE OSC 8
RX VAR BYTE ' Buffer data
XYZ_val VAR BYTE[12] ' Accelerometer XYZ data
TC_OUT VAR PORTC.4 ' Test point to measure loop time
Load_array:
TC_OUT = 1
FOR z = 0 to 10
XYZ_val[Z] = XYZ_val[Z+1]
NEXT z
XYZ_val[11] = RX
TC_OUT = 0
RETURN
It meant more typing but saved some space and time.
Bookmarks