anchor.diff:    BytesWrite := 0;
     Address := StartAddress;
     MainForm.ProgressBar.Max := WriteSize div PageSize;
  -  try
  -
  -    while Address < WriteSize do
  -    begin
  -      if (WriteSize - Address) < PageSize then PageSize := (WriteSize - Address);
  -      FillByte(DataChunk, PageSize, $FF);
  -      BytesWrite := BytesWrite + UsbAspI2C_Write(hUSBDev, DevAddr, MainForm.ComboAddrType.ItemIndex, Address, datachunk, PageSize);
  -      Inc(Address, PageSize);
  -
  -      while UsbAspI2C_BUSY(hUSBdev, DevAddr) do
  -      begin
  -        Application.ProcessMessages;
  -      end;
  -
  -      MainForm.ProgressBar.Position := MainForm.ProgressBar.Position + 1;
  +
  +  while Address < WriteSize do
  +  begin
  +    if (WriteSize - Address) < PageSize then PageSize := (WriteSize - Address);
  +    FillByte(DataChunk, PageSize, $FF);
  +    BytesWrite := BytesWrite + UsbAspI2C_Write(hUSBDev, DevAddr, MainForm.ComboAddrType.ItemIndex, Address, datachunk, PageSize);
  +    Inc(Address, PageSize);
  +
  +    while UsbAspI2C_BUSY(hUSBdev, DevAddr) do
         Application.ProcessMessages;
  -    end;
  -
  -  finally
  +
  +    MainForm.ProgressBar.Position := MainForm.ProgressBar.Position + 1;
  +    Application.ProcessMessages;
     end;
   
     if BytesWrite <> WriteSize then
       LogPrint(STR_WRONG_BYTES_WRITE, clRed)
     else
       LogPrint(STR_DONE);
  +
     MainForm.ProgressBar.Position := 0;
   end;
   
  
positive.code: 
    if ChunkSize > ChipSize then ChunkSize := ChipSize;
  
    try
      UsbAspMW_EWEN(hUSBDev, AddrBitLen);
  
      while Address < ChipSize div 2 do
      begin
        RomStream.ReadBuffer(DataChunk, ChunkSize);
  
        BytesWrite := BytesWrite + UsbAspMW_Write(hUSBDev, AddrBitLen, Address, datachunk, ChunkSize);
        Inc(Address, ChunkSize div 2);
  
        if Current_HW = CH341 then
          while ch341mw_busy do
          begin
            Application.ProcessMessages;
          end;
  
        if Current_HW = AVRISP then
          while avrisp_mw_busy do
          begin
            Application.ProcessMessages;
          end;
  
        if Current_HW = USBASP then
          while UsbAspMW_Busy(hUSBDev) do
          begin
            Application.ProcessMessages;
          end;
  
        MainForm.ProgressBar.Position := MainForm.ProgressBar.Position + ChunkSize;
        Application.ProcessMessages;
      end;
  
    finally
  
    end;
  
    if BytesWrite <> ChipSize then
      LogPrint(STR_WRONG_BYTES_WRITE, ClRed)
    else
      LogPrint(STR_DONE);
    MainForm.ProgressBar.Position := 0;
  end;
  
  procedure WriteFlash25(var RomStream: TMemoryStream; StartAddress, WriteSize: cardinal; PageSize: word; WriteType: integer);
  var
    DataChunk: array[0..2047] of byte;
    DataChunk2: array[0..2047] of byte;
  
negative.code:   Address := StartAddress;
    MainForm.ProgressBar.Max := ChipSize div ChunkSize;
  
    RomStream.Clear;
  
    while Address < ChipSize do
    begin
      if ChunkSize > (ChipSize - Address) then ChunkSize := ChipSize - Address;
  
      if ChipSize > FLASH_SIZE_128MBIT then
        BytesRead := BytesRead + UsbAsp25_Read32bitAddr(hUSBDev, $13, Address, datachunk, ChunkSize)
      else
        BytesRead := BytesRead + UsbAsp25_Read(hUSBDev, $03, Address, datachunk, ChunkSize);
  
      RomStream.WriteBuffer(datachunk, chunksize);
      Inc(Address, ChunkSize);
  
      MainForm.ProgressBar.Position := MainForm.ProgressBar.Position + 1;
      Application.ProcessMessages;
  
      if MainForm.ButtonCancel.Tag <> 0 then
      begin
        LogPrint(STR_USER_CANCEL, clRed);
        Break;
      end;
    end;
  
    if BytesRead <> ChipSize then
      LogPrint(STR_WRONG_BYTES_READ, clRed)
    else
      LogPrint(STR_DONE);
  
    MainForm.ProgressBar.Position := 0;
  end;
  
  