NTSC Video Example

Designing hardware and software that uses the VS23S0X0 family of ICs as a 8-bit or SPI SRAM memory or as a Video Controller for generating Composite Video (TV-Out) or driving other kinds of displays.
IsoPasi
VLSI Staff
Posts: 15
Joined: Tue 2015-11-24 12:31

NTSC Video Example

Post by IsoPasi » Mon 2016-02-01 12:49

Dear VSDSP Forum Users,

Here is a SW example for setting up the VS23S010 video display controller in
NTSC video mode. This example is pretty similar to PAL example.
Again a picture containing 256 boxes of different colors is generated.

The hardware setup for generating the video picture is the same as in PAL
example. The only difference is that 3.579545 MHz crystal is used for VS23S010.

The program is quite generic so it can be used as a guide for writing SW also
for other micro-controllers with SPI interface.

The main program is in main.c. It just calls the SpiRamVideoInit() function.

ntsc.c has the main functions and parameter setting for the video display
controller. SpiRamVideoInit() is the function that sets up the video display
controller and generates picture. This is also very similar to pal.c that was
used to generate PAL video.

The ntsc.h header file has all the definitions used by video display
controller. The #defines are the same as in pal.h. The define values are the
main differences when compared to PAL example. The crystal frequency, line
duration and line amounts are changed according to NTSC spec. Also the timing
parameters and levels of the video line are set according to NTSC.

The following zip package contains the C source files for the example.
ntsc1-2016-02-01-11-09-8BitProgImage.zip
(28.25 KiB) Downloaded 124 times
Here is a picture of TV screen after the program is run. Video is
progressive and 8 bits is used for a pixel in picture area. The picture area
(318x215 pixels) is framed by blueish lines. Other parts of image are
generated by prototype lines.
ntsc1.JPG
ntsc1.JPG (105.91 KiB) Viewed 2471 times
The microcode program for picture area is B22 A22 Y44 N10:
- Pick 2 bits B (U), shift 2 bits B22
- Pick 2 bits A (V), shift 2 bits A22
- Pick 4 bits Y, shift 4 bits Y44
- and do nothing N10
- Total 8 bits is used for a picture area pixel

The color burst level (U and V value) is set to 0xb5 in the proto line. In the
picture can be seen the color palette of this setup. PLL_CLKS_PER_PIXEL is set
to 4.

Here is the VS1005 std out to terminal when program is run:

VS23S010 INIT
Manufacturer ID: 2b03
ID ok, 4 VS23 ICs in system
Linelen: 1810 PLL clks
Picture line area is 318 x 215
Upper left corner is point (0,0) and lower right corner (317,214)
Memory space available for picture bytes 128466
Free bytes 58376
Picture line 327 bytes
Picture length, 159 color cycles
Picture pixel bits 8
Start pixel 2d
End pixel cc
Index start address 718
Picture line 0 address a2e
b8 <= 0eh
01 <= 40h
28 <= 002dh
29 <= 00cch
2b <= 3000h
2a <= 0712h
PROG:c09c0a4ah
2c <= 01c6h
2d <= 8d06h
Current line: 802c

There can be seen some parameter differences when compared to std out
generated by PAL video example:
- Linelen is 1810 PLL clks in NTSC, 2260 in PAL (NTSC line is slightly shorter
in duration and NTSC crystal frequency is lower)
- Y filter is not enabled.

Following are more example images using different parameters for BURST LEVEL
and different microcodes of picture area.

Please feel free to ask any questions regarding this example or VS23S010 usage.

Best regards,
Pasi
Pasi Isotalus, VLSI Solution Oy

IsoPasi
VLSI Staff
Posts: 15
Joined: Tue 2015-11-24 12:31

Re: NTSC Video Example

Post by IsoPasi » Mon 2016-02-01 13:17

Hi,

In the following images are shown NTSC video using smaller picture area. In both examples top right part of image that was in previous message is shown. The picture area is 160x120 pixels. The change to previous SW is that #define XPIXELS is changed to 160 and #define YPIXELS is changed to 120. XPIXELS is used to calculate Picture End register value. YPIXELS is used to define which of the lines in the picture are proto lines and which are picture lines. Each pixel is 4 color subcarrier cycles as in the image of the previous message (program length is 0x3).
ntsc2.JPG
ntsc2.JPG (73.27 KiB) Viewed 2467 times
The print outs of the program are as follows:
VS23S010 INIT
Manufacturer ID: 2b03
ID ok, 4 VS23 ICs in system
Linelen: 1810 PLL clks
Picture line area is 160 x 120
Upper left corner is point (0,0) and lower right corner (159,119)
Memory space available for picture bytes 128466
Free bytes 108306
Picture line 169 bytes
Picture length, 80 color cycles
Picture pixel bits 8
Start pixel 2d
End pixel 7d
Index start address 718
Picture line 0 address a2e
b8 <= 0eh
01 <= 40h
28 <= 002dh
29 <= 007dh
2b <= 3000h
2a <= 0712h
PROG:c09c0a4ah
2c <= 01c6h
2d <= 8d06h
Current line: 80c5

