Hello!!
I am doing a project using the library TLC5940 leds to handle a matrix with a multiplexer to manage the columns.
In the main code need to use an interrupt to manage the matrix while in the loop () "I make animations and more. But when I add a disruption to library stops working.
I tried MsTimer2 and more library, but do not work.
You can add an extra interruption in Arduino that operates parallel to those created in the library??
Thank you very much at all!
A bit of code as an example:
etc.. etc.. etc...
void setup(){
/////////////////////////////DRIVER ///////////////////////////
Tlc.init();
///////////////////////////// MULTIPLEXOR ///////////////////////////
pinMode(5,OUTPUT);
pinMode(4,OUTPUT);
pinMode(2,OUTPUT);
pinMode(6,OUTPUT);
digitalWrite(6,LOW);
///////////////////////////// ISR Timer Functions ///////////////////////////
setISRtimer();
startISR();
}
void loop(){
}
ISR(TIMER2_COMP_vect) {
/////////////////////////////ISR Timer Functions ///////////////////////////
for (uint8_t channel = 0; channel < 8; channel++) {
Tlc.set(channel, bri);
}
Tlc.update();
bri=bri+2;
if (bri > 4090) bri=0;
///////////////////////////// MULTIPLEXOR function ///////////////////////////
switch (fila) {
case 1:
PORTD &= ~_BV(PD5);
PORTD &= ~_BV(PD4);
PORTD &= ~_BV(PD2);
break;
case 2:
PORTD &= ~_BV(PD5);
PORTD &= ~_BV(PD4);
PORTD |= _BV(PD2);
break;
etc.. etc... etc...
}
void setISRtimer(){
TCCR2A = 0x02;
TCCR2B = 0x05;
TCNT2 = 0;
OCR2A = ISR_FREQ;
}
void startISR(){
TCNT2 = 0;
TIMSK2|=(1<<OCIE2A);
}
void stopISR(){
TIMSK2&=~(1<<OCIE2A);
}