I'll provide every information i have, But i need some time to work on that to make it understandable. i'll post that details tomorrow morning.
But i'll tell you my main concern is....i want to call timer interrupt every some ms so in that mean time if any button pressed it will be detected and send data to another microcontroller. In mean while MAIN loop is busy with never end loop whom i don't want to interrupt.
ISR (TIMER1_COMPA_vect) // Timer1 ISR
{
if(PINA!=0x1f) //this is a condition where if any button pressed(out of 5 buttons i am using) will be detected
{
val=PINA;
button(val); //passing PINA value
}
if((UCSRA&(1<<RXC))) //if recevied anytime
{
received_data=UDR; //store the value received
decide_func(received_data); //Passing received value.
}
}
And this is how i set-up my timer1 for CTC mode
Code:
TCCR1B |= (1 << WGM12)|(1 << CS11)|(1 << CS10);
TCNT1 = 0;
OCR1A = 2499; //I just set this value because it works fine not calculated(please help me here how to
//determine the value to be set in here.
TIMSK |= (1 << OCIE1A);
This is how i'm trying to transmit data .
Code:
while(!(UCSRA&(1<<UDRE)));
UDR=0b00000101;
Kindly help me in improving what to say that in technical terms if i were wrong somewhere(So next time i'll be more accurate).