Full Version : Zechovsky Improved Video Color Bar Gen (ASM)
avr >>GAME & VIDEO PROJECTS >>Zechovsky Improved Video Color Bar Gen (ASM)


Admin3- 04-19-2006
Improved Vasilis Video Bar Generator by Zechovsky


01.11.2003 by Zdenek Zechovsky

Improved original source code, added new features.

1. added vertical synchronization pulses

2. odd and even frames

3. picture is cut in two pieces, bottom bars is periodically moving left and right

4. The line 64us period is control by timer 0.

The only change in the hardware is the use of 510 ohm resistors, instead 500 ohm.

CODE


;******************************************************************************
;*
;*      PAL VERTICAL COLOUR BAR GENERATOR WITH VERTICAL SYNCHRONIZATION
;*
;*      Author:     Serasidis Vasilis
;*  Edited by: Zdenek Zechovsky (zexy@centrum.cz)  
;*      Writed:     30-10-2003 with AVR Studio 4.07
;*      Version:    2.0 beta
;*      Target:     AT90S2313-10 overclocked at 17.734475 MHz
;*      Web site:   http://www.serasidis.gr
;*      eMail:      info@serasidis.gr  
;*      
;*
;*      This PAL vertical colour bar genarator based on AT90s2313-10 MCU, overclo
;*      cked at 17.734475 MHz !!! because there is no AT90Sxxxx at this frequency
;*      Near to 17 MHz is AT90S1200-16 but i could`n find it on the market.
;*      For Analog to Digital converter i used R2R-ladders with 500 ohm and 1Kohm
;*      resistors connected to PortD.
;*
;*      Remember!!!
;*       - The timing of the instructions is very important.
;*       - Do not remove any 'Nop' intruction without replace it with someone
;*         else instruction.
;*
;*      Inform me if you improve this source code
;*      Good luck
;*
;******************************************************************************

.include"2313def.inc"
;-----------------------------------------------------------------
.def    zero        = r1
.def    temp        = r16
.def    delay       = r16
.def    burst       = r17
.def    Counter_L     =  r18
.def    Counter_H     = r19
.def    Event      = r20
.def    one_2      = r21
.def    temp_h        = r22
.def    up_color       = r22
.def    one         = r23
.def    down_color     = r24
.def    color_bar      = r25
.def    up             = r26
.def    Color_Chng_Reg    = r27
.def    Up_Down_Flag    = r28
.def    wreg2          = r29
;-----------------------------------------------------------------
.equ TIME     = 255-141 ;64us period
.equ WHITE_COLOR    = 31
.equ MEDIUM_COLOR   = 18
.equ COLOR_AMPLITUDE   = 8
.equ UP_COLOR_    = MEDIUM_COLOR + COLOR_AMPLITUDE
.equ DOWN_COLOR_    = MEDIUM_COLOR - COLOR_AMPLITUDE
.equ BURST_AMPLITUDE   = 2
.equ MEDIUM_BURST   = 8
.equ LOW_BURST    = MEDIUM_BURST + BURST_AMPLITUDE
.equ HIGH_BURST    = MEDIUM_BURST - BURST_AMPLITUDE
;-----boundary----------------------------------------------------
.equ VERT_1     = 3   ;vertical sync pulse
.equ VERT_EQU_PULSE_1  = 4   ;transition pulse ->vertical to equalizing
.equ EQU_PULSE_1    = 6   ;equalizing pulse
.equ NO_STRIPE_1    = 24   ;line without picture
.equ VERTICAL_OFFSET   = 160    
.equ    STRIPE_1_1        = VERTICAL_OFFSET;normal lines - odd field
.equ    STRIPE_1          = 311
.equ EQU_PULSE_2    = 313   ;equalizing pulse
.equ EQU_PULSE_VERT_2  = 314   ;transition pulse ->equalizing to vertical
.equ VERT_2     = 316   ;vertical sync pulse
.equ EQU_PULSE_3    = 318   ;equalizing pulse
.equ EQU_PULSE_3_NOTHING  = 319   ;equalizing pulse
.equ NO_STRIPE_2    = 336   ;line without picture
.equ    FRAME_2_1         = 313 + VERTICAL_OFFSET;normal lines - even field
.equ    FRAME_2          = 623
.equ    FRAME_EQU_PULSE_3  = 624   ;transition pulse
.equ    EQU_PULSE_4    = 626   ;equalizing pulse
;-----------------------------------------------------------------
.equ EVENT_VERT_1   = 1
.equ EVENT_VERT_EQU_PULSE_1 = 2
.equ EVENT_EQU_PULSE_1  = 3
.equ EVENT_NO_STRIPE_1  = 4
.equ    EVENT_STRIPE_1_1      = 5
.equ    EVENT_STRIPE_1        = 6
.equ EVENT_EQU_PULSE_2  = 7
.equ EVENT_EQU_PULSE_VERT_2 = 8
.equ EVENT_VERT_2   = 9
.equ EVENT_EQU_PULSE_3  = 10
.equ EVENT_EQU_PULSE_NOTHING = 11
.equ EVENT_NO_STRIPE_2  = 12
.equ    EVENT_FRAME_2_1       = 13
.equ    EVENT_FRAME_2        = 14
.equ    EVENT_FRAME_EQU_PULSE_3 = 15
.equ    EVENT_EQU_PULSE_4  = 16
;-----------------------------------------------------------------
.org $0000
 rjmp RESET ; Reset handle

.org $0005
 rjmp TIM1_OVF; Timer 0 overflow handle
;-----------------------------------------------------------------

;-----------------------------------------------------------------
; 64us timer
;-----------------------------------------------------------------

TIM1_OVF:
 ldi  temp,Time
 out  TCNT0,temp
 ldi  temp,1    
 add  Counter_L,temp  
 ldi  temp,0    
 adc  Counter_H,temp  
 cpi  Counter_L,Low(626)
 brne Inc_Line_Counter_1
 cpi  Counter_H,High(626)
 brne Inc_Line_Counter_2
 ldi  Counter_L,1
 ldi  Counter_H,0
 nop
 rjmp  Inc_Line_Counter_3
Inc_Line_Counter_1:
 nop
 nop
Inc_Line_Counter_2:
 nop
 nop
 nop
 nop
Inc_Line_Counter_3:  
    dec     burst  
    breq    Inc_Line_Counter  
    ldi     burst,1  
Inc_Line_Counter:

;----------line 1 and 2 ------------------------------------------
Line_1_2:
 cpi  Event,EVENT_VERT_1 ;1
 brne Line_3 ;3

    ldi     delay,14;42 cycles delay
Line_1_2_Wait:
 dec     delay
    brne    Line_1_2_Wait

 nop
 rcall Vert_pulse
 rcall Vert_pulse_fin
 mov  temp,Counter_L
 mov  temp_h,Counter_H
 subi temp,Low(VERT_1)
 sbci temp_h,High(VERT_1)
 brsh Line_3_Comp
 ldi  Event,EVENT_VERT_1
 reti
;----------line 3  -----------------------------------------------
Line_3:
 cpi  Event,EVENT_VERT_EQU_PULSE_1
 brne Line_4_5;3

    ldi     delay,13;39 cycles delay
Line_3_Wait:
 dec     delay
    brne    Line_3_Wait

 nop
 rcall Vert_pulse
 rcall Equaliz_pulse_fin
Line_3_Comp:
 mov  temp,Counter_L
 mov  temp_h,Counter_H
 subi temp,Low(VERT_EQU_PULSE_1)
 sbci temp_h,High(VERT_EQU_PULSE_1)
 brsh Line_4_5_Wait_Comp
 ldi  Event,EVENT_VERT_EQU_PULSE_1
 reti
;----------line 4 and 5 ------------------------------------------
Line_4_5:
 cpi  Event,EVENT_EQU_PULSE_1
 brne Line_6_23;3

    ldi     delay,12;36 cycles delay
Line_4_5_Wait:
 dec     delay
    brne    Line_4_5_Wait

 nop
 rcall Equaliz_pulse
 rcall Equaliz_pulse_fin
Line_4_5_Wait_Comp:
 mov  temp,Counter_L
 mov  temp_h,Counter_H
 subi temp,Low(EQU_PULSE_1)
 sbci temp_h,High(EQU_PULSE_1)
 brsh Line_6_23_Comp
 ldi  Event,EVENT_EQU_PULSE_1
 reti
;----------line 6 -> 23 ------------------------------------------
Line_6_23:
 cpi  Event,EVENT_NO_STRIPE_1
 brne Line_24_141;3

    ldi     delay,11;33 cycles delay
Line_6_23_Wait:
 dec     delay
    brne    Line_6_23_Wait

 ldi     one_2,MEDIUM_COLOR
 rcall start
 rcall Un_jitter
Line_6_23_Comp:
 mov  temp,Counter_L
 mov  temp_h,Counter_H
 subi temp,Low(NO_STRIPE_1)
 sbci temp_h,High(NO_STRIPE_1)
 brsh Line_24_141_Comp
 ldi  Event,EVENT_NO_STRIPE_1
 reti
;----------line 24 -> 141 -----------------------------------------
Line_24_141:
 cpi  Event,EVENT_STRIPE_1_1
 brne Line_142_310;3

    ldi     delay,10;30 cycles delay
Line_24_141_Wait:
 dec     delay
    brne    Line_24_141_Wait

 ldi     one_2,MEDIUM_COLOR
 rcall start
 rcall Color_bar_14
 rcall Un_jitter
Line_24_141_Comp:
 mov  temp,Counter_L
 mov  temp_h,Counter_H
 subi temp,Low(STRIPE_1_1)
 sbci temp_h,High(STRIPE_1_1)
 brsh Line_142_310_Comp
 ldi  Event,EVENT_STRIPE_1_1
 reti

;----------line 142 -> 310 ---------------------------------------
Line_142_310:
 cpi  Event,EVENT_STRIPE_1
 brne Line_311_312;3

    ldi     delay,9 ;27 cycles delay
Line_142_310_Wait:
 dec     delay
    brne    Line_142_310_Wait

 ldi     one_2,MEDIUM_COLOR
 rcall start
 rcall Color_bar_4
 rcall Un_jitter
Line_142_310_Comp:
 mov  temp,Counter_L
 mov  temp_h,Counter_H
 subi temp,Low(STRIPE_1)
 sbci temp_h,High(STRIPE_1)
 brsh Line_311_312_Comp
 ldi  Event,EVENT_STRIPE_1
 reti
;----------line 311 -> 312 ----------------------------------------
Line_311_312:
 cpi  Event,EVENT_EQU_PULSE_2
 brne Line_313;3

    ldi     delay,8 ;24 cycles delay
Line_311_312_Wait:
 dec     delay
    brne    Line_311_312_Wait

 nop
 rcall Equaliz_pulse
 rcall Equaliz_pulse_fin
Line_311_312_Comp:
 mov  temp,Counter_L
 mov  temp_h,Counter_H
 subi temp,Low(EQU_PULSE_2)
 sbci temp_h,High(EQU_PULSE_2)
 brsh Line_313_Comp
 ldi  Event,EVENT_EQU_PULSE_2
 reti
;----------line 313 -----------------------------------------------
Line_313:
 cpi  Event,EVENT_EQU_PULSE_VERT_2
 brne Line_314_315;3

    ldi     delay,7 ;21 cycles delay
Line_313_Wait:
 dec     delay
    brne    Line_313_Wait

 nop
 rcall Equaliz_pulse
 rcall Vert_pulse_fin
Line_313_Comp:
 mov  temp,Counter_L
 mov  temp_h,Counter_H
 subi temp,Low(EQU_PULSE_VERT_2)
 sbci temp_h,High(EQU_PULSE_VERT_2)
 brsh Line_314_315_Comp
 ldi  Event,EVENT_EQU_PULSE_VERT_2
 reti
;----------line 314 and 315 ---------------------------------------
Line_314_315:
 cpi  Event,EVENT_VERT_2
 brne Line_316_317;3

    ldi     delay,6 ;18 cycles delay
Line_314_315_Wait:
 dec     delay
    brne    Line_314_315_Wait
 nop
 rcall Vert_pulse
 rcall Vert_pulse_fin
Line_314_315_Comp:
 mov  temp,Counter_L
 mov  temp_h,Counter_H
 subi temp,Low(VERT_2)
 sbci temp_h,High(VERT_2)
 brsh Line_316_317_Comp
 ldi  Event,EVENT_VERT_2
 reti
;----------line 316 and 317 ---------------------------------------
Line_316_317:
 cpi  Event,EVENT_EQU_PULSE_3
 brne Line_318;3

    ldi     delay,5 ;15 cycles delay
Line_316_317_Wait:
 dec     delay
    brne    Line_316_317_Wait

 nop
 rcall Equaliz_pulse
 rcall Equaliz_pulse_fin
Line_316_317_Comp:
 mov  temp,Counter_L
 mov  temp_h,Counter_H
 subi temp,Low(EQU_PULSE_3)
 sbci temp_h,High(EQU_PULSE_3)
 brsh Line_318_Comp
 ldi  Event,EVENT_EQU_PULSE_3
 reti
;----------line 318 -----------------------------------------------
Line_318:
 cpi  Event,EVENT_EQU_PULSE_NOTHING
 brne Line_319_335;3

    ldi     delay,4 ;12 cycles delay
Line_318_Wait:
 dec     delay
    brne    Line_318_Wait
 nop
 rcall Equaliz_pulse
 nop
Line_318_Comp:
 mov  temp,Counter_L
 mov  temp_h,Counter_H
 subi temp,Low(EQU_PULSE_3_NOTHING)
 sbci temp_h,High(EQU_PULSE_3_NOTHING)
 brsh Line_319_335_Comp
 ldi  Event,EVENT_EQU_PULSE_NOTHING
 reti
;----------line 319 -> 335 ----------------------------------------
Line_319_335:
 cpi  Event,EVENT_NO_STRIPE_2
 brne Line_336_453;3

    ldi     delay,3 ;9 cycles delay
Line_319_335_Wait:
 dec     delay
    brne    Line_319_335_Wait

 ldi     one_2,MEDIUM_COLOR
 rcall start
 rcall Un_jitter
Line_319_335_Comp:
 mov  temp,Counter_L
 mov  temp_h,Counter_H
 subi temp,Low(NO_STRIPE_2)
 sbci temp_h,High(NO_STRIPE_2)
 brsh Line_336_453_Comp
 ldi  Event,EVENT_NO_STRIPE_2
 reti
;----------line 336 -> 453 ----------------------------------------
Line_336_453:
 cpi  Event,EVENT_FRAME_2_1
 brne Line_454_622;3

    ldi     delay,2 ;6 cycles delay
Line_336_453_Wait:
 dec     delay
    brne    Line_336_453_Wait

 ldi     one_2,MEDIUM_COLOR
 rcall start
 rcall Color_bar_14
 rcall Un_jitter
Line_336_453_Comp:
 mov  temp,Counter_L
 mov  temp_h,Counter_H
 subi temp,Low(FRAME_2_1)
 sbci temp_h,High(FRAME_2_1)
 brsh Line_454_622_Comp
 ldi  Event,EVENT_FRAME_2_1
 reti
;----------line 454 -> 622 ---------------------------------------
Line_454_622:
 cpi  Event,EVENT_FRAME_2
 brne Line_623;3

    ldi     delay,1 ;3 cycles delay
Line_454_622_Wait:
 dec     delay
    brne    Line_454_622_Wait

 ldi     one_2,MEDIUM_COLOR
 rcall start
 rcall Color_bar_4
 rcall Un_jitter
Line_454_622_Comp:
 mov  temp,Counter_L
 mov  temp_h,Counter_H
 subi temp,Low(FRAME_2)
 sbci temp_h,High(FRAME_2)
 brsh Line_623_Comp
 ldi  Event,EVENT_FRAME_2
 reti
;----------line 623 ----------------------------------------------
Line_623:
 cpi  Event,EVENT_FRAME_EQU_PULSE_3
 brne Line_624_625;9
 nop
 rcall  Only_Half_White
 rcall  Equaliz_pulse_fin
 rcall Color_Chng
Line_623_Comp:
 mov  temp,Counter_L
 mov  temp_h,Counter_H
 subi temp,Low(FRAME_EQU_PULSE_3)
 sbci temp_h,High(FRAME_EQU_PULSE_3)
 brsh Line_624_625_Comp
 ldi  Event,EVENT_FRAME_EQU_PULSE_3
 reti
;----------line 624 and 625 --------------------------------------
Line_624_625:   ;Event No.13;45 cykles
 rcall  Equaliz_pulse
 rcall  Equaliz_pulse_fin
Line_624_625_Comp:
;if(i_Counter<624){Event = 0;} else { Event = 13;}
 mov  temp,Counter_L
 mov  temp_h,Counter_H
 subi temp,Low(FRAME_EQU_PULSE_3)
 sbci temp_h,High(FRAME_EQU_PULSE_3)
 brsh  Line_624_625_Comp_1
 ldi  Event,EVENT_VERT_1
 reti
Line_624_625_Comp_1:
 nop
 ldi  Event,EVENT_EQU_PULSE_4
 reti
;-----------------------------------------------------------------
;-----------------------------------------------------------------
;Reset handle
;-----------------------------------------------------------------
RESET:
  ldi  temp,RAMEND
       out  SPL,temp     ;Init Stack Event
       ldi     temp, 0b01111111   ;set port D bits to outputs
       out     DDRD, temp
 ldi  temp,2   ;Timer/Counter 0 clocked at 8 CK
 out  TCCR0,temp
 ldi  temp,7   ;Timer/Counter 1 counter
 out  TCCR1B,temp
 ldi  temp,TIME
 out  TCNT0,temp
 ldi  temp,$82
 out  TIFR,temp
 ldi  temp,1 << TOIE0
 out  TIMSK,temp
 ldi  delay,2

       clr     zero         ;zero voltage level
       ldi     up,WHITE_COLOR    ;high voltage level (1.2V - white color)
       ldi     burst,1      ;
       ldi     one,8        ;low voltage level (0.2V - black color)
       ldi     one_2,MEDIUM_COLOR ;low voltage level (0.2V - black color)
       ldi     up_color,HIGH_BURST;High level for color carrier (1V)
       ldi     down_color,LOW_BURST;Low level for color carrier (0.38V)
       ldi     wreg2,12  
 ldi  Counter_L,0
 ldi  Counter_H,0
 ldi  Event,EVENT_VERT_1
 ldi  Color_Chng_Reg,12
 clr  Up_Down_Flag
 nop
 sei
loop:
 rjmp  loop
;-----------------------------------------------------------------    
;-----------------------------------------------------------------
;Synchro pulses
;-----------------------------------------------------------------
Un_jitter:
 cpi  burst,1
 breq Un_jitter_1 ;if burst = 1 then start_next  
Un_jitter_1:
 nop
 ret
;-----------------------------------------------------------------
;4 color bars + 1 white + 1 black
;-----------------------------------------------------------------    
start:
       ldi     one,8
       out     portd,one
       ldi     up_color,HIGH_BURST    ;set the up-voltage level for color burst      
       ldi     down_color,LOW_BURST   ;set the down-voltage level for color burst
       ldi     one,8            ;set the midle-voltage level for color burst
       ldi     delay,2    
       rcall   again
       out     portd,zero       ;start the horizontal synchronization
       rcall   delay2           ;delay 6.44uS (115 cycles. 1 cycle=0.056uS at 17,734475 MHz)    
       out     portd,one
       ldi     delay,2    
       rcall   again
 cpi  burst,0        
       breq    color_burst    
color_burst:
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
 ret

Color_bar_4:
 ldi     color_bar,4 ;Number of color bars (4 color bars + 1 white + 1 black)
       out     portd,up       ;Show the white color (1st color bar)
 mov     delay,Color_Chng_Reg
 add  delay ,Color_Chng_Reg

Color_bar_4_delay:  
 dec  delay
 nop
 brne Color_bar_4_delay
 nop
       ldi     up_color,UP_COLOR_    ;set the up-voltage level for color carrier
       ldi     down_color,DOWN_COLOR_  ;set the down-voltage level for color carrier
       mov     one,one_2         ;set the midle-voltage level for color carrier
       nop

color_carrier:  
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one

       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one

       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one

       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one      ;146 cycles
       out     portd,down_color

       dec     color_bar      ;check if is the 5th color-bar
       breq    start2         ;if yes, go to start again from the beginning
       rjmp    color_carrier  ;if not, go to show the next color-bar (151 cycles)

start2:
 out     portd,wreg2    ;Show the black color (6th color bar)
 nop
 ret


delay: ;delay 152 cycles (51,072uS/6 bars = 8,512uS = 152 cycles)              
       ldi     delay,59;55;48
again:  dec     delay
       brne    again
       ret

delay2:;delay  115 cycles              
       ldi     delay,24
again2: dec     delay
       brne    again2
       ret

;-----------------------------------------------------------------
;Synchro pulses
;-----------------------------------------------------------------

Equaliz_pulse:
       ldi     one,8
       out     portd,one
       ldi     delay,6    
       rcall   again
       out     portd,zero     ;start the horizontal synchronization
       ldi     delay,12    
       rcall   again    
       out     portd,one
       ldi     delay,161    
       rcall   again
 ret

Equaliz_pulse_fin:
       ldi     one,8
       out     portd,one
       ldi     delay,6    
       rcall   again          
       out     portd,zero     ;start the horizontal synchronization
       ldi     delay,12    
       rcall   again    
       out     portd,one
 ret

Vert_pulse:
       ldi     one,8
       out     portd,one
       ldi     delay,6    
       rcall   again          
       out     portd,zero     ;start the horizontal synchronization
       ldi     delay,155    
       rcall   again    
       out     portd,one
       ldi     delay,15    
       rcall   again  
 nop    
 ret

Vert_pulse_fin:
       ldi     one,8
       out     portd,one
       ldi     delay,6    
       rcall   again          
       out     portd,zero     ;start the horizontal synchronization
       ldi     delay,145    
       rcall   again    
 nop
       out     portd,one
 ret

Only_Half_White:
       ldi     one,8
       out     portd,one
       nop
       nop
       nop
       ldi     delay,4    
       rcall   again          ;17 cycles delay
       out     portd,zero     ;start the horizontal synchronization
       rcall   delay2         ;delay 6.44uS (115 cycles. 1 cycle=0.056uS at 17,734475 MHz)  
       out     portd,one
       nop
       nop
       ldi     delay,33    
       rcall   again       ;17 cycles delay
       out     portd,up       ;Show the white color (1st color bar)
       ldi     delay,118    
       rcall   again       ;cycles delay
 nop
       ret
;-----------------------------------------------------------------
;14 color bars + 1 white + 1 black
;-----------------------------------------------------------------
Color_bar_14:
 ldi     color_bar,14;Number of color bars (14 color bars + 1 white + 1 black)
       out     portd,Color_Chng_Reg
       rcall   delay

       ldi     up_color,UP_COLOR_    ;set the up-voltage level for color carrier
       ldi     down_color,DOWN_COLOR_  ;set the down-voltage level for color carrier
       mov     one,one_2         ;set the midle-voltage level for color carrier

color_carrier_exper:  
    out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
       out     portd,up_color
       out     portd,one
       out     portd,down_color
       out     portd,one
 nop
       dec     color_bar      ;check if is the 5th color-bar (blue)
       breq    start2_exper         ;if yes, go to start again from the beginning
       rjmp    color_carrier_exper  ;if not, go to show the next color-bar (151 cycles)
start2_exper:  
 out     portd,Color_Chng_Reg
 ret
;-----------------------------------------------------------------
;Change color brightness
;-----------------------------------------------------------------
Color_Chng:
 nop
 cpi  Up_Down_Flag,1
 breq Color_Chng_Down
 nop
Color_Chng_Up:
 nop
 cpi  burst,1
 brne  Color_Chng_Up_3
 cpi  Color_Chng_Reg,31
 breq  Color_Chng_Up_2
 inc  Color_Chng_Reg
 nop
 ret
Color_Chng_Up_2:
 ldi  Up_Down_Flag,1
 ret
Color_Chng_Up_3:
 nop
 nop
 nop  
 ret
Color_Chng_Down:
 nop
 cpi  burst,1
 brne  Color_Chng_Down_3
 cpi  Color_Chng_Reg,12
 breq  Color_Chng_Down_2
 dec  Color_Chng_Reg
 nop
 ret
Color_Chng_Down_2:
 ldi  Up_Down_Flag,0
 ret
Color_Chng_Down_3:
 nop
 nop
 nop
 ret
;-----------------------------------------------------------------
.db "Video PAL project ver.2.1 10.11.03 by Zdenek Zechovsky"
;-----------------------------------------------------------------



Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.