Close

Temporization for Standard Paddle.

A project log for Digi:Arka

Dirt-cheap Vaus paddle clone for MSX - Now supports Standard Paddles too.

danjovicdanjovic 04/05/2020 at 02:130 Comments

According to MSX Red book:

"Each paddle is basically a one-shot pulse generator, the length of the pulse being controlled by a variable resistor. A start pulse is issued to the specified joystick connector via PSG Register 15. A count is then kept of how many times PSG Register 14 has to be read until the relevant input times out. Each unit increment represents an approximate period of 12 µs on an MSX machine with one wait state."

When you do the math, 256 increments of 12us yelds: 12us*256 = 3072us.

Time for Potentiometer at minimum
Timing for Potentiometer at minimum: 12.125us
Timing for Potentiometer at maximum: 3058us
Timing for Potentiometer at maximum: 3058us

Mission Accomplished!

A quick note, though.

Pulse pins coming from MSX triggers a Pin Change interrupt on the AVR. At the beginning of the ISR it was necessary to read the state of the line to check whether the pin change has been a rising or a falling edge.

The DigitalRead() function was taking too long to execute, longer than the 4.7us that the input pulse lasted.

After the code was changed to read the AVR input register (PINB) directly the Standard paddle function worked fine.

#define SOChigh() PINB&(1<<1) // Fast digital reading

//
// Pin change interrupt driven by SOC (Start of Conversion) pin (8) - PULSE
//
ISR(PCINT0_vect) { //

  if (SOChigh()  ) { //Rising edge?
...
...

Discussions