-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPI Pinswap 2 not available #199
Comments
I haven't worked on this core for a long time, so I honestly don't remember why I wrote that it was unavailable. But when looking at the SPI.h/cpp source code, it appears that SPI swap 2 is available. I suggest you give it a try 🙂 |
I did, and it seems to not be working. But as I have no debugger it might be something else I missed, I'll keep digging. |
Somehow that sounds vaguely familiar, but I see no references to it anywhere.... I see nothing about it in errata, nor do I remember seeing that one go by. Do you have a 'scope? if so I would write the code to use one mux option, test it ( expecting it to work, thus giving a screenshot of a working transaction) then swap the wires and the code to use mux 2, and see what was different... Depending on the results you see with the scope, and how simple you can get code that reproduces it (the ideal test case is something that can be demonstrated with only the board, jumpers, and a 'scope). And if you do that and get two different scope traces when the code is otherwise identical, I think that would be very informative (if disheartening). I see no reason it wouldn't work short of a silicon bug, or a bug in user code, which is why am giving the advise about a demonstration test case 2 paragraphs down. That note about pinswap option 2 is present WAAAY back. I see it in history at times when you can check the SPI.h at the time, and see that pins/swap wasn't even in yet - so at the time that note was added, you couldn't use options 1 or 2 :-P How are you swapping pins? Using pins() or swap()? Make sure you're getting true back from SPI.pins() or SPI.swap() if you get false back, that means it didn't like the arguments, and it has set the pinset to the default. (while MCUdude's pinswap code looks like that logic was copied from an earlyish version of my cores (or the other way around, but unless I just had a bad dream about writing that....
On that basis, I dropped any requirement for specifying the SS pin by making it __attribute((unused)) and giving it a default value, commented out the tests of the SS pin, and documented it's optionality. I feel like there may also be a case or two on the DD where there's no SS pin for a pinset, which may have forced that, though I probably had done that earlier. whatever I did do back of the envelope calculations for the usability of SPI slave mode and uh, there is a reason SPI.h doesn't attempt to implement it. The problems are myriad, but they all come down to speed; this is why I never went any further working on this; it was clear it wouldn't be a good fit.I2C and Serial are better fits to communication between AVRs. :
|
Thanks for your reply @SpenceKonde, I don't have a scope on hand but I could use one from the office if the need arises. I can already confirm that SPI.swap(2) does return true which makes me think the problem is user code. I am using the RFM69 library which uses SPI to communicate with a HopeRF RFM69, I think that library overwrites my SPI code and uses the default pins for SPI. My arduino coding is not up to par to figure out how to figure that out too be honest so I'll have to do some research and digging. Thanks again for the suggestions I'll let you know if I go the scope route. |
I can confirm that pinswap 2 on SPI works. I assume the comment about unavailability can be removed. |
I have spotted at https://github.com/MCUdude/MegaCoreX/blob/master/megaavr/variants/48pin-standard/pins_arduino.h on line 119 it is noted that it is noted that Pinswap 2 is not available. What would be the reason for this, is there any way there can be worked around this?
As you can probably guess I have a custom PCB where I connected the pinswap 2 SPI pins as I originally based my board on the Nano Every design.
Thanks in advance!
The text was updated successfully, but these errors were encountered: