vamsimanideep / tlc5940arduino

Automatically exported from code.google.com/p/tlc5940arduino
0 stars 0 forks source link

code examples and circuit for mux don't seem to match #13

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The circuit diagram here 
http://tlc5940arduino.googlecode.com/svn/trunk/Tlc5940Mux/tlc5940mux_circuit_exa
mple.png

is clear. I'm trying to use the second option (ie using a shift register on one 
side. Problem is the code example TL5940Mux->Matrix describes a set up with a 
3:8 line decoder. Do you have a code example that matches the diagram please? 
Thanks for your work with the library.

Original issue reported on code.google.com by tomschof...@gmail.com on 23 Oct 2012 at 4:45

GoogleCodeExporter commented 8 years ago

// SHIFT_DATA_PIN (PC0 is analog 0) = '595 SER pin (Pin 14)
#define SHIFT_DATA_PORT PORTC
#define SHIFT_DATA_PIN  PC0
#define SHIFT_DATA_DDR  DDRC
// SHIFT_CLK_PIN (PC1 is analog 1) = '595 SRCLK (Pin 11)
#define SHIFT_CLK_PORT  PORTC
#define SHIFT_CLK_PIN   PC1
#define SHIFT_CLK_DDR   DDRC
// '595 RCLK is hooked to tlc XLAT pin (Arduino digital Pin 9, 74HC595 Pin 12)

static inline void shift8_595_row(uint8_t row)
{
  // the output of the '595 for the selected row should be high, all others
  // low
  uint16_t output = (1 << row);
  uint16_t nbit = 1 << (NUM_ROWS - 1); //0x80;
  for (; nbit; nbit >>= 1) {
    if (nbit & output) {
      SHIFT_DATA_PORT |= _BV(SHIFT_DATA_PIN);
    } 
    else {
      SHIFT_DATA_PORT &= ~_BV(SHIFT_DATA_PIN);
    }    
    // pulse the '595 sclk
    SHIFT_CLK_PORT |= _BV(SHIFT_CLK_PIN);
    SHIFT_CLK_PORT &= ~_BV(SHIFT_CLK_PIN);
  }
}

in setup()

SHIFT_DATA_DDR |= _BV(SHIFT_DATA_PIN);
SHIFT_CLK_DDR  |= _BV(SHIFT_CLK_PIN);

in ISR(TIMER1_OVF_vect)

add shift8_595_row(shiftRow); after TlcMux_shiftRow(shiftRow);

Original comment by rafal83 on 5 Jan 2013 at 12:29

GoogleCodeExporter commented 8 years ago
Wow that's great rafal83. Thanks for taking the time. I'm ashamed to say I'd 
given up on this but will now go back to it and give it another go. 

Tom

Original comment by tomschof...@gmail.com on 6 Jan 2013 at 11:12