ramapcsx2 / gbs-control

GNU General Public License v3.0
773 stars 110 forks source link

Clockgen uninitialized error, "sync skipped ofr wrong" #454

Closed kellenbrew closed 1 year ago

kellenbrew commented 1 year ago

Having a bit of a weird issue. For context I have only used the GBS with my Xbox over component, and it is displaying output.

I have tried two different Si5351 external clock generators. I have confirmed 3.3v is being supplied to the clockgen board, and continuity to SDA and SCL from clockgen board all the way to the D1 and D2 of the ESP8266. First wiring it as show in the wiki, and also directly to the D1 and D2 pins.

When I enable frametime lock I get the following output: sync skipped ofr wrong: 28.77 user command 5 at settings source 0, custom slot 65, status 1 FTL on Active FrameTime Lock enabled, adjusting external clock gen frequency Error: trying to tune external clock frequency while clock frequency uninitialized!

The last error repeats in the console. I still have a display, albeit with tearing.

Disabling the external clock and turning on FrameTime lock I get what I assume to be the normal output. Active FrameTime Lock enabled, disable if display unstable or stays blank!

No more tearing and over all a great picture. I am still just unsure as to why my clock gen isn't working. Is this a bug, or are there other things I should check?

Edit: After checking the output frequency, it is 30hz when scaling, however when I enable pass through it goes to 60 and the error stops.

nyanpasu64 commented 1 year ago

Is your debug pin not properly mounted? https://ramapcsx2.github.io/gbs-control/Wiki/Build-the-Hardware.html#connect-debugpin

kellenbrew commented 1 year ago

Double checked my debug pin for continuity to D6, all good there. Tried a Wii with component cables and XBox with official MS component cables and same issue. Changed TV's and without anything attached to the VGA output and same error.

Hooked up a laptop to the VGA input, and enabling the clockgen gives no errors and works fine.

nyanpasu64 commented 1 year ago

After checking the output frequency, it is 30hz when scaling, however when I enable pass through it goes to 60 and the error stops.

How do you check the output frequency? Is the output vsync frequency 30hz with or without external clock generator? Is the input vsync frequency 60 hz?

kellenbrew commented 1 year ago

Sorry I think my words got jumbled in my first message. Both the Xbox and Wii are softmodded, set to output 480p

Clock gen enabled my monitor reports this: 20230503_112304

Disabling the clock gen and rebooting, not changing the input in any way 20230503_112158

nyanpasu64 commented 1 year ago

Where did you order your clock generators from? Are they outputting half the requested frequency due to a lower frequency crystal?

Do you also get 29hz output on commit 34c816ac4dfb16a503e93145ef2166e4f6d0ad13 (before some clock gen changes)?

kellenbrew commented 1 year ago

I can try that version. Here is the clock gen I ordered https://www.amazon.com/dp/B07X7ZT7KJ?psc=1&ref=ppx_yo2ov_dt_b_product_details

Also for further testing, I connected the output via VGA to a different LCD monitor. Previously I was using a VGA to HDMI adapter.

Clock gen enabled: -Pass through H: 31khz V 60khz (different than H: 60 V: 60 observed on other monitor with HDMI adapter) -Any upscaling preset: sync skipped ofr wrong 28.77, monitor does not support input from GBS-C

Clock gen disabled:

nyanpasu64 commented 1 year ago

Looks like that board has a 25 MHz crystal like the code expects, so that's most likely not the problem.

If the old commit fails too, did you verify you connected the center pad of CLK0 to pin 40 on the Tvia chip with heatsink? https://ramapcsx2.github.io/gbs-control/Wiki/Si5351-Clock-Generator-install-notes.html

kellenbrew commented 1 year ago

Using that commit, looking at the serial console over USB I get no ext clockgen. Current master branch does detect it. I verified my wiring but I will reflow the connections just to make sure.

kellenbrew commented 1 year ago

reflowed connections. Confirmed SDA/SCL pin continuity from points on clock gen to points on ESP. Confirmed 3.3v on ground and side of the cap on clockgen. Same result of not detected with suggested commit. luwaXSeGR9KKsErwomeVZg

kellenbrew commented 1 year ago

Added some debug code, pass through with horizontal 31khz 60khz horizontal, the field time ticks was 5560856. So the ofr message math checks out with 160000000.00/5560856 . Not sure if the field time ticks are correct though.

nyanpasu64 commented 1 year ago

I'm starting to think you have a clone chip which doesn't communicate properly with the GBS-C (outputting the wrong frequency), and was unrecognized prior to #429. Can you check that the clock gen is detected (but malfunctions) on 6d7e89f5bfdd6cd4c422f57a8be9df99ac8bd5f4 (which adds support for clones) and not on the previous commit 4b20ae47ed6b428019fff6eaf924f9721d6d20ce?

