Need Support for MCP4142-104E/SN Potentiometer

Thanks for verifying that :smiley:

@peekay123

I found the line of code I was talking about.

Specifically the setClockDivider , do we need this on the Photon & Electron? :

@RWB, you do. That sets the SPI clock speed. The default is too fast.

1 Like

And for the records for the Photon even more than for the Core as the Photon is clocked 66% faster than the Core.

@peekay123, I guess the comment is a but misleading since (AFAIK) the base SPI clock is half the µC clock, so DIV8 should actually give you 4.5MHz (Core) and 7.5MHz (Photon).
And since we now have something like SPI.setClockSpeed(15, MHZ); that would save some confusion.


But on re-reading the Core docs it states the base clock is 72MHz (I'm sure @BDub said looong ago it was half that) while on Photon/Electron it's 60MHz for SPI and 30MHz for SPI1 :confused:

@ScruffR You might wanna run a quick test to check by setting DIV16 and seeing if the clock is 4.5MHz with a scope… I can’t look right now, but I seem to remember always using 72MHz in my calculations for the Core.

3 Likes

Thanks for that update, then I must remember wrong, or I attributed that info to the wrong persion :blush: - I’m sure I didn’t make this up myself :flushed:
It might have been Dave too, but I’ll do the measuing.


Update:
Yup, the half system clock idea was not mine, but to apply it to the Core where it only applies to its successors was my :shit: :flushed:

But @RWB, while doing the testing I found (or was pointed to by @BDub again :+1:) that SPI.begin() should be called after SPI.setClockDivider() (and I’d guess the other setup functions too).
Doing it the other way round caused the clock to ignore my divider setting.

2 Likes

@ScruffR I moved the SPI.setClockDivider to the last line and everything still works just fine.