Commit 1e9b2e6d authored by lcgamboa's avatar lcgamboa

fix: Fix gpboard simulation clock speed.

parent 829fff56
...@@ -2,5 +2,5 @@ PACKAGE=picsimlab ...@@ -2,5 +2,5 @@ PACKAGE=picsimlab
MAINVER=0 MAINVER=0
MINORVER=9 MINORVER=9
VERSION=0.9.2 VERSION=0.9.2
DATE=240324 DATE=240406
VERSION_STABLE=0.9.1 VERSION_STABLE=0.9.1
...@@ -273,13 +273,12 @@ void cboard_gpboard::Draw(void) { ...@@ -273,13 +273,12 @@ void cboard_gpboard::Draw(void) {
} }
void cboard_gpboard::Run_CPU(void) { void cboard_gpboard::Run_CPU(void) {
int i; long int i;
// int j; // int j;
unsigned char pi; unsigned char pi;
unsigned int alm[64]; unsigned int alm[64];
const int pinc = MGetPinCount(); const int pinc = MGetPinCount();
// const int JUMPSTEPS = Window1.GetJUMPSTEPS ();
// //number of steps skipped // //number of steps skipped
const long int NSTEP = PICSimLab.GetNSTEP(); // number of steps in 100ms const long int NSTEP = PICSimLab.GetNSTEP(); // number of steps in 100ms
const float RNSTEP = 200.0 * pinc / NSTEP; const float RNSTEP = 200.0 * pinc / NSTEP;
...@@ -293,8 +292,8 @@ void cboard_gpboard::Run_CPU(void) { ...@@ -293,8 +292,8 @@ void cboard_gpboard::Run_CPU(void) {
// j = JUMPSTEPS; //step counter // j = JUMPSTEPS; //step counter
pi = 0; pi = 0;
if (PICSimLab.GetMcuPwr()) // if powered if (PICSimLab.GetMcuPwr()) // if powered
for (i = 0; i < PICSimLab.GetNSTEP(); i++) // repeat for number of steps in 100ms for (i = 0; i < NSTEP; i++) // repeat for number of steps in 100ms
{ {
/* /*
if (j >= JUMPSTEPS)//if number of step is bigger if (j >= JUMPSTEPS)//if number of step is bigger
......
...@@ -51,7 +51,10 @@ unsigned char bridge_gpsim_get_pin_count(void) { ...@@ -51,7 +51,10 @@ unsigned char bridge_gpsim_get_pin_count(void) {
} }
const char* bridge_gpsim_get_pin_name(int pin) { const char* bridge_gpsim_get_pin_name(int pin) {
return gpic->get_pin_name(pin).c_str(); if (gpic) {
return gpic->get_pin_name(pin).c_str();
}
return "error";
} }
unsigned char bridge_gpsim_get_pin_value(int pin) { unsigned char bridge_gpsim_get_pin_value(int pin) {
...@@ -107,9 +110,7 @@ void bridge_gpsim_set_apin_value(int pin, float value) { ...@@ -107,9 +110,7 @@ void bridge_gpsim_set_apin_value(int pin, float value) {
void bridge_gpsim_step(void) { void bridge_gpsim_step(void) {
gpic->step_cycle(); gpic->step_cycle();
if (gpic->mCurrentPhase == ((ClockPhase*)gpic->mExecute2ndHalf)) { bp.clear_halt();
gpic->step_cycle();
}
} }
void bridge_gpsim_end(void) { void bridge_gpsim_end(void) {
......
...@@ -83,7 +83,7 @@ void bsim_gpsim::MSetSerial(const char* port) { ...@@ -83,7 +83,7 @@ void bsim_gpsim::MSetSerial(const char* port) {
void bsim_gpsim::MSetFreq(float freq_) { void bsim_gpsim::MSetFreq(float freq_) {
freq = freq_; freq = freq_;
bridge_gpsim_set_frequency(freq); bridge_gpsim_set_frequency(freq);
TimerUpdateFrequency(freq); TimerUpdateFrequency(freq / 4.0);
} }
float bsim_gpsim::MGetFreq(void) { float bsim_gpsim::MGetFreq(void) {
...@@ -99,7 +99,7 @@ void bsim_gpsim::MSetSerial(const char* port) { ...@@ -99,7 +99,7 @@ void bsim_gpsim::MSetSerial(const char* port) {
} }
float bsim_gpsim::MGetInstClockFreq(void) { float bsim_gpsim::MGetInstClockFreq(void) {
return freq; return freq / 4.0;
} }
int bsim_gpsim::CpuInitialized(void) { int bsim_gpsim::CpuInitialized(void) {
......
...@@ -379,6 +379,8 @@ void COscilloscope::ReadPreferences(char* name, char* value) { ...@@ -379,6 +379,8 @@ void COscilloscope::ReadPreferences(char* name, char* value) {
SetMeasure(i, measures[i]); SetMeasure(i, measures[i]);
} }
} }
SetBaseTimer();
} }
std::vector<std::string> COscilloscope::WritePreferencesList(void) { std::vector<std::string> COscilloscope::WritePreferencesList(void) {
...@@ -569,6 +571,7 @@ void COscilloscope::ReadPreferencesList(std::vector<std::string>& pl) { ...@@ -569,6 +571,7 @@ void COscilloscope::ReadPreferencesList(std::vector<std::string>& pl) {
// osc_ch2 // osc_ch2
WindowCmd(PW_MAIN, "combo3", PWA_COMBOSETTEXT, tokens[9]); WindowCmd(PW_MAIN, "combo3", PWA_COMBOSETTEXT, tokens[9]);
SetChannelPin(1, atoi(tokens[9]) - 1); SetChannelPin(1, atoi(tokens[9]) - 1);
SetBaseTimer();
} }
void COscilloscope::SetBaseTimer(void) { void COscilloscope::SetBaseTimer(void) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment