externer taktgeber

This commit is contained in:
Mike Schwörer 2017-05-11 11:58:44 +02:00
parent 80775aa181
commit 4eebfe8255
4 changed files with 86 additions and 4 deletions

View File

@ -106,6 +106,11 @@
this.cbxComPorts = new System.Windows.Forms.ComboBox(); this.cbxComPorts = new System.Windows.Forms.ComboBox();
this.btnRSConnect = new System.Windows.Forms.Button(); this.btnRSConnect = new System.Windows.Forms.Button();
this.btnRSDisconnect = new System.Windows.Forms.Button(); this.btnRSDisconnect = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.edClockAddr = new System.Windows.Forms.TextBox();
this.edClockBit = new System.Windows.Forms.TextBox();
this.btnClockStart = new System.Windows.Forms.Button();
this.edCLockFreq = new System.Windows.Forms.TextBox();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -798,11 +803,58 @@
this.btnRSDisconnect.UseVisualStyleBackColor = true; this.btnRSDisconnect.UseVisualStyleBackColor = true;
this.btnRSDisconnect.Click += new System.EventHandler(this.btnRSDisconnect_Click); this.btnRSDisconnect.Click += new System.EventHandler(this.btnRSDisconnect_Click);
// //
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(915, 610);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(56, 13);
this.label6.TabIndex = 58;
this.label6.Text = "Taktgeber";
//
// edClockAddr
//
this.edClockAddr.Location = new System.Drawing.Point(918, 626);
this.edClockAddr.Name = "edClockAddr";
this.edClockAddr.Size = new System.Drawing.Size(64, 20);
this.edClockAddr.TabIndex = 59;
this.edClockAddr.Text = "0x20";
//
// edClockBit
//
this.edClockBit.Location = new System.Drawing.Point(994, 626);
this.edClockBit.Name = "edClockBit";
this.edClockBit.Size = new System.Drawing.Size(64, 20);
this.edClockBit.TabIndex = 60;
this.edClockBit.Text = "3";
//
// btnClockStart
//
this.btnClockStart.Location = new System.Drawing.Point(1064, 626);
this.btnClockStart.Name = "btnClockStart";
this.btnClockStart.Size = new System.Drawing.Size(49, 23);
this.btnClockStart.TabIndex = 61;
this.btnClockStart.Text = "Start";
this.btnClockStart.UseVisualStyleBackColor = true;
this.btnClockStart.Click += new System.EventHandler(this.btnClockStart_Click);
//
// edCLockFreq
//
this.edCLockFreq.Location = new System.Drawing.Point(918, 652);
this.edCLockFreq.Name = "edCLockFreq";
this.edCLockFreq.Size = new System.Drawing.Size(140, 20);
this.edCLockFreq.TabIndex = 62;
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1298, 692); this.ClientSize = new System.Drawing.Size(1298, 692);
this.Controls.Add(this.edCLockFreq);
this.Controls.Add(this.btnClockStart);
this.Controls.Add(this.edClockBit);
this.Controls.Add(this.edClockAddr);
this.Controls.Add(this.label6);
this.Controls.Add(this.btnRSDisconnect); this.Controls.Add(this.btnRSDisconnect);
this.Controls.Add(this.btnRSConnect); this.Controls.Add(this.btnRSConnect);
this.Controls.Add(this.cbxComPorts); this.Controls.Add(this.cbxComPorts);
@ -948,6 +1000,11 @@
private System.Windows.Forms.ComboBox cbxComPorts; private System.Windows.Forms.ComboBox cbxComPorts;
private System.Windows.Forms.Button btnRSConnect; private System.Windows.Forms.Button btnRSConnect;
private System.Windows.Forms.Button btnRSDisconnect; private System.Windows.Forms.Button btnRSDisconnect;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox edClockAddr;
private System.Windows.Forms.TextBox edClockBit;
private System.Windows.Forms.Button btnClockStart;
private System.Windows.Forms.TextBox edCLockFreq;
} }
} }

View File

@ -142,7 +142,7 @@ namespace PIC_Simulator
private void StepProgramm() private void StepProgramm()
{ {
bool finished = programm.Step(); bool finished = programm.Step(int.Parse(insertTime.Text));
if (finished) { quartztimer.Stop(); MessageBox.Show("Finished"); return; } if (finished) { quartztimer.Stop(); MessageBox.Show("Finished"); return; }
@ -483,6 +483,15 @@ namespace PIC_Simulator
{ {
rs232.Disconnect(); rs232.Disconnect();
} }
private void btnClockStart_Click(object sender, EventArgs e)
{
programm.TaktgeberAktiviert = !programm.TaktgeberAktiviert;
programm.TaktgeberFrequenz = int.Parse(edCLockFreq.Text);
programm.TaktgeberZahler = 0;
programm.TaktgeberAdresse = Convert.ToUInt32(edClockAddr.Text.Substring(2), 16);
programm.TaktgeberBitnummer = uint.Parse(edClockBit.Text);
}
} }
} }

View File

@ -118,6 +118,12 @@ namespace PIC_Simulator.PIC
public List<int> Breakpoints = new List<int>(); public List<int> Breakpoints = new List<int>();
public int TaktgeberFrequenz = 100000;
public int TaktgeberZahler = 100000;
public bool TaktgeberAktiviert = false;
public uint TaktgeberAdresse = 0;
public uint TaktgeberBitnummer = 0;
public PICProgramm() public PICProgramm()
{ {
// Anfangswerte // Anfangswerte
@ -210,12 +216,22 @@ namespace PIC_Simulator.PIC
return binaryval; return binaryval;
} }
public bool Step() public bool Step(int frequenz)
{ {
if (PCCounter >= befehle.Count) return true; if (PCCounter >= befehle.Count) return true;
PICBefehl aktueller_befehl = befehle[PCCounter]; PICBefehl aktueller_befehl = befehle[PCCounter];
if (TaktgeberAktiviert)
{
TaktgeberZahler += frequenz;
if (TaktgeberZahler > TaktgeberFrequenz)
{
TaktgeberZahler = 0;
SetRegisterOhneBank(TaktgeberAdresse, TaktgeberBitnummer, !GetRegisterOhneBank(TaktgeberAdresse, TaktgeberBitnummer));
}
}
if (IsSleeping) return false; if (IsSleeping) return false;
if (aktueller_befehl.befehl == ADDWF) if (aktueller_befehl.befehl == ADDWF)

View File

@ -19,7 +19,7 @@
[ ] Testprogramm 5 (Bitbefehle) [ ] Testprogramm 5 (Bitbefehle)
[ ] Testprogramm 6 (indirekte Adressierung) [ ] Testprogramm 6 (indirekte Adressierung)
[ ] Testprogramm 7 (Timer 0 ) [ ] Testprogramm 7 (Timer 0 )
[ ] Ext. Taktgeber an RA4 + IO-Pin [X] Ext. Taktgeber an RA4 + IO-Pin
[ ] Testprogramm 7 (Interrupts) [ ] Testprogramm 7 (Interrupts)
[ ] Testprogramm 9 (Sleep-Befehl) [ ] Testprogramm 9 (Sleep-Befehl)
[ ] Tetstprogramm 10 (PCL und PCLATH) [ ] Tetstprogramm 10 (PCL und PCLATH)