keesj 1 Report post Posted October 25, 2017 Hi, 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); w(); int v = value; for (signed int x = 15; x >= 0; x--) { digitalWrite(MX_DATA, ((v >> x) & 0x1) ? 1 : 0); w(); digitalWrite(MX_CLK, HIGH); w(); digitalWrite(MX_CLK, LOW); w(); } digitalWrite(MX_CS, HIGH); w(); } 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. Share this post Link to post Share on other sites
Jack Gassett 0 Report post Posted October 31, 2017 Hey, 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. Jack. Share this post Link to post Share on other sites
keesj 1 Report post Posted October 31, 2017 8 hours ago, Jack Gassett said: Hey, 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. Jack. Hi, 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) https://github.com/GadgetFactory/DesignLab_Examples/blob/master/libraries/ZPUino_Wishbone_Peripherals/COMM_zpuino_wb_SPI.vhd#L250 and (I think sets the do_sample correctly) https://github.com/GadgetFactory/DesignLab_Examples/blob/master/libraries/ZPUino_Wishbone_Peripherals/spi.vhd#L81 However https://github.com/GadgetFactory/DesignLab_Examples/blob/master/libraries/ZPUino_Wishbone_Peripherals/spi.vhd#L95 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. Share this post Link to post Share on other sites
alvieboy 25 Report post Posted November 14, 2017 Let me take a look at that and I'll get back to you. Probably there's a bug there, I don't recall testing it with non-usual modes (it's also tricy to implement). Alvie Share this post Link to post Share on other sites