Unstable VGA output generated using STM32H7 (LTDC) and ADV7125

Thread Starter

piorkov

Joined Aug 17, 2021
13
Hello!

Some time ago I made some PCB for generating VGA signal using STM32H7 (LTDC) and ADV7125 converter:
Screenshot from 2021-08-17 09-24-48.pngScreenshot from 2021-08-17 09-25-05.png
I've managed to generate an image for three resolutions (all 60Hz) 640x480 60 800x600 1024x768, but it's not clean - the image is choppy and artifacts appear (although 800x600 looks the best).

CLK for ADV7125 as well as H_SYNC and V_SYNC are generated by LTDC on STM32H7. What I am able to configure is VGA timing and LTDC clock frequency and these values I am rather sure of.


What else can be the cause of unstable signal?
 

MrChips

Joined Oct 2, 2009
30,621
Welcome to AAC!

You need to be able to pinpoint the source of the problem. The first question is, is it a hor sync or vert sync problem or is it a data access problem? Here are some possible sources for unstable image.

1) H_SYNC and V_SYNC must be rock steady.
2) Data must be in sync with both H_SYNC and V_SYNC.
3) Data access must be stable.
4) Possible electrical noise and/or cabling problem.
 

Thread Starter

piorkov

Joined Aug 17, 2021
13
1) H_SYNC and V_SYNC must be rock steady.
2) Data must be in sync with both H_SYNC and V_SYNC.
3) Data access must be stable
H_SYNC, V_SYNC, Clock signal for ADV7125 and all color data are generated from STM32 (LTDC). I believe it is synchronized because that is the job of the LTDC to keep stable

4) Possible electrical noise and/or cabling problem.
This is where I have my doubts. I already realized that the signal lines from STM32 to ADV7125 as well as H_SYNC and V_SYNC have different lengths (from 15mm to even 80mm). Could this be a problem ?
 

MrChips

Joined Oct 2, 2009
30,621
Do you have access to an oscilloscope to show you the phase relationship between signals?

Can you post a video of the VGA screen so that we can see the effect you are describing?
 

Thread Starter

piorkov

Joined Aug 17, 2021
13
Do you have access to an oscilloscope to show you the phase relationship between signals?

Can you post a video of the VGA screen so that we can see the effect you are describing?
I am going to a university tomorrow where I will have access to an oscilloscope. Which waveforms are interesting ?
Only V_SYNC and H_SYNC ?

Video with VGA output:
 

MrChips

Joined Oct 2, 2009
30,621
In your video I see the picture of a dog sliding back and forth across the screen about once a second.

This is not noise. This indicates that your data access is not synchronized to H_SYNC.
 

Thread Starter

piorkov

Joined Aug 17, 2021
13
In your video I see the picture of a dog sliding back and forth across the screen about once a second.

This is not noise. This indicates that your data access is not synchronized to H_SYNC.

To the D-SUB connector, the H_SYNC and V_SYNC signal is generated by LTDC. The color data is sent to the DAC (ADV7125) and this is synchronized by the CLOCK signal.

Are you suggesting that there is a mismatch between H_SYNC, V_SYNC and CLOCK?

Did you notice that the all image is jigger? This effect is more visible in live
 

MrChips

Joined Oct 2, 2009
30,621
Image jitter is a subtle problem and more difficult to solve.

Is the image of the dog supposed to move across the screen?
If so, then start off with a static image. A grid of white horizontal and vertical lines is a good place to start.
 

Thread Starter

piorkov

Joined Aug 17, 2021
13
I prepared second video wit static image:

I looked through this thread what you sent me. I set fixed the timing for 640x480 like he had it set, but I didn't notice a change.
 

MrChips

Joined Oct 2, 2009
30,621
This is where you need to look at the signals on an oscilloscope.
Trigger the scope on H_SYNC and look at any video output. Again, it would be better to generate a single vertical white line one pixel wide close to the left side of the screen.
 

Thread Starter

piorkov

Joined Aug 17, 2021
13
This is where you need to look at the signals on an oscilloscope.
Trigger the scope on H_SYNC and look at any video output. Again, it would be better to generate a single vertical white line one pixel wide close to the left side of the screen.
I made measurements on an oscilloscope today, but what came out really surprised me. I'd like to point out that all measurements I made (except LTDC CLOCK) were taken directly from D-SUB (resolution 640x480)
In the test, I displayed, as you suggested, a single white line on a black background.

LTDC_CLOCK (~25.25MHz)
LTDC_CLK 640x480.png
V_SYNC (~59.88Hz)
V_sync 640x480.png
H_SYNC (31,64kHz)
H_sync 640x480.png
Red color: (31,64kHz)
Red Color 640x480.png
All together:
Full 640x480.png
Do I understand correctly that H_SYNC should have the same value as LTDC_CLOCK and V_SYNC should have the same value as H_SYNC now?

At first I thought I made a mistake in the measurements, but H_SYNC V_SYNC, and red color, I took directly from D-SUB

I did a quick check and I don't think I messed up the signal lines on the PCB. Should I see anything on the screen with such a signal?
 

MrChips

