Created Sat, 16 Jul 2011 18:51:38 +0000 by electroscott
Sat, 16 Jul 2011 18:51:38 +0000
Spent hours upon hours trying to troubleshoot a master/slave SPI issue and finally found that (on my board) the MISO line is permanently shorted to digital 50 (SPI), so I can actually remove the first jumper (master/slave for MISO) and still have MISO connect to Digital 50 (SPI). As such, when I tried to utilize the jumpers to switch to slave mode, it caused all sorts of grief.
You may want to double-check that MISO/MOSI switch between digital 50/43 depending on the settings of the master/slave jumpers.
I've decided to leave mine set to Master mode and just switch the SDI<->SDO on the original "master" PIC32 unit.
Hopefully this will keep someone from spending a great deal of time trying to troubleshoot this...it may be just a solder join on my board, so double check if you're going to use slave mode...
Fri, 22 Jul 2011 19:28:18 +0000
The AVR microcontrollers have pins labeled MISO and MOSI which switch direction depending on wheter the SPI controller is in slave mode or master mode. The PIC microcontrollers don't do that. They have pins labeled SDO and SDI which don't change direction depending on how the SPI controller is enabled. The point of JP3/JP4 is to allow the switching of direction on the two pins at the connector.
Digital pins 50 and 51 are the SPI signals MISO and MOSI. This is where the MISO and MOSI pins are on the Arduio Mega boards. These two pins switch between SDI2A and SDO2A by the position of jumpers JP3 and JP4.
The presence of SDO2A on pin 43 is for the ethernet controller. That pin on the PIC32 part is overloaded with one of the signals for the PHY interface for the ethernet controller.
Gene Apperson Digilent
Mon, 25 Jul 2011 23:48:09 +0000
Thank you for the reply.
Pin 1 of the 6-pin connector (like the ICD connector for the AVR) that is labled MISO is permanently connected to Digital 50 on my board. It does not matter what way the jumpers are set. As such, using this as a slave and swapping SDI/SDO by way of the jumpers didn't work on my board. I had to force it into master mode and then hard-swap the SDI/SDO lines. All is working now, but I wanted to point out that the switchover jumper wasn't working on my board--not sure if it was a short or something up with the artwork. So, for my board, the slave mode doesn't work due to the pins not properly swapping.
It's a terrific board, though, and I now have 2x 32-bit PICs on my robot!
BTW, I assumed that pin 1 of the 2x3 connector would go to the middle pin for the MISO jumper and that pin 4 of the 2x3 connector would go to the middle pin for the MOSI jumper. I made a mistake that I thought I'd just use the "center" pins of the jumpers to directly connect to SDI/SDO, but it turns out that for MOSI the center pin is connected to the 2x3 jumper and the top pin is connected to Digital 43; the center pin is connected to pin 1 of the 2x3 jumper but I'm not sure if the top or bottom pin is actually going to Digital 50/43, because it's permanently shorted to Digital 50 on my board. In other words, if one wants to use the jumpers to connect to SDI/SDO, use the center pin for MISO (left most jumper) but use the top-most pin for MOSI (the right most jumper). Hope that's clear enough...
Tue, 26 Jul 2011 20:01:20 +0000
I don't know if this is the case here, but often there is a little "default" trace across header pin pins that must be cut in order to use the jumper configuration. I don't have a board in front of me or I'd look. Might also be able to see it in the board layout (Eagle) files if you have Eagle available (I think there are Eagle files...)
Tue, 26 Jul 2011 22:54:14 +0000
Pin 1 of J13 (2x3) is connected to digital pin 50 by design. Those are the two places where the MISO signal appear on the Mega board. This also connects to the center pin of JP3. Similarly, Pin 4 of J13 is connected to digital pin 51, as this is where MOSI appears on the Mega. This also connects to the center pin of JP4.
The point of jumpers JP3 and JP4 is to switch whether MISO/MOSI connect to SDI/SDO or SDO/SDI. This switching occurs internally on the AVR parts and doesn't on the PIC parts.
If you set JP3/JP4 to the slave position, you should see SDO on MISO (J13-1 and 50) and SDI on MOSI (J13-4 and 51). The intent was that you pick up MISO and MOSI from either digital pin 50 and 51 or from J13.
Have you looked at the schematic of the Max32 board? Something isn't making sense to me here.
Were you connecting two chipKIT boards together via SPI with one as master and one as slave. If so, you should connect MOSI to MOSI and MISO to MISO. Then set the jumpers for one of them to MASTER and the other to SLAVE.
Gene Apperson Digilent
Sat, 30 Jul 2011 21:04:39 +0000
Thanks for the meaningful reply. Part of my trouble is recalling all the steps I took, and when I post here I try to recall what is what. I'd be better off actually beeping out the pins before I spend more board space talking about the many permutations. All I know is that when I connected my jumpers in slave mode, it didn't seem like I was indeed getting the swapping of SDI/SDO.
I am not connecting two ChipKits together, however. One is a ChipKit (I would have bought a handful if I knew about them earlier!) and one is a Microchip development board that exposes the pins of the PIC32 USB board (DM320002 PIC32 I/O Expansion Board, URL http://www.microchipdirect.com/ProductSearch.aspx?Keywords=DM320002).
I've looked at the schematic for the ChipKit but not the Eagle artwork. Maybe I'll search for the artwork and that would explain a lot to me (e.g., if there's a default trace that needs to get cut). I certainly didn't want to start a panic and if this is a non-issue then I'm sorry. It very well could have been a coding problem the whole while I was troubleshooting the hardware as well. For sure, though, I have to keep my ChipKit in master mode and manually swap the SDI/SDO channels. If I try to let the jumpers do it and maintain SDI-SDI and SDO-SDO (which should then swap SDI/SDO on the ChipKit) it doesn't work.
Maybe my mistake was to tap into the 2x3 header to connect to the I/O expansion board, since you had indicated that pin 1 is always connected to Digital 50 (SDI2A). As such, using this pin to interswitch between MISO/MOSI configuration is exactly the trouble I was reporting, as it's always connected to SDI. Where is the best place to tap MISO/MOSI on the ChipKit board and still utilize the jumpers (I will answer that myself when I look at the Eagle artwork).
Regardless, my code and hardware are now working perfectly. I'm tapping the 2x3 header MISO/MOSI lines 1 and 4 for the SDI/SDO features as mapped by the master jumper configurations.
Sat, 30 Jul 2011 21:39:59 +0000
Okay, I looked at the PCB artwork--should have done that from the start, but somehow I missed it.
I can see what's being said about the Mega for compatibility. However, from my spreadsheet, I show digital 43 and digital 51 being shared. As such, when I put JP3 into slave mode, I'm effectively creating a loopback for SDI/SDO, local to the chipKIT. This is the trouble that I was experiencing in slave mode.
Looks like a DPDT swap could be had to shifting Digital 50 to JP4.3 but that may interfere with the Mega compatibility (?).
Works a treat as long as I leave the jumpers in Master mode.