I have basic C# form which program microcontroller but I have hard time on fuse programming.
Command line code to program fuse is: "atprogram.exe –t atmelice –i jtag -d atmega2561 write -fs --values E299FF"
- As you can see in image fuse program successfully in command line
- In Visual Studio form same command line return nothing.
- When I substitute fuse code with chip erase code form return result. This only happen when I program the fuse.
- I have also tires WaitForExit(); still nothing
Original C# file can be downloaded from: Microchip Visual Studio form code
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;
}
Please let me know if you have additional questions.