SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
The data sheet for the COM-09767 7-Segment Serial Display says "The maximum speed of the SPI clock input is 2MHz", yet I'm unable to get it to work at anything over 0.5Mhz. Looking at the source code for the onboard ATMega328 I see the following:
Code: Select all
SPCR = (1<<SPIE) | (1<<SPE);
which should configure the SPI clock as 1/4 of the system clock. I can't see an external resonator or crystal on the board, and looking through the code seems to suggest that it expects a clock rate of 8MHz which would be right if the internal 8Mhz resonator is being used. However I can only get it to run at 0.5MHz using the following SPCR settings on a CPU that's running at 16MHz:
Code: Select all
_BV(SPE) | _BV(MSTR) | _BV(SPI2X) | _BV(SPR1)
That gives a SPI clock of f_osc / 32, which is 16 / 32 or 0.5Mhz.

Why doesn't the display board run at the rated 2MHZ SPI frequency? The only possible suggestion I can come up with is that the CKDIV8 fuse bit has been set incorrectly, but then I'd expect the maximum frequency to be 8 / 8 / 4 = 0.25Mhz, not 0.5MHz.
In the end I found the cause of the problem myself - at 2MHz the SPI ISR overruns. I've fed this information back to SparkFun and they've updated the datasheet to say that the SPI interface shouldn't be clocked at over 250KHz. That's a workaround, I believe SparkFun are working on updated firmware that will correct the problem and allow the SPI interface to run at full speed, i.e. 2MHz.
You CAN reprogram the ATMega328p.

I messed mine up (probably ESD) and the digits were all spazzing out, just flashing random things and not accepting SPI commands. But I checked in the EAGLE files and the reset, MOSI, MISO, and SCK lines are connected to the corresponding pins on the 328 to allow in system programming. I downloaded the source code and reflashed it onto the micro and it works fine now.

If you're really that dissatisfied with the coding or really need to get it working at 2MHz you can just write some firmware yourself and reprogram the micro.

ps. Feel free to share if you make a better firmware for this thing. :D