title: pic18f47q43 Reading from program flash memory problem
body: <p>I am using MPLAB X IDE and MPLAB Code Configurator (MCC).</p>
  <p>i generated the library of the flash read/write and erase with MCC.</p>
  <p>then when i used &quot;<code>FLASH_ReadPage</code>&quot; built in function created from the MCC its not working, and after debugging i found it stucked in a while loop that is checking for &quot;<code>NVMCON0bits.GO</code>&quot; to be cleared and its never cleared thats why its stucked.</p>
  <p>here is the function:</p>
  <pre><code>void FLASH_ReadPage(uint32_t flashAddr)
  {
      uint8_t GIEBitValue = INTCON0bits.GIE; // Save interrupt enable
  
      //Set NVMADR with the target word address
      NVMADRU = (uint8_t) ((flashAddr &amp; 0x00FF0000) &gt;&gt; 16);
      NVMADRH = (uint8_t) ((flashAddr &amp; 0x0000FF00) &gt;&gt; 8);
      NVMADRL = (uint8_t) (flashAddr &amp; 0x000000FF);
  
      //Set the NVMCMD control bits for Page Read operation
      NVMCON1bits.NVMCMD = 0b010;
  
      //Disable all interrupt
      INTCON0bits.GIE = 0;
  
      //Perform the unlock sequence
      NVMLOCK = 0x55;
      NVMLOCK = 0xAA;
  
      //Start page read and wait for the operation to complete
      NVMCON0bits.GO = 1;
      while (NVMCON0bits.GO);    **&lt;----- Stucked here**
      
      //Restore the interrupts
      INTCON0bits.GIE = GIEBitValue;
  
      //Set the NVMCMD control bits for Word Read operation to avoid accidental writes
      NVMCON1bits.NVMCMD = 0b000;
  }
  </code></pre>