The value of Picture End register is changed (29 is 007dh instead of 00cch in the previous message).

In the following image the PLLCLKS_PER_PIXEL define is changed from 4 to 8 and so one pixel is 8 PLL clock cycles long. The PLLCLKS_PER_PIXEL define affects the value that is written to Video Display Controller Control2 register (PLEN bits). The picture area becomes then respectively wider.
ntsc3.JPG
ntsc3.JPG (82.64 KiB) Viewed 2467 times
Lastly the first image is stretched also in the Y-direction. This is done by setting the same line index value for two successive image lines and then the same line is displayed twice before a new line is used. In the program code the YPIXELS define was changed to 240. Also the loop where line indexes are set was edited.

Code: Select all

	// 13. Set pic line indexes to point to protoline 0 and their individual picture line.
	j=0;
	for (i=0; i<ENDLINE-STARTLINE; i++) {
		//SetPicIndex(i+STARTLINE, PICLINE_BYTE_ADDRESS(i),0);
		SetPicIndex(i+STARTLINE, PICLINE_BYTE_ADDRESS(j),0);
		if (i%2==1) j++;
		// All lines use picture line 0
		//SetPicIndex(i+STARTLINE, PICLINE_BYTE_ADDRESS(0),0);
#ifdef INTERLACE
		// In interlaced case in both fields the same area is picture box area.
		SetPicIndex(i+STARTLINE+FIELD1START, PICLINE_BYTE_ADDRESS(i),0);
#endif
	}
	
The resolution of image is still 160x120, but the size is twice of the first shown in this message. The image does not quite fit now on the monitor as can be seen.
ntsc7.JPG
ntsc7.JPG (90.65 KiB) Viewed 2464 times
Best regards,
Pasi
Pasi Isotalus, VLSI Solution Oy

IsoPasi
VLSI Staff
Posts: 15
Joined: Tue 2015-11-24 12:31

Re: NTSC Video Example

Post by IsoPasi » Mon 2016-02-01 14:48

Hello,

Following are images where different NTSC burst values are tried.

In the original NTSC example image color burst value is b5h (4-bits of U and V) and the blank value is 37h (8 bits of Y) for protoline data.

In the following image the color burst value and thus its amplitude are decremented to d3h and the colors have become richer. N in the image means that the NTSC burst value is changed to displayed value. The burst value is changed by writing over the area of the memory where the picture area protoline color burst resides like was done in the PAL examples too.
ntsc4.JPG
ntsc4.JPG (109.2 KiB) Viewed 2464 times
Next the values of U and V are switched vice versa and color palette changes as follows.
ntsc5.JPG
ntsc5.JPG (108.14 KiB) Viewed 2464 times
The smallest non-zero burst value gives a following video image. Zero burst value would generate a black and white image.
ntsc6.JPG
ntsc6.JPG (109.94 KiB) Viewed 2464 times
If there arises any questions considering these examples please don't hesitate to ask.

Best regards,
Pasi
Pasi Isotalus, VLSI Solution Oy

IsoPasi
VLSI Staff
Posts: 15
Joined: Tue 2015-11-24 12:31

Re: NTSC Video Example

Post by IsoPasi » Mon 2016-02-01 17:13

In this example are shown how the colors of the image can be changed using different microcode programs. In the previous NTSC video images the microcode was B22 A22 Y44 N10:
- Pick two bits of B, shift two B22
- Pick two bits of A, shift two A22
- Pick four bits of Y, shift four Y44
- Do nothing N10

In the next image A is taken first and then B, otherwise the microcode is the same. The microcode is shown at the bottom of the image.
ntsc8.JPG
ntsc8.JPG (111.69 KiB) Viewed 2459 times
In the following example there are not strong red colors. However, there are some nice yellow, green and purple shades.
ntsc9.JPG
ntsc9.JPG (114.51 KiB) Viewed 2459 times
To sum up, with different microcodes and also with different color burst values it is possible to generate quite different color palettes when using a fixed word length for a pixel, eight bits in these examples.

Best regards,
Pasi
Pasi Isotalus, VLSI Solution Oy

JimDrew
User
Posts: 13
Joined: Wed 2016-01-20 19:33

Re: NTSC Video Example

Post by JimDrew » Tue 2016-02-02 3:15

Thanks for the examples.

Is it possible to display 320x240 or 160x120 on a NTSC display without the bottom being cut off?

With a 160x120, you should be able to have more colors, correct? How many colors? If you can get 65536 colors, can you tell me the microcode necessary for RGB16 (5:6:5)?

