c - EEPROM data to TeraTerminal -


i attempting read data external eeprom using atmega324p. issue coming loop. cannot past reading 4 pages (4 x 64b) of eeprom data. if increase loop counter 4 5 stuck in infinite loop of uart0 transmits. here code have currently:

// create array store logged off eeprom data , use  //in sending bytes teraterm. location 0-15 hold first assertlog uchar aucteratermmsgbuf[ext_eeprom_page_length]; //length 64b   void teratermoutputmsg(void) {         //configure uart0 want purposes teratermconfiguart0();  //define starting address read from.  each time button pushed  //we begin reading beginning of memory array (aka full dump of eeprom stored data) uint16 eepromreadaddress = 0x0000;  //loop thru whole eeprom 1 page of data @ time , send it.   //cant past 4 pages though.... todo fix  for(uint16 uspagessent = 0; uspagessent < 4; uspagessent++)  {     //get 1 page of log specified address in eeprom , store      //array of type uchar , length of 1 page (64b).     teratermgetassertlog(eepromreadaddress);      //send 1 page of eeprom data teraterm     teratermuart0transmit();      //update next read address pass log function     eepromreadaddress += ext_eeprom_page_length; //length 64bytes   }  }  //gets data eeprom , puts array in prep send out uart0 pc void teratermgetassertlog(uint16 nextreadaddress) { //initialize array storing eeprom data for(uint16 = 0; < ext_eeprom_page_length; i++)     aucteratermmsgbuf[i] = 0;  //this read bytes eeprom , load them array exteeprom_read(aucteratermmsgbuf, nextreadaddress);              }  //function output string of data out pc void teratermuart0transmit(void) { //array encode tera term message using sprintf.   //takes each hex value (0x_ _ ) , converts ascii code numbers/letters uchar encodemsgarray[2]; //next character transmitted uchar nextchar;  //counter bytes sent.  after 16 (1 log) want send new line break point uint8 bytecount = 0x01;  //loop through message buffer , send output teraterm for(uint16 = 0; < ext_eeprom_page_length; i++) {     //get next char teraterm output buffer array     nextchar = aucteratermmsgbuf[i];      //convert char hex value ascii code 2 letters/numbers present in 1 hex value     sprintf(encodemsgarray, "%2.2x", nextchar);      //transmit 2 ascii codes on uart0 teraterm space after     uart0_transmit(encodemsgarray[0]);     uart0_transmit(encodemsgarray[1]);     uart0_transmit(" ");    //send space text file parser can distinguish between bytes of data       //if have sent whole assert log, print next new line     if(bytecount == 16)     {         bytecount = 0x00;         sprintf(encodemsgarray, "\r\n");         uart0_transmit(encodemsgarray[0]);         uart0_transmit(encodemsgarray[1]);      }      ++bytecount; }  } 

i know might kind of lot read through, stumped. when put loop counter variable (pagessent) in watch window, gets optmized, when declare volatile still gets optimized, when max value set 4 loop exits properly, if max value higher 4 stuck... help.

i figured out looking @ optmization posts. if loop variable not used, compiler sets variable max value. not understand compilers or optimization. being said, if pass uspagessent variable teratermuart0transmit , multiply 64 in function next (page) address, well. helpful down line. here link helpful post:for loop being ignored (optimized?) out


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -