Hi all,
I read on this forum this is not a good practice :
jmp_buf Go_back_to_beginning; int main (void){ setjmp ( Go_back_to_beginning ); delay_ms( 50 ); //// wait until 50ms free of ISR while(1){ if( Something_else_is_High ){ if( setjmp( Go_back_to_beginning ) ) Do_SOMETHING_very_long_depending_on_updated_critical_value( critical_value ); } else { if( setjmp( Go_back_to_beginning ) ) Do_ANOTHER_THING_very_long_depending_on_updated_critical_value( critical_value ); } } } ISR( INT0_vect ){ Do_sometimes_something_critical_but_very_quick(); critical_value++; longjmp ( Go_back_to_beginning, 1); }
But I don't understand why, because longjmp will return quickly 1, and then leave ISR ? No ?
It's too bad if it's not possible because, it would be cool to imagine very great structures, very flexible with that feature.
Should I use Goto instead, and then test a flag to :
- Do_SOMETHING_very_long_depending_on_updated_critical_value()
- or: Do_ANOTHER_THING_very_long_depending_on_updated_critical_value()
What would be the syntax of GOTO please (I never used it in C) ?
Thanks, all of you :wink: