/////MAIN FUNCTION//////
int main(void)
{
MT_INIT_ALL();int thread=3,t=70;
sei();
Receiving_ON;
while(1){ // run forever
Receiving_ON;
TIMER0_OFF;
if (REC_ERROR_FLAG==0){
Receiving_OFF;
TIMER0_ON;
if (thread==1){
PORTA|=(1<<PORTA3);
Receiving_OFF;
ERROR_handler();
}
if (thread==2){
///
//
PWM_Update();
}
if (thread==3){
//PORTA^=(1<<PORTA3);
Report_Log1();
START_STOP_CMD_INIT();
MT_ERROR_FLAGS_INIT();// REC_ERROR_FLAG flag is set to 1 so that the set pwm functions are executed only once in one thread
TIMER0_OFF;
}
}
} // repeat this forever^
}
ISR(TIMER0_COMP_vect)
{
s=s++;
if(s==t){
if(thread==3){
PORTA&=~(1<<PORTA3);
thread=1;t=70;
}
else if(thread==1) {
thread=2;t=70;
}
else if(thread==2) {
thread=3;t=70;
}
s=0;
}
}