Joined Oct 2, 2009
30,621
You are on the wrong track. You need to be looking at sub microsecond time scale.

Let us look at some typical numbers.
Assuming horizontal scan frequency is 31.5kHz, this translates to a period of about 32μs. The active scan time is about 25μs. Hence for 640 horizontal pixels, one pixel width is about 40ns, or a pixel clock of 25MHz.

For 800 x 600, one pixel is about 25ns = 40MHz.

What you are looking for is the jitter or variation in the position of the first visible pixel. Acceptable jitter must be less than a fraction of one pixel width, i.e. about 10ns.

When the oscillosope is triggered by H_SYNC, the duration to the first pixel must be stable to within 10ns.

Reference: https://projectf.io/posts/video-timings-vga-720p-1080p/
 

Thread Starter

piorkov

Joined Aug 17, 2021
13
I'm sorry, I thought wrong that H_SYNC should have a frequency of ~25MHz (for 640x480) (approximately). Now I understood that my frequencies are correct.

So we are interested in comparing H_SYNC with RGB signal (for each signal ) ?
 

MrChips

Joined Oct 2, 2009
30,621
We are not so interested in the frequency but the phase relationship.
Bear in mind that what we are looking at on the oscilloscope is not going to solve your problem. In only confirms what you are already witnessing on the video display.

Start with triggering the oscilloscope on H_SYNC.
The 25MHz clock signal must be locked steady in sync with H_SYNC, with no discernible jitter (sub 10ns).

Next, you don't have to look at all R, G, B video signals. One will do.
The first occurrence of the video signal should be in sync with both H_SYNC and CLK. Any phase jitter is going to show up on the display. We are expecting to see the jitter here because it results in jitter on the screen. It is best to test with a vertical white line at the left-most side of the screen.

After you get to this point the difficult task is pin-pointing the source of the problem.
Possible sources are:
1) noise on H_SYNC, CLOCK and video signals
2) cable lenghts and improper shielding
3) improper power supply decoupling
 

Thread Starter

piorkov

Joined Aug 17, 2021
13
I have new videos and images from oscilloscope. Honestly, I don't know if I captured what was needed, but I recently used an oscilloscope for the first time since college and I'm not an expert at it ( I'm not an electrical engineer).

Yellow signal is LTDC_CLOCK,
Blue signal is H_SYNC and
Magenta signal is RED COLOR

The test image, as I mentioned, is the white, single-pixel, vertical line of the leftmost.

LTDC_CLK_H_SYNC_COLOR_2.pngLTDC_CLK_H_SYNC_COLOR_1.pngH_SYNC_COLOR.pngH_SYNC_COLOR.pngCOLOR_LTDC_CLK.pngLTDC_CLOCK_stop_H_sync_1_compare.pngLTDC_CLOCK_start_H_sync.pngLTDC_CLOCK_start_H_sync_3_compare.png
In addition, I have occasionally (but not always) seen interference like this
LTDC_CLOCK_start_H_sync_2_bad.png
VIdeos:

As for XTAL, I use HSE 8MHz for STM32

Possible sources are:
1) noise on H_SYNC, CLOCK and video signals
2) cable lenghts and improper shielding
3) improper power supply decoupling
1) I would like to know from what such interference arises - I'm mainly starting this thread because I want to know what mistakes I made
2) I am using a normal VGA cable (I have tested several)
3) As I mentioned I am not an electrical engineer, I suggested on the Waveshare board and I put a 100nF capacitor to each voltage input (for stm32h7 as well as for ADV7125)
 

MrChips

Joined Oct 2, 2009
30,621
Thanks for posting the photos and videos.
Just so that you understand, showing static photos is no particularly relevant. We want to see the amount of jitter which can only be seen over time, i.e. with a video.

Having said that,

1) I see no jitter in the videos you have posted,
2) Where did all that noise come from in the last two still photos? How did they suddenly appear and not seen in the other photos?

Note also that the oscilloscope has a bandwidth of 60MHz stated while the clock is 25MHz. That is why you are seeing triangular waves instead of square waves for the clock, i.e. the scope does not have high enough bandwidth.

1629487600407.png

1629487640109.png
 

Thread Starter

piorkov

Joined Aug 17, 2021
13
2) Where did all that noise come from in the last two still photos? How did they suddenly appear and not seen in the other photos?
I have seen such interference (smaller and larger) on an oscilloscope from time to time. It was difficult for me to catch it before, because the software of this oscilloscope is very poor and catches a short frame there - I was lucky to make this screen

Note that in the video below, at the 6th second and beyond, you can also see such momentary interference:
I had previously thought this was some sort of momentary measurement error - I have no experience with an oscilloscope

Note also that the oscilloscope has a bandwidth of 60MHz stated while the clock is 25MHz. That is why you are seeing triangular waves instead of square waves for the clock, i.e. the scope does not have high enough bandwidth.
Doesn't the sampling rate matter? This oscilloscope has 2GS/s
By the way, 60Mhz is more than twice as much as 25MHz, It's still not enough ?

I have an analog (two channel) 120MHz oscilloscope, But it's hard for me to show 2 signals at one time.
 
Top