我有基本的 C# 形式,可以对微控制器进行编程,但我很难进行熔丝编程。
编程保险丝的命令行代码是:“atprogram.exe –t atmelice –i jtag -d atmega2561 write -fs --values E299FF”
原始C#文件可以从以下网址下载: Microchip Visual Studio 表单代码
public StreamReader RunProgram_atprogram(String programName, String cmd, String programPath) {
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.FileName = programName;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
if (programPath.Length > 13) {
proc.StandardInput.WriteLine(programPath[0].ToString() + ":");
if (cmd.Length != 0) {
proc.StandardInput.WriteLine("cd " + programPath.Substring(0, (programPath.Length - 13)));
}
}
proc.StandardInput.WriteLine(cmd);
StreamReader reader = proc.StandardOutput;
proc.StandardInput.WriteLine("exit");
proc.Close();
return reader;
}
private void program_Click(object sender, EventArgs e)
{
StreamReader reader;
string outline;
string failflag = null;
string buffer = null;
if ((textBox1.Text == "") || (textBox2.Text == ""))
{
MessageBox.Show("Please choose atpgrogram.exe application and programming file");
return;
}
program_status.Clear();
program_status.AppendText("Programming...");
// Program Fuse
reader = RunProgram_atprogram("cmd.exe", "atprogram.exe –t atmelice –i jtag -d atmega2561 write -fs --values E299FF", textBox1.Text);
while (!reader.EndOfStream)
{
outline = reader.ReadLine();
cmd_execution_info.AppendText(outline + "\r\n");
if (outline.Length > 8)
{
if (outline.Substring(0, 8) == "Firmware")
{
failflag = reader.ReadLine();
cmd_execution_info.AppendText(failflag + "\r\n");
}
}
}
if (failflag != ("Chiperase completed successfully"))
{
program_status.Clear();
program_status.AppendText("Fail");
return;
}
如果您还有其他问题,请告诉我。