As for fixing the functionality, I'm not sure how to approach that. You could try reverting 766efbf4896b842f464c841d04aa19c0f414f15f then 8f565da9383d2582de5b44370500f09ef37c02d1, and see if your chip outputs the right frequency or not. If that doesn't work, then perhaps the library at https://github.com/pavelmc/Si5351mcu doesn't function correctly with clone chips (it does some trickery to allow for smooth frequency sweeps), though I currently don't know what's wrong as I don't have a clone chip.

kellenbrew commented 1 year ago

I think you may be right. With the clock gen enabled the GBS board does stop responding after jumping around a few presets until I reboot. I ordered both from the same vendor, bad idea in hind sight. I have one coming directly from adafruit now.

If it is just the wrong frequency, is there any data I can collect jumping between the commits that may help support this clone for others in the future (short of an oscilloscope)?

Thanks for your help!

nyanpasu64 commented 1 year ago

@smgoldade is your clone clock gen fully functioning with correct output frequency? This issue's reporter appears to have a clone clock gen that's recognized with your patch, but it doesn't work properly with GBS-C's Si5351mcu library.

Interestingly, both the Amazon link (a clone chip?), and the listing I purchased (https://www.ebay.com/itm/384925804207, worked with unmodified code as of my purchase at 2022-11, no clue now), are labeled Si5351A rather than Si5351. Apparently it's just a version of the Si5351?

Bizarrely, the Amazon link has reviews both saying it works "Yes, buy for GBS Control" and doesn't work "dead on arrival" with GBS-C. Perhaps it's a clone unit, or unreliable manufacturing process, or different chips from different sources and some are defective?

Are there perhaps some registers that need to be initialized? Though I'm currently too busy to debug the library code and see what's missing. It's possible it could be made to work with changed initialization, changed Si5351mcu::setFreq code, or alternatively the clone chip is outright incompatible with smooth frequency sweeps which external clock gen and especially framesync depends on.

Documents:

kellenbrew commented 1 year ago

Just an update ofr wrong on all of them 6d7e89f - same error (detected) 4b20ae4 - same error (detected) 766efbf - same error (detected) 8f565da - same error (detected)

Possible the supplier could have changed vendors. Honestly the only reason I bought that specific one was because it was linked in the parts list under Voultar's gbs video.

smgoldade commented 1 year ago

My clone chip is still working. I use it for my NES/SNES. It's possible indeed there is even more of another variety that have even more registers misconfigured?

On Wed, May 3, 2023, 10:27 PM kellenbrew @.***> wrote:

Just an update ofr wrong on all of them 6d7e89f https://github.com/ramapcsx2/gbs-control/commit/6d7e89f5bfdd6cd4c422f57a8be9df99ac8bd5f4

Possible the supplier could have changed vendors. Honestly the only reason I bought that specific one was because it was linked in the parts list under Voultar's gbs video.

— Reply to this email directly, view it on GitHub https://github.com/ramapcsx2/gbs-control/issues/454#issuecomment-1534039716, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCPF46PWCXCZTS5LLDUDHDXEMOZZANCNFSM6AAAAAAXJ7LO3A . You are receiving this because you were mentioned.Message ID: @.***>

nyanpasu64 commented 1 year ago

I don't know what's going on. If it was a clone chip it would be "no ext clockgen" prior to 6d7e89f5bfdd6cd4c422f57a8be9df99ac8bd5f4 "Merge pull request #429 from smgoldade/robust-clockgen" on 11 Apr 2023. But you're getting detection with errors on all commits starting from 8f565da9383d2582de5b44370500f09ef37c02d1 "Update Si5351mcu to unmodified upstream 0.7.1 (#435)" 12 Mar 2023 which changes the clockgen usage but not detection code, but not on the previous commit? Can you retest on 34c816ac4dfb16a503e93145ef2166e4f6d0ad13 (before #435) and see if the chip is detected or not?

I don't think it's very likely the clock gen's underside is shorting against the TV5725's heatsink?

kellenbrew commented 1 year ago

34c816a clock gen is not detected. Short is unlikely as the board is sitting in a 3D printed wood PLA holder.

nyanpasu64 commented 1 year ago

So 8f565da9383d2582de5b44370500f09ef37c02d1 has "ext clockgen detected" followed by malfunction, but 34c816ac4dfb16a503e93145ef2166e4f6d0ad13 has "no ext clockgen"? I don't know why that would happen, as the value of rto->extClockGenDetected is set strictly before we call any methods on Si5351mcu Si. I don't think I can debug further without having the malfunctioning hardware on hand, and don't want to order and install a bad clock generator for testing.

kellenbrew commented 1 year ago

Replaced the clock gen with a genuine one from Adafruit. Now adjusts clock correctly with no errors.