-
Notifications
You must be signed in to change notification settings - Fork 109
Description
I am trying to use the scanvideo_dpi code to drive a small LCD. The LCD needs a pixel clock, VSync and HSync. I am having trouble getting the timing to work in several areas. I am new to PIO programming and I'm having trouble following all the code but basically I have done the following. I started with the TestPattern code in Pico-Playground but I have created my own video timing:
#define vga_mode psp_mode_480x272_60
const scanvideo_timing_t psp_timing_480x272_60_default =
{
.clock_freq = 8000000,
.h_active = 480,
.v_active = 272,
.h_front_porch = 8,
.h_pulse = 4,
.h_total = 531,
.h_sync_polarity = 0,
.v_front_porch = 8,
.v_pulse = 4,
.v_total = 292,
.v_sync_polarity = 0,
.enable_clock = 1,
.clock_polarity = 0,
.enable_den = 0
};
const scanvideo_mode_t psp_mode_480x272_60 =
{
.default_timing = &psp_timing_480x272_60_default,
.pio_program = &video_24mhz_composable,
.width = 480,
.height = 272,
.xscale = 1,
.yscale = 1,
};
I update the system clock to ensure it is a power of 2 times the pixel clock:
set_sys_clock_khz(128000,true);
finally I added the following to CMakeLists.txt
target_compile_definitions(test_pattern
PRIVATE
PICO_SCANVIDEO_ENABLE_CLOCK_PIN=1
)
The code runs and I have a logic analyzer that shows basically good data on the R/G/B pins
but I do not think the sync pulses match what I would expect:
- I cannot get a clock on either GP18 or GP19. The code looks like it should be on Pin 18 but also a bit of code that looks wrong (see below)
- The R0 pin appears to "glitch" after every pixel so instead of being a steady low for 15 pixels and steady high for 15 pixels it it has a short pulse at the end of each pixel going the opposite of whatever it should be:
- VSync also does not match what I would expect (but maybe it would work with analog VGA?
the code that I think might be an issue is in scanvideo.c:
uint pin_mask = 3u << PICO_SCANVIDEO_SYNC_PIN_BASE;
bi_decl_if_func_used(bi_2pins_with_names(PICO_SCANVIDEO_SYNC_PIN_BASE, "HSync",
PICO_SCANVIDEO_SYNC_PIN_BASE + 1, "VSync"));
#if PICO_SCANVIDEO_ENABLE_DEN_PIN
bi_decl_if_func_used(bi_1pin_with_name(PICO_SCANVIDEO_SYNC_PIN_BASE + 2, "Display Enable"));
pin_mask |= 4u << PICO_SCANVIDEO_SYNC_PIN_BASE;
#endif
#if PICO_SCANVIDEO_ENABLE_CLOCK_PIN
bi_decl_if_func_used(bi_1pin_with_name(PICO_SCANVIDEO_SYNC_PIN_BASE + 3, "Pixel Clock"));
pin_mask |= 8u << PICO_SCANVIDEO_SYNC_PIN_BASE;
#endif
I think the pin mask for the pixel clock should be:
pin_mask |= 4u << PICO_SCANVIDEO_SYNC_PIN_BASE;
if the out pin is 1 past the VSync but this may be my lack of knowledge on the details of the PIO Side set commands. I have tried making this change but it did not fix my issue with the clock.
Has anyone used this code to drive an LCD directly from the parallel output pins?
