/*------------------------------------------------ Function for memory write ------------------------------------------------*/ void EeWrite() { temp_prog = PROG_NO - 0X30; WMCON |= EEMEN_; WMCON |= EEMWE_; program[temp_prog].e_total_turns = prog.total_turns; program[temp_prog].e_stop1_turns = prog.stop1_turns; // same copying code here... for( i=0; i < 2500; i++ ) { if( WMCON & EERDY_ ) break; } WMCON &= ~EEMEN_; // EEMEN=1; WMCON &= ~EEMWE_; // EEMWE_=1; }
/*------------------------------------------------ Function for memory read ------------------------------------------------*/ void EeRead() { temp_prog = PROG_NO - 0X30 WMCON |= EEMEN_; // EEMEN=1; prog.total_turns = program[temp_prog].e_total_turns; prog.stop1_turns = program[temp_prog].e_stop1_turns; prog.trvs = program[temp_prog].e_trvs; prog.offset = program[temp_prog].e_offset; prog.index = program[temp_prog].e_index; prog.stop2_turns= program[temp_prog].e_stop2_turns; prog.dir = program[temp_prog].e_dir; WMCON &= ~EEMEN_; // EEMEN=1; }
This is one more observation that when I compile my code in Keil, it omits some of my Instructions It sounds strange, but is true. When after compiling I start debugging, it wont show the breakpoint at some positions. It won't execute that instruction too! The Keil compiler is an optimizing compiler. That means, it optimizes your program and may move stuff around and combine things that you didn't think about. This is how all optimizing compilers work. You should probably take a look at the following knowledgebase article: http://www.keil.com/support/docs/2467.htm. Jon