Cornell University ECE4760
NTSC video
PIC32MX250F128B
NTSC video generation on PIC32
NTSC video is an old standard, but is still used in North America for closed circuit TV. It is fairly simple to generate a black/white NTSC signal. Also, the frame buffer for a 1-bit, 256x200 pixel image is only 1600 words (6400 bytes) of RAM. Chapter 13 of Programming 32-bit Microcontrollers in C: Exploring the PIC32 by Lucio Di Jasio was very useful. TV signal gneeration is an example of a hard-real-time system. A pulse delay of only one machine cycle is visually detectable, so some care is necessary in the code.
The code examples below have several parts:
void video_pt(int x, int y, char c) or define video_pt_m(x,y,c) |
Draw a point into frame buffer memory. Specify the position x,y (y increasing downward) and the color with black=0, white=1, and xor=2. Limits of x are 0 to 255. Limits on y are 0 to 199. The macro version is faster. |
char video_state(int x, int y) |
Read back a point from video memory. A white point will read back as a nonzero value (actually the bit within the video memory byte which is being checked). |
void video_line(int x1, int y1, int x2, int y2,
char c) |
Draw a line into video memory. The line extends from (x1,y1) to (x2,y2) with a color as above. Uses a Breshenham algorithm for speed. |
void video_putchar(int x, int y, int c) |
Draw a 5x7 character at (x,y) with ascii character code c. The coordinates represent the upper-left corner of the character. You must download the character header file to use this function. |
void video_string(int x, int y, char *str) |
Draw a 5x7 string starting at (x,y). The coordinates represent the upper-left corner of the first character. You can draw about 16 5x7 characters in one frame time. |
|amplitude|=max(|Re|,|Im|)+0.4*min(|Re|,|Im|)
. This approximation is accurate within about 4%.References:
PPSInput(2, U2RX, RPB11);
//Assign U2RX to pin RPB11 -- Physical pin 22 on 28 PDIP PPSOutput(4, RPB10, U2TX);
//Assign U2TX to pin RPB10 -- Physical pin 21 on 28 PDIP Documentation
from the left column. Copyright Cornell University July 13, 2015