Are you going to make an app note with a real world example of the circuitry. There are a lot of questions that are not answered in the datasheet:

Can you directly feed the VXTALIN with the color signal (using a microcontroller line or oscillator) instead of using an external crystal?
What are the extra "VideoOut" pins for?
What is the actual max speed (in MHz or bytes per second) of the SRAM parallel transfer while the video controller is enabled?
The simple reference schematic shows a 75 ohm resistor and a capacitor connected to the VideoOut#0 line - what value is the capacitor?

I think there is a language translation issue with your description of the microcode. There is no definition of what is being shifted and which direction the shift is occurring. Can you explain this a bit better?

IsoPasi
VLSI Staff
Posts: 15
Joined: Tue 2015-11-24 12:31

Re: NTSC Video Example

Post by IsoPasi » Tue 2016-02-02 11:53

Have you read the Chapter 6.2 of the datasheet that covers the operation of Video Display Controller? There are covered the main topics of the block and it should be quite helpful.
Is it possible to display 320x240 or 160x120 on a NTSC display without the bottom being cut off?
NTSC has 480 visible lines, so 320x240 or 160x120 would completely fill the picture, the example picture doesn't quite start from the top. Another option would be to use interlaced mode and show all lines 3 times, which might look better for 160x120...

The size of the picture on monitor depends on:
- X-direction, how many PLL clock cycles are used per pixel (and also for one microcode). This can be from 2 to 16.
- Y-direction, usually one pixel is one line or integer multiple of line. In interlaced pictures one pixel is 1.5 lines. Other values need some kind of data interpolation before displaying them.
With a 160x120, you should be able to have more colors, correct? How many colors? If you can get 65536 colors, can you tell me the microcode necessary for RGB16 (5:6:5)?
VS23S010 uses YUV colors, because that's how video signals are generated... We use C macros to convert from RGB565 to YUV844, which is a nice representation for 16-bit colors for the TV. Here's an example YUV844 hicolor TV picture (318 x 200 pixels) displayed by VS23S010:
race.JPG
race.JPG (130.15 KiB) Viewed 2443 times
On page 37 of the datasheet is a table of possible color /resolution combinations, which is however missing the 160x120. 160x120 is 19200 pixels. The sensible maximum data per one pixel is 20 bits. 19200*20 is 384000 bits or 48000 bytes and it fits easily in the memory.

65536 colors is achieved using 16 bits. For example a microcode:
- Pick 4 bits A(Y), shift by 4
- Pick 4 bits B(U), shift by 4
- Pick 8 bits Y, shift by 4
- Pick nothing, shift by 4

The microcode is in YUV format, so you need to convert RGB565 to YUV first. In the ntsc.h header are conversion calls for this

Code: Select all

/// 8-bit RGB to 8-bit YUV444 conversion
#define YRGB(r,g,b) ((76*r+150*g+29*b)>>8)
#define VRGB(r,g,b) ((-37*r-73*g+111*b)>>8)
#define URGB(r,g,b) ((157*r-131*g-25*b)>>8)
Those defines give byte wide results that you can shift to 5 or 6 bits.
Are you going to make an app note with a real world example of the circuitry. There are a lot of questions that are not answered in the datasheet:
Updated version of datasheet is under work. We could also publish the VS23S010 Display Daughterboard for VS1005 Developer Board schematics, although that is not the simplest possible implementation.
Can you directly feed the VXTALIN with the color signal (using a microcontroller line or oscillator) instead of using an external crystal?
The clock can be fed directly to VXTALIN. For NTSC the external clock should be exactly NTSC color clock (3.579545) or 8x that.
What are the extra "VideoOut" pins for?
There's a possibility that VLSI would make a multi-die version VS23S0X0 which would have more than one analog output, but no such IC exists as of yet. Currently those pins are reserved and not connected in any chip version.
What is the actual max speed (in MHz or bytes per second) of the SRAM parallel transfer while the video controller is enabled?
We have measured at our lab setup 11MHz, which is by no means the upper limit. The hardware is optimized for writing data to the IC, so writing speed is higher than the reading speed when video is enabled. The speed depends on the board design, used VCC level and temperature. In our tests the bus has been fast enough for watching videos on the TV.
The simple reference schematic shows a 75 ohm resistor and a capacitor connected to the VideoOut#0 line - what value is the capacitor?
The series capacitor is not needed and should not be used for DC connection to the TV. If AC connection is required, the capacitor should be sufficiently large (hundreds of microfarades), but DC connection is recommended.
I think there is a language translation issue with your description of the microcode. There is no definition of what is being shifted and which direction the shift is occurring. Can you explain this a bit better?
To understand the operation, you need to read the datasheet thoroughly. The bits are picked from most significant bits in an internal shift register and shifted left. Then more data is loaded from the memory to the LSB end of the shift register from the SRAM memory as needed.

