i had change the global variable value in interrupt vector function, but this value doesn't transfered into the function or the function doesn't read the changed value, which is changed by the interruption vector. the vector interruption itself is
//---------------------------------------------
ISR(INT1_vect)
{
EIMSK |= !(1<<INT1); //disable int1 âíåøíèå ïðåðûâàíèÿ INT0
_delay_ms(900);
switch(Ok)
{
case 0: MenuOut();break;
case 1: endFunction=1;break;
//case 1: EndFunction(endFunction,Ok);break; //1st var -doesnt print changed value ok and endFunction
default:break;
//case 20:Ok=0;MenuPrint();break;
}
//EIMSK |= (1<<INT1); add this line 2 func 2 enable
}
//---------------------------------------------
and the function itself is look like this (i had removed excessed details, just significant cycle less) the idea is if the function is launched, the flag OK=1, and in this case the interruption processing function change value of the variable endFunction and it's value is checked at the start of every cycle, and by default is 0, so when it changed by the interrupt to 1, the cycle must to break, but really it continues before completing.
and the full text of function is below, in real it had some more operators which are not significant for the question, but all the function has properly works, except the cycle breaking.
//-------------------- Adc START -----------------------------------------------
void Adc (void) // dummy of Adc for the interrupt check only, later change to full power Adc,it's for screen output only
//void Adc (volatile unsigned char endFunction,volatile unsigned char Ok) //read the first 2 cells in array symbol[ ]
{
Ok=1; //button action flag - function is active//endFunction=0; //fla
unsigned char j=0,n=0; //cycle counter
Clearscreen();
EIMSK |=(1<<INT1); //add this line 2 func 2 enable intrrpt
while(j<100)
{
//endFunction=0; //by default
//----------------------check that pressed the select button ---------------------------------
if (endFunction==1){break;}
//if (Ok==1){MenuOut(); break;}
//---------------------------------------------------
while(n<6) // this cycle just repeat existing value measured before, n times for the screen filling
{
unsigned char m = 0;
SetPgAddr(n,n+1);
SetClmAddr((n*2),100);
while (m<6)
{
unsigned char a = 78-47; //my table symbol number is less than ascii 2 47
if ((a <1)|(a>10))
{
a=17; //@
}
Char1(a);
m++;
_delay_ms(500);
}
//+1 is for 2 down 2 one line in my sym table
Char1(endFunction+1);Char1(Ok+1);
// : 26 0
// 0 16 1 ascii48
// 1 17 2
// . 26 11
// C 35 20
n++;//p2=p3=0;
_delay_ms(100);
}
//-------------------------------------------
j++;Char1(13); //for new edition identificator symbol -
}
Ok=0;endFunction=0; //initialisation on out - button action flag - function is un active
}
//-----------Adc FINISH -------------------------------------------------------
as for the variable declaring, i had declared is as global in first lines of main.c file, it looks like this:
// ---------------global --------------------------------
unsigned char a0;
unsigned int adc_value=0;
unsigned int adt_value=0;
unsigned char ColPosSt = 0;
unsigned char ColPosEnd = 127;
volatile unsigned char endFunction=0; //for the cancel - flag
volatile unsigned char Ok=0; //for menu choice //button action flag - function is active
unsigned char PgPosSt = 0;
unsigned char PgPosEnd = 7;
unsigned char sec=0;
unsigned char zer =0;
unsigned char Line = 0; //for menu choice
//WARNING: This Font Require X-GLCD Lib.
// You can not use it with MikroE GLCD Lib.
You passed endFunction by value:
void Adc (volatile unsigned char endFunction,volatile unsigned char Ok) //read the first 2 cells in array symbol[ ] {it is a local variable (copy of argument you give calling that function) so interrupt routine doesn't even know about it. You need access directly global endFunction variable or pass it as e.g. pointer.