From 37447e16d466ef1834b5375ee6746bfbdfa4d95d Mon Sep 17 00:00:00 2001 From: MooglyGuy Date: Tue, 19 Jul 2022 04:39:38 +0200 Subject: -duet16: Added external PTM clock. [Ryan Holtz] (#10103) -6840ptm: Fixed one-shot behavior and timer enabling when switching to internal clock. [Ryan Holtz] --- src/devices/machine/6840ptm.cpp | 24 ++++++++++++------------ src/mame/matsushita/duet16.cpp | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/devices/machine/6840ptm.cpp b/src/devices/machine/6840ptm.cpp index 390669d0b1c..f63a3c4bca7 100644 --- a/src/devices/machine/6840ptm.cpp +++ b/src/devices/machine/6840ptm.cpp @@ -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); + } } diff --git a/src/mame/matsushita/duet16.cpp b/src/mame/matsushita/duet16.cpp index 9c9fed0bca0..12df48118a9 100644 --- a/src/mame/matsushita/duet16.cpp +++ b/src/mame/matsushita/duet16.cpp @@ -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)); -- cgit v1.2.3