why SPI loop back is getting failed?
I am assuming you have read the Harmony Examples documentation and you see that LED2 is lit, indicating failure.
Well, the thing that I don't remember seeing explicitly stated in the documentation is that in order to do the loopback test you have to connect SDO1 to SDI1 externally
. Maybe they thought it was obvious that a loopback project requires you
to loop something back. I think it should have been Step 0 in the three-step sequence (thus making it a four-step sequence).
Bottom line for this part of your question: When I connect SDO1 (RD0) to SDI1 (RC4), LED3 is lit, indicating success. Remove the external connection, click the MPLABX toolbar icon for "Hold in Reset" then "Release from Reset" and LED2 is lit. Reconnect the external jumper, Reset and Release, and LED3 is lit.
Now, if you aren't working with a Starter Kit I/O Expansion Board (or something else that your USKII is plugged into), I don't know how the heck you would make the external connection, but if you are, you can look up the connections on the USK2 schematic and the Expansion Board schematic to see what pins on J10 and/or J11 correspond to RD0 and RC4.
I use a PICTail prototype board plugged into the Expansion Board and, for these signals, the marked names work for this. (Beware: For some few Signals and some few Starter Kit modules, the names marked on the PICtail protype board have been scrambled slightly, so always check the schematics.)
...can you please suggest with some example codes to test SPI...
I'm not a Harmony guy. I say this not meaning to disparage Harmony, but I mean that I simply don't have enough experience to try to help others. There is a Harmony subforum. Maybe you can ask Harmony-specific questions there.
If you just want to test SPI, you can write a bare-metal (non-Harmony) project that initializes a SPI module and exercises it.
Finally, an opinion or two (see Footnote):
- I hate it that the USKII board doesn't have a reset button. I always need a reset button during development, even if the final product doesn't have a reset function. I (almost) always lay out the PCB to accommodate a Reset switch, or at least with pads to which I can connect wires to an external reset button.
- I hate one-and-done tests like this. I (almost) always put tests like this in a loop so that I can connect and disconnect the external jumper and see the LED pattern change. Can observe bit patterns on a 'scope to see what the heck is going on.
The opinions expressed here are not necessarily my own.
It's these dang voices in my head.
post edited by davekw7x - 2017/11/23 10:08:24