-duet16: Added external PTM clock. [Ryan Holtz] (#10103)

-6840ptm: Fixed one-shot behavior and timer enabling when switching to
internal clock. [Ryan Holtz]
This commit is contained in:
MooglyGuy 2022-07-19 04:39:38 +02:00 committed by GitHub
parent 6f8673a00a
commit 37447e16d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 13 deletions

View File

@ -412,14 +412,7 @@ void ptm6840_device::reload_count(int idx)
if (one_shot_mode)
{
m_output[idx] = false;
if (!(m_control_reg[idx] & COUNT_OUT_EN))
{
m_out_cb[idx](0);
}
else
{
m_out_cb[idx](m_output[idx]);
}
m_out_cb[idx](m_output[idx]);
}
// Set the timer
@ -441,7 +434,7 @@ void ptm6840_device::reload_count(int idx)
duration += attotime::from_ticks(2, clock());
LOGMASKED(LOG_COUNTERS, "Timer #%d init_timer: output = %f\n", idx + 1, duration.as_double());
LOGMASKED(LOG_COUNTERS, "Timer #%d init_timer: duration = %f\n", idx + 1, duration.as_double());
m_enabled[idx] = 1;
@ -636,10 +629,11 @@ void ptm6840_device::write(offs_t offset, uint8_t data)
if (gated)
{
m_timer[idx]->adjust(attotime::never);
m_disable_time[idx] = duration;
}
else
{
m_disable_time[idx] = duration;
m_timer[idx]->adjust(duration, idx);
}
}
}
@ -738,8 +732,14 @@ TIMER_CALLBACK_MEMBER(ptm6840_device::timeout)
{
m_out_cb[param](0);
}
m_enabled[param]= 0;
reload_count(param);
m_enabled[param] = 0;
const bool one_shot_mode = m_mode[param] == 4 || m_mode[param] == 6;
if (!one_shot_mode)
{
reload_count(param);
}
}

View File

@ -391,7 +391,7 @@ void duet16_state::duet16(machine_config &config)
bgpit.out_handler<2>().set("kbusart", FUNC(i8251_device::write_txc));
bgpit.out_handler<2>().append("kbusart", FUNC(i8251_device::write_rxc));
ptm6840_device &itm(PTM6840(config, "itm", 0));
ptm6840_device &itm(PTM6840(config, "itm", 8_MHz_XTAL / 8));
itm.set_external_clocks(0.0, 0.0, (8_MHz_XTAL / 8).dvalue()); // C3 = 1MHz
itm.o3_callback().set("itm", FUNC(ptm6840_device::set_c1)); // C1 = C2 = O3
itm.o3_callback().append("itm", FUNC(ptm6840_device::set_c2));