private void btnEepromWrite_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
            {
                Eeprom.MemWrRunning = false;
                return;
            }
            else
            {
                Eeprom.FileName = openFileDialog1.FileName;
            }

            Eeprom.MemWrRunning = true;
            tbxCurrentAddr.Text = tbxStartAddr.Text;

            Eeprom.SetEepromParam(Convert.ToInt32(tbxStartAddr.Text),  // Addr
                                  Convert.ToInt32(tbxSize.Text),       // Length
                                  Convert.ToByte(tbxPageSize.Text),    // PageSize
                                  Convert.ToByte(tbxAddr.Text, 16),    // DeviceAddr
                                  cbx2ByteAddr.Checked);               //

            tmPolling.Interval = 1;
            tmPolling.Start();
        }
        private void tmPolling_Tick(object sender, EventArgs e)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new tmPollingTickDelegate(tmPolling_Tick), new object[] { sender, e });
            }
            else
            {
                if (cbxRepeat.Checked == true)       // Terminal Tx repeat
                {
                    bool Ack = true;

                    if (tbxI2cTx.Text != "") // if "", then supress I2cWr
                    {
                        Ack = I2c.WriteBytes(Convert.ToByte(tbxAddr.Text, 16),
                                             tbxI2cTx.Text);

                        if (cbxRepeatedStart.Checked == false)
                        {
                            I2c.StopCond();
                        }
                    }
                    if (Ack == false)
                    {
                        uiNAKCnt++;
                        tbxNAKCnt.Text = Convert.ToString(uiNAKCnt);
                    }
                    else
                    {
                        if ((tbxRxCount.Text != "") && (tbxRxCount.Text != "0"))
                        {                   // something to read
                            ReadAndLog(Convert.ToByte(tbxRxCount.Text, 10));

                            I2c.StopCond();
                        }                   // end of something to read
                    }



                    TxRepeatCounter++;
                    tbxRepeatCounter.Text = Convert.ToString(TxRepeatCounter);

                    if ((StopOnError == true) &&
                        (Ack == false))
                    {
                        cbxRepeat.Checked = false;
                    }
                }

                else if (Eeprom.MemRdRunning == true)
                {
                    if (Eeprom.Read() == false)
                    {
                        uiNAKCnt = Convert.ToUInt16(tbxNAKCnt.Text);
                        uiNAKCnt++;
                        tbxNAKCnt.Text      = Convert.ToString(uiNAKCnt);
                        Eeprom.MemRdRunning = false;
                        tbxCurrentAddr.Text = "failed";
                    }
                    else
                    {
                        tbxCurrentAddr.Text = Convert.ToString(Eeprom.Addr);
                    }
                }

                else if (Eeprom.MemWrRunning == true)
                {
                    if (Eeprom.Write() == false)
                    {
                        uiNAKCnt = Convert.ToUInt16(tbxNAKCnt.Text);
                        uiNAKCnt++;
                        tbxNAKCnt.Text      = Convert.ToString(uiNAKCnt);
                        Eeprom.MemWrRunning = false;
                        tbxCurrentAddr.Text = "failed";
                    }
                    else
                    {
                        Thread.Sleep(10);           // 10ms Eeprom Wr
                        tbxCurrentAddr.Text = Convert.ToString(Eeprom.Addr);
                    }
                }

                else if (I2c.LogOn == true)
                {
                    tbxLogCounter.Text = Convert.ToString(I2c.LogCounter);
                }

                else if (CaptureRunning == true)
                {
                    CaptureI2c();
                }

                else
                {
                    tmPolling.Stop();
                }
            }
        }