Why is this error happening in c? -


i wrote code in codevisionavr:

 //global variable int second2=0;  int sec_wait=14;  bit waito_get=0,wait_to_string=0,error_reciv=0,fail_reciv=0; . . .     // in function while (second2 < sec_wait) {      if (wait_to_string || error_reciv || fail_reciv)       second2= sec_wait; };   if (wait_to_string == 0) {       printf("second2 %d sec_wait %d error_reciv %d fail_reciv %d  \r\n",            second2, sec_wait, error_reciv, fail_reciv);  };   

output of program this:

second2 1 sec_wait 14 error_reciv 0 fail_reciv 0   

how exit while loop, when condition true value printed?

also have 2 interrupt routines:

  • interupt1: each 1 second second2++
  • interupt2: character usart , maybe set: wait_to_string ,error_reciv, fail_reciv.

my assembler code is:

; 0000 01ec               while(second2 < sec_wait){ _0x87:     call subopt_0xc     call subopt_0x5     cp   r26,r30     cpc  r27,r31     brge _0x89 ; 0000 01ed                 if(wait_to_string || error_reciv || fail_reciv)     sbrc r3,7     rjmp _0x8b     sbrc r4,0     rjmp _0x8b     sbrs r4,1     rjmp _0x8a _0x8b: ; 0000 01ee                     second2 = sec_wait;     call subopt_0xc     sts  _second2,r30     sts  _second2+1,r31 ; 0000 01ef               }; _0x8a:     rjmp _0x87 _0x89: 

if variables can modified thread, should marked volatile. if not, compiler can use cached values in register , never reload them memory. if marked volatile, compiler shall reload them main memory every time read.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -