Hi J,compss = 0 'CHIP SELECT COMPASS ON
'For i = 0 To 18 '5 'READ XYZ Xx2 Yx2 Zx2
'SPISend addr
'SPIReceive data
'b(i) = data
'addr = addr + i
'Next i
'compss = 1 'CHIP SELECT COMPASS OFF
This does not work at all.
Find out why by going through the for next loop and calculating addr with each value of i.
Both #18 sections work as good as each other. Both error 25% of the time, but if no error at start-up, then both seem reliable.
I guess that with the [ addr = addr + i ] after SPISEND, then it gets a READing beforethe start of the 1 to 18 LOOP, so givig an extra READ at the end?
EDIT: From the tests I've tried, I'm pretty sure the problem is at the PIC end, as the SPI signals are arriving.
NOTE: Normally I'm programming the PIC using a Pickit3, that has a MCLR PIN, and needs the PIC to be powered up before programming. If I'm not programming, but testing, and try a test, without the Pickit3 attached, then I get error with all the last tries. However, as soon as it was attached and powered, then no error. So perhaps it is a PIC initiation problem
EDIT EDIT: I've just checked the PCB, and noticed that there are no capacitors near the PIC power PINS, which is suggested. I'll add some.
Last edited: