So I'm hoping to use these two chips together, but have some problems. The Trinket doesn't have all the pins that the TLC5940 needs, will switching to bitbang mode in the TLC5940 library fix this?
In the library, I've added an "ATtiny_85.h" file in the pinouts:
#ifndef TLC_ATTINY_85_H
#define TLC_ATTINY_85_H
/** \file
SPI and timer pins for the ATmega168/48/88. Don't edit these. All
changeable pins are defined in tlc_config.h */
/** VPRG (Arduino digital pin 8) -> VPRG (TLC pin 27) */
#define DEFAULT_VPRG_PIN PB0
#define DEFAULT_VPRG_PORT PORTB
#define DEFAULT_VPRG_DDR DDRB
/** XERR (Arduino digital pin 12) -> XERR (TLC pin 16) */
#define DEFAULT_XERR_PIN PB4
#define DEFAULT_XERR_PORT PORTB
#define DEFAULT_XERR_DDR DDRB
#define DEFAULT_XERR_PINS PINB
/** SIN (Arduino digital pin 7) -> SIN (TLC pin 26) */
#define DEFAULT_BB_SIN_PIN PB0
#define DEFAULT_BB_SIN_PORT PORTB
#define DEFAULT_BB_SIN_DDR DDRB
/** SCLK (Arduino digital pin 4) -> SCLK (TLC pin 25) */
#define DEFAULT_BB_SCLK_PIN PB2
#define DEFAULT_BB_SCLK_PORT PORTB
#define DEFAULT_BB_SCLK_DDR DDRB
/** MOSI (Arduino digital pin 11) -> SIN (TLC pin 26) */
#define TLC_MOSI_PIN PB0
#define TLC_MOSI_PORT PORTB
#define TLC_MOSI_DDR DDRB
/** SCK (Arduino digital pin 13) -> SCLK (TLC pin 25) */
#define TLC_SCK_PIN PB2
#define TLC_SCK_PORT PORT2
#define TLC_SCK_DDR DDRB
/** SS will be set to output as to not interfere with SPI master operation.
If you have changed the pin-outs and the library doesn't seem to work
or works intermittently, make sure this pin is set correctly. This pin
will not be used by the library other than setting its direction to
output. */
#define TLC_SS_PIN PB5
#define TLC_SS_DDR DDRB
/** OC1A (Arduino digital pin 9) -> XLAT (TLC pin 24) */
#define XLAT_PIN PB0
#define XLAT_PORT PORTB
#define XLAT_DDR DDRB
/** OC1B (Arduino digital pin 10) -> BLANK (TLC pin 23) */
#define BLANK_PIN PB1
#define BLANK_PORT PORTB
#define BLANK_DDR DDRB
/** OC2B (Arduino digital pin 3) -> GSCLK (TLC pin 18) */
#define GSCLK_PIN PB4
#define GSCLK_PORT PORTB
#define GSCLK_DDR DDRB
#endif
which, as I understand it, contains the pins on the board and should be correct, apart from the Trinket not having an OC2B pin.
I then added this
#elif defined (__AVR_ATtiny85__)
#include "ATtiny_85.h"
to the "chip_includes.h" file, to load my header above.
I then changed to BITBANG mode through
** Determines how data should be transfered to the TLCs. Bit-banging can use
any two i/o pins, but the hardware SPI is faster.
- Bit-Bang = TLC_BITBANG
- Hardware SPI = TLC_SPI (default) */
#define DATA_TRANSFER_MODE TLC_BITBANG
/* This include is down here because the files it includes needs the data
transfer mode */
#include "pinouts/chip_includes.h"
/* Set DATA_TRANSFER_MODE to TLC_BITBANG and change the pins below if you need
to use different pins for sin and sclk. The defaults are defined in
pinouts/ATmega_xx8.h for most Arduino's. */
#if DATA_TRANSFER_MODE == TLC_BITBANG
/** SIN (TLC pin 26) */
#define SIN_PIN PB2
#define SIN_PORT PORTB
#define SIN_DDR DDRB
/** SCLK (TLC pin 25) */
#define SCLK_PIN PB3
#define SCLK_PORT PORTB
#define SCLK_DDR DDRB
#endif
but when I try and verify the example in the Arduino IDE from
here, I get these errors:
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp: In function 'void __vector_4()':
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:63: error: 'TCCR1A' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:64: error: 'TIMSK1' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp: In member function 'void Tlc5940::init(uint16_t)':
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:112: error: 'TCCR1A' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:113: error: 'TIMSK1' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:122: error: 'TCCR1B' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:122: error: 'WGM13' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:125: error: 'ICR1' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:143: error: 'TCCR2A' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:143: error: 'COM2B1' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:145: error: 'WGM21' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:146: error: 'WGM20' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:147: error: 'TCCR2B' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:147: error: 'WGM22' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:148: error: 'OCR2B' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:149: error: 'OCR2A' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:150: error: 'CS20' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp: In member function 'uint8_t Tlc5940::update()':
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:178: error: 'TCCR1A' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:193: error: 'TIFR1' was not declared in this scope
C:\Users\jemonn\Desktop\windows\libraries\Tlc5940\Tlc5940.cpp:193: error: 'TIMSK1' was not declared in this scope
and I'm not sure how to go about fixing it so it works? I'm still waiting for my chips to arrive, I got a free sample TLC5940 so if it's impossible to get it to work, it's not a massive loss, and I'd be open for suggestions of LED drivers that would work, but obviously I'd rather this works.
Thanks!