107107
108108#define TMS_CRYSTAL_FREQ_HZ 10738635.0f
109109
110- #define PICO_CLOCK_PLL 1512000000
111- #define PICO_CLOCK_PLL_DIV1 4
110+ //#define PICO_CLOCK_PLL 1512000000 // 302.4MHz - standard voltage
111+ //#define PICO_CLOCK_PLL_DIV1 5
112+
113+ //#define PICO_CLOCK_PLL 1308000000 // 327MHz - 1.15v
114+ //#define PICO_CLOCK_PLL_DIV1 4
115+
116+ //#define PICO_CLOCK_PLL 984000000 // 328MHz - 1.15v
117+ //#define PICO_CLOCK_PLL_DIV1 3
118+
119+ //#define PICO_CLOCK_PLL 1056000000 // 352MHz - 1.3v
120+ //#define PICO_CLOCK_PLL_DIV1 3
121+
122+ #define PICO_CLOCK_PLL 1128000000 // 376MHz - 1.3v
123+ #define PICO_CLOCK_PLL_DIV1 3
124+
125+ //#define PICO_CLOCK_PLL 1512000000 // 378MHz - 1.3v
126+ //#define PICO_CLOCK_PLL_DIV1 4
127+
128+ //#define PICO_CLOCK_PLL 804000000 // 402MHz - DOES NOT WORK
129+ //#define PICO_CLOCK_PLL_DIV1 2
130+
131+ //#define PICO_CLOCK_PLL 1212000000 // 404MHz - DOES NOT WORK
132+ //#define PICO_CLOCK_PLL_DIV1 3
133+
112134#define PICO_CLOCK_PLL_DIV2 1
113135#define PICO_CLOCK_HZ (PICO_CLOCK_PLL / PICO_CLOCK_PLL_DIV1 / PICO_CLOCK_PLL_DIV2)
114136
@@ -188,6 +210,7 @@ void __not_in_flash_func(pio_irq_handler)()
188210 else if ((TMS_PIO -> fstat & (1u << (PIO_FSTAT_RXEMPTY_LSB + tmsReadSm ))) == 0 ) // read?
189211 {
190212 uint32_t readVal = TMS_PIO -> rxf [tmsReadSm ];
213+ uint32_t readDat = TMS_PIO -> rxf [tmsReadSm ]; // What was read?
191214
192215 if ((readVal & 0x04 ) == 0 ) // read data
193216 {
@@ -200,7 +223,8 @@ void __not_in_flash_func(pio_irq_handler)()
200223 switch (tms9918 -> registers [0x0F ] & 0x0F )
201224 {
202225 case 0 :
203- currentStatus = 0x1f ;
226+ currentStatus &= ~(readDat >> 16 ); // Switch off any 3 high bits which have just been read
227+ currentStatus |= 0x1f ;
204228 vrEmuTms9918SetStatusImpl (currentStatus );
205229 currentInt = false;
206230 gpio_put (GPIO_INT , !currentInt );
@@ -220,8 +244,6 @@ void __not_in_flash_func(pio_irq_handler)()
220244 */
221245static inline void enableTmsPioInterrupts ()
222246{
223- __dmb ();
224- * ((io_rw_32 * )(PPB_BASE + M0PLUS_NVIC_ICPR_OFFSET )) = 1u << TMS_IRQ ;
225247 * ((io_rw_32 * )(PPB_BASE + M0PLUS_NVIC_ISER_OFFSET )) = 1u << TMS_IRQ ;
226248}
227249
@@ -231,7 +253,6 @@ static inline void enableTmsPioInterrupts()
231253static inline void disableTmsPioInterrupts ()
232254{
233255 * ((io_rw_32 * )(PPB_BASE + M0PLUS_NVIC_ICER_OFFSET )) = 1u << TMS_IRQ ;
234- __dmb ();
235256}
236257
237258#ifdef GPIO_RESET
0 commit comments