Recommended Posts


I am trying to interface with an 8x8 Led-Digit driver.  I Started by bit banging the code to get something working

void send(int value) {

  // enable CS
  digitalWrite(MX_CS, LOW);
  int v = value;
  for (signed int x = 15; x >= 0; x--) {
    digitalWrite(MX_DATA, ((v >> x) & 0x1) ? 1 : 0);
    digitalWrite(MX_CLK, HIGH);
    digitalWrite(MX_CLK, LOW);
  digitalWrite(MX_CS, HIGH);


Next I moved to using the zpuino SPI block. I looked at the datasheet above and the wikipedia article on SPI and determined I need to send my SPI message using "MODE0".



When I do so the SPI device is not working properly


And from looking at the SPI implementation I think the problem is that the values are always set on the rising edge of the clock while for MODE0 the value should be set before (e.g. on the falling edge).

Am I missing something? (from experimenting using MODE2 apprears to work but then clock stays high in between cycles)



Here is my setup (for the fun o it): I hoped to be able to use a pin of the IO BufferWing to be able to drive the display but this did not work.



Link to comment
Share on other sites

8 hours ago, Jack Gassett said:


Did you have any luck with this? I was sick all last week so was not watching the forums very well. This is a question that Alvie can probably answer easily, but I think a search of the forum might answer it too... I seem to remember a post about this topic before.



I started looking into the code to try and understand the problem myself. the SPI master does have enough flags passed to the code

 e.g. spi_samprise is kinda taken into account to determine when to sample the signal (at rise or fall of the clock)


and (I think sets the do_sample correctly)




Will alway shift on the rising edge of the spi clock. I made small modifications trying to fix it but I am getting into trouble because I need to skip the first rising edge

e.g. if try to I skip the first rising edge all my data if off by one clock cycle.

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.