I'm trying to make digital pot MCP4261 to work with Nano Every, but the megaavr SPI library behaves weirdly. The library in question is this:
The problem is, I can only control wiper0 and can only set its position if the value is 0b1, 0b11, 0b111, 0b1111...etc. i.e all bits are 1. For example 255 will move wiper to one end, but 254, 253, 252... etc wont do anything. Basically the library is broken for Nano Every. When I run the sketch with Arduino Nano, everything works as expected, but Nano uses different SPI library.
Could anyone point me to any alternative Nano Every SPI library please?
the info is not enough. I have loaded my sketch from the Mega2560 to the NanoEvery. Connected is a display EA-DOGM162. Just adjusted the pins and the thing runs.
Yes, I used SPI as part of the sketch to run TFT display, it worked fine. But I'm having problems with digital potentiometer. It is weird because it is not totally borked but it doesnt work as expected in a long way. I will post my sketch a bit later.
SS init should always be high level. Otherwise, try the SPI mode. Do you have a data logger or oscilloscope? To see if the data you want goes over the bus.
Makes no difference if I pull SS high at the start. I dont have oscilloscope, would have been ideal to compare output from Classic Nano and Every. I will figure something out how to capture data, thanks.
I did more experiments and examined SPI library, I cant see anything wrong with it, which leads me now to think that maybe Nano Every generates dodgy SPI waveform. Loaded the same sketch on Raspberry Pi Pico and it works just as good as it works on Nano Classic. So potentiometer is not an issue either it understands at least 2 completely different boards. Without oscilloscope I'm afraid I hit the dead end.
I still can not imagine that it should not work on Every. SPI with display works. Data is only sent. MCP does not work, although here too only data is sent.
Test this lib.
And please check the wiring again. Not that a cable is missing or similar. You can also test the clock to lower.
Tried that library first thing but the same issues. Tried clock higher, lower, no difference. That library is just the wrapper on top of the SPI that only calculates pot position from resistance or other way round. I stripped it to bare minimum in my sketch. It could be that displays are more tolerant to waveform, and pot is not. Still, without oscilloscope it would be only guess.
A small update. I have since purchased Arduino DUE, I needed a board powerful enough that supports hardware interrupts on many pins. SPI with digital potentiometer works on DUE as expected. I am not going to spend more time trying to figure out why it fails on Every, shame really I was getting to like this board.