If you have a MEGA65, you'd probably like to be able to plug a SCART cable on to the VGA port and have it Just Work :tm:, causing the MEGA65 to drive 15KHz video. Then if you plug in a normal VGA cable, you'd like regular 31KHz video still, right?
To make this small miracle reality, I've modified a MiSTer SCART cable by putting a 2K Ohm resistor between pins 12 and 15. Those pins are used for the I2C interface that lets a VGA monitor and the computer it's connected to chat to one another.
Except here we are using it just to let the MEGA65 see if this kind of modified cable is connected. And if so, then it will immediately switch to 15KHz RGB output until the cable is disconnected.
To do this, we need a little bit of VHDL that pulses those two lines periodically, and checks that what is pushed onto one pin shows up on the other, and vice-versa.
We could have used an I2C device of some sort. But that's more effort and cost than just jamming a resistor between the two pins, and adding some insulation tape to prevent these 5V I2C pins from touching anything important, like the HSYNC or VSYNC pins, which would make both the FPGA in the MEGA65 and possibly also the circuitry in your monitor permanently sad.
So if you modify a cable for this purpose, make sure you do the insulation!
Here's my test cable with some kaptan tape for the insulation:
What may be easier for many folks, is for someone to just design up a VGA pass-through cable with the resistor in it. Or even a switch so you can select 15 or 31 KHz in real-time.
Anyway, I'm blabbing here, because I'm waiting for the synthesis run to finish, so that I can test if the VHDL works first time. The code itself is quite simple. Simple enough that I've trusted ChatGPT to vibe code it for me. For more complex stuff, I don't trust it, but this is the kind of simple stuff that GPTs are fairly good at now. If you'd like to play, here's the prompt I used:
ok, let's write a bit of VHDL that talks to these two pins and confirms that their values follow each other. Assume it's fed a 40.5MHz clock as clock_in, and it has the two vga pins as vga12 and vga15. The pulses of the lines should be fairly slow, let's say, around 100usec, and the module should verify that the other line follows within 10usec and holds for the remainder of the time. Then release the line, and make sure it floats back high. Then repeat with the other line. This should happen every 10msec, with the lines released in the meantime. The module should output a single line scart_cable_detected that = 1 if cable present, or 0 if the cable has not been detected for 2 consecutive probes.
And it worked! The cable detection works fine. So now I'm just back-porting it for R3 and R5 targets, and that should be that.
Note that this isn't in the official cores. There will be an announcement when it is. So don't go expecting to be able to make and try out a cable like this, without having to also put a custom bitstream on for now.
If you're worried my posts are uncharacteristically short, fear not. There is a monster post coming covering a bunch of the MEGAphone stuff.
No comments:
Post a Comment