Hi, I'm looking for a library for TLC5940 with ATtiny2313 support. I tried changing libraries with ATmega/ATtiny85 support, but it's not working... I'm a total newbie... Anyone want to help me? ^^
Why use a 2313? As you've noticed, it makes life difficult.
Converting the library won't be easy, the library uses two timers and the 2313 only has one spare.
You can get small-format Mega328s for under $3. They're compatible with an Arduino Uno so everything just works..
I know that ATtiny2313 is not good for this. But currently I have only this and I don't have time to change anything. It's a my project to my studies. And I can't use a fully-prepared modules. I should only use a simple units (this ATmega from url has a few built-in parts).
Ofc, I can abandon this idea about pwm (no problem), but with pwm it will be nicer.
I found libraries for ATmegaXYZ, ATtiny45/85, why not for ATtiny2313? ![]()
serek:
I found libraries for ATmegaXYZ, ATtiny45/85, why not for ATtiny2313?
Because you're the first person to need it...
In the true spirit of hacking, it's your job to create one. ![]()
So, last try...
http://forum.arduino.cc/index.php?topic=125212.15
It's for ATtiny45/85. How I can change it? xD
EDIT: I tried this files Luciolinae/code/avrbits/attiny2313 at master · damian0815/Luciolinae · GitHub But it's still not working xD
serek:
So, last try...ATtiny85 + TLC5940 - LEDs and Multiplexing - Arduino Forum
It's for ATtiny45/85. How I can change it? xD
A 2313 is more like a Tiny84. There's enough clues in that thread to make it work on a Tiny84.
Lol, it's your library^^
Heh, it's working. Very thanks ![]()
BUMP
One more question.
I have this code:
#define NMB_PINS 3
int main(void)
{
int16_t i;
uart_init(__UBRR);
unsigned char tab[NMB_PINS];
init();
while(1)
{
uart_getcolors(tab, NMB_PINS); //getting colors from RS232 to "tab"
for(i = 0; i < NMB_PINS; i++)
set(i, 4095 / 255 * tab[i]);
update();
}
}
void uart_getcolors(unsigned char* buf, uint8_t len)
{
int i = 0;
while(uart_getc() != 1) ;
for (i = 0; i < len; i++) {
buf[i] = uart_getc();
}
char uart_getc() {
while(!(UCSR0A & (1<<RXC0)))
update();
return UDR0;
}
But it's not working very well. For example, when red color was sent, this red color is displayed, but from time to time other color (green, yellow, .... ) is displayed. And from time to time LEDs are off. Why?
Have a look at the "Data OverRun" bit in USCR0A...
fungus:
Have a look at the "Data OverRun" bit in USCR0A...
I wrote that I'm a newbie...
And I still don't know, what I should to do...
Copy that status bit to a LED. See if it lights up.
fungus:
Copy that status bit to a LED. See if it lights up.
I'm trying, but still don't know how it should be xD
OK, try a really low baud rate for the serial communication...
fungus:
OK, try a really low baud rate for the serial communication...
I tried, but only 19200 rate causes that everything works (except different colors on my LEDs).
Maybe idea with Data Overrun bit is good. But I don't know, how I should to use it correctly...
Ok, currently it works.
I used interrupts.
Main.c
#include <avr/io.h>
#include <avr/delay.h>
#include <avr/interrupt.h>
#include "myuart.h"
#include "Tiny85_TLC5940.h"
#define NMB_PINS 12
unsigned char odebrano[NMB_PINS];
int16_t i;
SIGNAL(SIG_USART0_RECV)
{
uart_getcolors(odebrano, NMB_PINS);
for(i = 0; i < NMB_PINS; i++)
set(i, (4095 / 255) * odebrano[i]);
}
int main(void)
{
uart_init(__UBRR);
sei();
init();
while(1)
{
update();
}
}
But LEDs from time to time are blinking. Can I remove this effect?
The library depends on not having interrupts that take ages.
(An interrupt that takes ages is always a bad idea...)
So what I should to do?
My interrupts takes too much time? So maybe I should change this one interrupt to a few interrupts? Or what?
serek:
My interrupts takes too much time?
It waits for a lot of data to arrive on the serial port, so, yes...
serek:
So maybe I should change this one interrupt to a few interrupts? Or what?
I wouldn't use interrupts, they'll cause LED flicker. The timing in the TLC library needs to be predictable.
Your code without interrupts was almost right but update() takes about 8500 clock cycles to execute. If you send more than 2 byte of data in this time then data will be lost (the "Data OverRun" bit tells you if this happens). You need to send less data or reduce the baud rate.
Ok. But I have problem with changing baud rate. When I choose baud rate which is not equal to 19200, my LEDs are off...
EDIT: My bad, I forgot, that in my driver application on my PC I should have the same baud rate... Now all works very good.