Best regards,
Pasi
Pasi Isotalus, VLSI Solution Oy

JimDrew
User
Posts: 13
Joined: Wed 2016-01-20 19:33

Re: NTSC Video Example

Post by JimDrew » Tue 2016-02-02 21:12

OK, that answers a few questions not in the datasheet.

You stated:
- X-direction, how many PLL clock cycles are used per pixel (and also for one microcode). This can be from 2 to 16.
Since this is a fixed clock device (NTSC or PAL), why not state the actual number of nanoseconds per pixel? The PLL is a bit confusing the way you have it worded in the datasheet. Apparently you need either a NTSC or PAL frequency input AND enable the PLL, or 8x the NTSC or PAL frequency. You also apparently need to set the PLL on or off. The device works at the standard NTSC/PAL frequencies even with the PLL has not yet been enabled? Is that all correct?

We only program in assembly code, so C macros are not going to help. We have RGB 5:6:5 data or RGB 3:3:2 data. I guess that data must be converted to this YUV844 format, so I will look into the best way to do that (likely a big lookup table). We are using the parallel port (via DMA) for sending data to the SRAM (no reading is ever required). What happens to the state of the parallel port lines while the SPI mode is enabled? Do these lines go Z state? We have wired the microcontroller hardware SPI to the same parallel port lines that it needs, and enable/disable those lines with the state of the XCS or XCSPAR - so no bit-banging is required.

JimDrew
User
Posts: 13
Joined: Wed 2016-01-20 19:33

Re: NTSC Video Example

Post by JimDrew » Tue 2016-02-02 23:28

We could also publish the VS23S010 Display Daughterboard for VS1005 Developer Board schematics, although that is not the simplest possible implementation.
Yes, please post this schematic. Also, what voltage/current requirement is there on VXTALIN if driving this line from an external source (like a microcontroller pin, programmable oscillator, etc.)? What tolerance is required for the crystal (+/-50ppm or better)?

Your datasheet states that either XRD or XWR can be used for both reading or writing. Is that correct? If either can be used, why have two lines that do the same thing?

User avatar
Panu
VLSI Staff
Posts: 2533
Joined: Tue 2010-06-22 13:43

Re: NTSC Video Example

Post by Panu » Wed 2016-02-03 1:13

Yes, please post this schematic. Also, what voltage/current requirement is there on VXTALIN if driving this line from an external source (like a microcontroller pin, programmable oscillator, etc.)? What tolerance is required for the crystal (+/-50ppm or better)?
Good questions, I'd imagine that the levels would be IOVDD levels, but I'll have to get back to you on that. Crystal performance is what the TV requires to detect the correct color subcarrier frequency. 50ppm is certainly good enough.
Your datasheet states that either XRD or XWR can be used for both reading or writing. Is that correct? If either can be used, why have two lines that do the same thing?
Because many microcontrollers have 8080-style or Nand Flash controller buses, which use separate RD and WR signals and we designed the VS23S010 so that it can be interfaced using that kind of bus.

-Panu
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

User avatar
Panu
VLSI Staff
Posts: 2533
Joined: Tue 2010-06-22 13:43

Re: NTSC Video Example

Post by Panu » Wed 2016-02-03 1:35

The PLL is a bit confusing the way you have it worded in the datasheet.
Sorry for any confusement. The datasheet is challenging to write for this IC. You could see the datasheet as a legal document that states VLSI performance claims for pieces of hardware and we are instructed to keep the datasheets as concise as possible, and write application information in separate application notes or User's Guides. We haven't yet had the chance to write those and we're approaching the subject with these messages. They will probably be compiled into a User's Guide later on.
Since this is a fixed clock device (NTSC or PAL), why not state the actual number of nanoseconds per pixel?
Well, yes and no. If you use the IC for NTSC or PAL that is true. But you can also drive any number of industrial displays or monitors with different timings and different crystal values and using fixed frequencies might seem limiting for those uses. For example, I used a 10 MHz crystal for the VGA demo. In this point we just try to describe the operation of the hardware in the datasheet.
The device works at the standard NTSC/PAL frequencies even with the PLL has not yet been enabled? Is that all correct?
The previous version of VS23S010 (VS23S010A) required an external 28.636 MHz crystal oscillator, which (and especially its PAL counterpart) proved to be a very rare component. So we added the 8x PLL and internal oscillator circuitry so that you can generate the required clock with a cheap and common crystal and not having to source the special oscillator. If you have the 28.6 MHz oscillator, don't enable PLL. If you have the 3.58 MHz crystal, enable the PLL.

Thank you for your excellent questions! They steer us in the right direction when we are considering what kind of User's Guides or application notes we need to write for this IC.

-Panu
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

Post Reply