A little HELP!!


Closed Thread
Results 1 to 40 of 77

Thread: A little HELP!!

Hybrid View

  1. #1
    Join Date
    Mar 2011
    Location
    Los Angeles, California
    Posts
    322

    Question A little HELP!!

    Okay so I am still struggling with this code. In television there are three forms of video standards for different parts of the world. There is NTSC, which is the American standard, PAL a European standard and SECAM another standard. Most of the world uses either the NTSC or PAL standard. The basic difference is weather the power is 50 cycles per second (PAL) or 60 cycles per second (NTSC) as this is used for the timing of the television electronics. Since this STV5730 seems to display an out of sync picture most of the time my guess is that the code has the PAL standard embedded somewhere in it. I can see a display for a short time with the characters in the PIC code then it goes back to a scrambled sync signal. I have never seem an "overlay" display where the characters are superimposed over the incoming picture. I am hoping someone with much, much more knowledge than I have can tell me what to change in the code? Thanks in advance.

    Code:
    '****************************************************************
    '*  Name    : English OSD                                       *
    '*  Author  : Ed Cannady                                        *
    '*  Notice  : Copyright (c) 2017 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 6/4/2017                                          *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    'OSDCSX.bas version 2.0
    'Incruser with STV5730A and PIC 18F2520 - 20 MHz
    'Source for PICBasic PRO 
    'Risto Kõiva 2001, F1FCO & F6CSX, March 2003
    'Turns on F1UBZ insert (part RS232 / MAX232 useless) or demo board STV5730 
    'Page mode, color bars
    'Cyclic change of background color
    '23cm or 70cm band display according to pin 18 status (RA1)
    
    
    '** HARDWARE DEFINITION **
    Define OSC 20
    
    	CMCON = 7 'put the 18F2520 in digital mode on PORT A
        ADCON1 = $0F
    
    	Clk VAR PORTC.4
    	Sda VAR PORTC.5
    	Csn VAR PORTC.3
    	Mute VAR PORTB.7 '0 if sync valid, 1 if no sync
        mode VAR PORTB.3 'pin # 9, 0 = Page mode, 1 = Mixed mode
    	On_off VAR PORTA.2 'Stop the incruser: pin # 1, 0 = off, 1 = on	
    	Band VAR PORTA.1 'incrustation 23 cm if 0 or 70 cm if 1
    	
    INPUT Mode
    INPUT Mute
    INPUT On_off
    INPUT Band
    
    OUTPUT Clk
    OUTPUT Sda
    OUTPUT Csn
    
    '** DEFINITION OF VARIABLES **
    	
    	ICount VAR BYTE
    	Bit_Counter VAR BYTE
    	WData VAR WORD
    	C VAR WORD
    	B1 VAR BYTE
    	B2 VAR BIT
    	B3 VAR BIT
    	B4 VAR BIT
    	
    	W1 VAR BYTE
    	W2 VAR BYTE
    	
    '** START OF PROGRAM **
    	
    	GOSUB Init 'initialization
    	GOSUB Mode_mixed 'Mixed mode by default
    	GOSUB Display_mixed
    	b1 = 1
    	b2 = 1
    	b3 = 1	
    	c  = 0
    Looped:	
    
    	B1 = On_off
    	IF b1 = 0 THEN Incrust_off 'monitors the On_off button
    	B4 = Band
    	IF b4 = 0 THEN
    		W1= $02
    		W2= $03
    		ELSE
    		W1= $07
    		W2= $00
    	ENDIF
    		
    	B3 = MODE 'reads MODE
        
    	IF b3 = b2 THEN Jump 'does not change anything
    		
    	IF b3 = 1 THEN 'If MODE = 1: Mixed Mode, Picture Overlay
    		c = 0
    		GOSUB Mode_mixed
    		GOSUB Display_mixed 		
    		B2 = b3
    		ELSE 
    		GOSUB Mode_page 'Mode Page: Mire		
    		FOR c = 0 TO 6
    		WData = $00CD: GOSUB Send '(tip at address 13)
    		WData = $1000 + ($201 * c): GOSUB Send 'background color change 
    		GOSUB Display_page
    		PAUSE 2000
    		NEXT c
    		B3 = Mode 'reads mode
    		B2 = ~ b3 'b2 is not equal to b3, we do not jump and we start again
    	ENDIF 
    		
    	PAUSE 500
    	GOTO Looped		
    
    Jump:
    	PAUSE 200
    	GOTO Looped
    
    
    	END
    	
    '	disable debug
    '------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ---------
    'No overlay. We go into mixed mode and we delete the screen
    Incrust_off:
     
    		GOSUB Mode_mixed
    		PAUSE 100
    		b1 = 1
    		B3 = Mode 'reads mode
    		B2 = ~ b3 'b2 is not equal to b3, we do not jump
    		GOTO Looped
    			
    '------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ---------	
    'No Overlay
    Delete_Screen: 
    
    	c = 0
    	
        WData = 0: GOSUB Send 'tip top left of screen (0,0)
        c = 1
        FOR c = 1 TO 308 'on clears the screen with spaces (0B)
    	WData = $1700 + $0B: GOSUB Send '$1700: background disabled, white character not blinking
        NEXT c
        RETURN
    '------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ---------    
    'display in overlay mode
    Display_mixed:
     
        WData = 0: GOSUB Send 'do not omit this line: position 0,0
        WData = $1780 + $6E: GOSUB Send 'flashing parable
        WData = $170B:        GOSUB Send 'space
        WData = $1700 + $11:  GOSUB Send 'F
        WData = $1700 + $06:  GOSUB Send '6	
        WData = $1700 + $0E:  GOSUB Send 'C	
        WData = $1700 + $1E:  GOSUB Send 'S
        WData = $1700 + $23:  GOSUB Send 'X
    
        WData = $170B:        GOSUB Send 'space
        WData = $170B:        GOSUB Send 'space
        WData = $170B:        GOSUB Send 'space
              
        WData = $1700 + $18:  GOSUB Send 'M   
        WData = $1700 + $0C:  GOSUB Send 'A
        WData = $1700 + $1D:  GOSUB Send 'R
        WData = $1700 + $1E:  GOSUB Send 'S
        WData = $1700 + $10:  GOSUB Send 'E 
        WData = $1700 + $14:  GOSUB Send 'I
        WData = $1700 + $17:  GOSUB Send 'L	
        WData = $1700 + $17:  GOSUB Send 'L
        WData = $1700 + $10:  GOSUB Send 'E	
        
        WData = $170B:        GOSUB Send 'space
        WData = $170B:        GOSUB Send 'space
        WData = $170B:        GOSUB Send 'space    
        
        WData = $1700 + $15:  GOSUB Send 'J   
        WData = $1700 + $19:  GOSUB Send 'N
        WData = $1700 + $02:  GOSUB Send '2
        WData = $1700 + $03:  GOSUB Send '3
        WData = $1700 + $1D:  GOSUB Send 'R 
        WData = $1700 + $13:  GOSUB Send 'H
      		
    	PAUSE 1000	 
    	RETURN
    '------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ---------
    'display in page mode
    Display_page: 
    
    'First line in Max Zoom
      
        WData = 0:           GOSUB Send 'do not omit this line: position 0,0 Line 0
        WData = $1F0B:       GOSUB Send 'space
        WData = $1F00 + $11: GOSUB Send 'F with blue background
        WData = $1F00 + $06: GOSUB Send '6	
        WData = $1F00 + $0E: GOSUB Send 'C	
        WData = $1F00 + $1E: GOSUB Send 'S
        WData = $1F00 + $23: GOSUB Send 'X
    
    
        WData = $100:         GOSUB Send 'line 1
        WData = $170B:        GOSUB Send 'space
        WData = $170B:        GOSUB Send 'space
        WData = $1700 + $1A:  GOSUB Send 'O with black background
        WData = $1700 + $39:  GOSUB Send 'p
        WData = $1700 + $26:  GOSUB Send ':
        WData = $1700 + $15:  GOSUB Send 'J
        WData = $1700 + $1A:  GOSUB Send 'O
        WData = $1700 + $10:  GOSUB Send 'E
        WData = $1700 + $17:  GOSUB Send 'L
        WData = $170B:        GOSUB Send 'space
        WData = $170B:        GOSUB Send 'space
        WData = $170B:        GOSUB Send 'space
        WData = $170B:        GOSUB Send 'space
         
        WData = $1700 + $1C:  GOSUB Send 'Q
        WData = $1700 + $1F:  GOSUB Send 'T
        WData = $1700 + $13:  GOSUB Send 'H   
        WData = $1700 + $26:  GOSUB Send ':    
        WData = $1700 + $18:  GOSUB Send 'M   
        WData = $1700 + $0C:  GOSUB Send 'A
        WData = $1700 + $1D:  GOSUB Send 'R
        WData = $1700 + $1E:  GOSUB Send 'S
        WData = $1700 + $10:  GOSUB Send 'E 
        WData = $1700 + $14:  GOSUB Send 'I
        WData = $1700 + $17:  GOSUB Send 'L	
        WData = $1700 + $17:  GOSUB Send 'L
        WData = $1700 + $10:  GOSUB Send 'E
     
        WData = $200:         GOSUB Send 'line 2 
        WData = $1700 + $1E:  GOSUB Send 'S
        WData = $1700 + $1A:  GOSUB Send 'O 
        WData = $1700 + $19:  GOSUB Send 'N    
        WData = $1700 + $26:  GOSUB Send ': 
        WData = $1700 + $01:  GOSUB Send '1
        WData = $1700 + $04:  GOSUB Send '4    
        WData = $1700 + $05:  GOSUB Send '5
        WData = $1700 + $27:  GOSUB Send '. 
        WData = $1700 + $02:  GOSUB Send '2
        WData = $1700 + $02:  GOSUB Send '2    
        WData = $1700 + $05:  GOSUB Send '5
        WData = $1700 + $18:  GOSUB Send 'M 
        WData = $1700 + $13:  GOSUB Send 'H    
        WData = $1700 + $43:  GOSUB Send 'z
        WData = $170B:        GOSUB Send 'space    
        WData = $1700 + $38:  GOSUB Send 'o
        WData = $1700 + $3E:  GOSUB Send 'u      
        WData = $170B:        GOSUB Send 'space
        WData = $1700 + $01:  GOSUB Send '1
        WData = $1700 + $04:  GOSUB Send '4    
        WData = $1700 + $05:  GOSUB Send '5    
        WData = $1700 + $27:  GOSUB Send '. 
        WData = $1700 + $04:  GOSUB Send '4   
        WData = $1700 + $00:  GOSUB Send '0     
        WData = $1700 + $00:  GOSUB Send '0
        WData = $1700 + $18:  GOSUB Send 'M 
        WData = $1700 + $13:  GOSUB Send 'H    
        WData = $1700 + $43:  GOSUB Send 'z    
           
                                             
     'Color bars, 4 lines  
       
     FOR iCount = $0 TO $3
        WData = $300 + $100 * iCount: GOSUB Send 'to the beginning of line 3
        
        	
        WData = $170B:        GOSUB Send 'space
        WData = $170B:        GOSUB Send 'space
        
        WData = $1877:        GOSUB Send 'black
        WData = $1877:        GOSUB Send
        WData = $1877:        GOSUB Send
    
        WData = $1977:        GOSUB Send
        WData = $1977:        GOSUB Send
        WData = $1977:        GOSUB Send
    
        WData = $1A77:        GOSUB Send
        WData = $1A77:        GOSUB Send
        WData = $1A77:        GOSUB Send
    
        WData = $1B77:        GOSUB Send
        WData = $1B77:        GOSUB Send
        WData = $1B77:        GOSUB Send
    
        WData = $1C77:        GOSUB Send
        WData = $1C77:        GOSUB Send
        WData = $1C77:        GOSUB Send
    
        WData = $1D77:        GOSUB Send
        WData = $1D77:        GOSUB Send
        WData = $1D77:        GOSUB Send    
    
        WData = $1E77:        GOSUB Send
        WData = $1E77:        GOSUB Send
        WData = $1E77:        GOSUB Send    
    
        WData = $1F77:        GOSUB Send
        WData = $1F77:        GOSUB Send
        WData = $1F77:        GOSUB Send 'white
        NEXT iCount  
    
    	
    	WData = $700:         GOSUB Send
    	FOR iCount = $1 TO $8
        WData = $170B: GOSUB Send 'space
        NEXT iCount 
    	WData = $1700 + $5F:  GOSUB Send '*
    	WData = $1700 + $5F:  GOSUB Send '*
    	WData = $1700 + $5F:  GOSUB Send '*
    	WData = $170B:        GOSUB Send 'space
    	WData = $1780 + W1:   GOSUB Send '2 or 7
       	WData = $1780 + W2:   GOSUB Send '3 or 0
       	WData = $1780 + $2C:  GOSUB Send 'c
       	WData = $1780 + $36:  GOSUB Send 'm
       	WData = $170B:        GOSUB Send 'space
       	WData = $1700 + $5F:  GOSUB Send '*
    	WData = $1700 + $5F:  GOSUB Send '*
    	WData = $1700 + $5F:  GOSUB Send '*
       	
       
        PAUSE 1000	
    	
        RETURN
    '------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ---------
    WasteTime: 'timer 2 clock cycles 
    	ASM
    	  nop
    	  nop
    	ENDASM
    	RETURN
    '------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ---------
    StartCommunication: 'Start of transmission Fig 2 page 12 manual STV5730A
    	HIGH Clk: GOSUB WasteTime 'Clock to 1
    	LOW  Csn: GOSUB WasteTime 'Chip select to 0
    	LOW  Clk: GOSUB WasteTime 'Clock at 0
    	RETURN
    '------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ---------
    StopCommunication: 'end of transmission 
    	HIGH Clk: GOSUB WasteTime 'Clock to 1
    	HIGH Csn: GOSUB WasteTime 'Chip select to 1
    	RETURN
    '------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ---------
    SendOne: 'Send a bit 0
    	HIGH Sda: GOSUB WasteTime
    	LOW  Clk: GOSUB WasteTime
    	HIGH Clk: GOSUB WasteTime
    	RETURN
    '------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ---------
    SendZero: 'sending a bit 1
    	LOW  Sda: GOSUB WasteTime
    	LOW  Clk: GOSUB WasteTime
    	HIGH Clk: GOSUB WasteTime
    	HIGH Sda: GOSUB WasteTime
    	RETURN
    '------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ---------
    OutByte: 'send a 16 bit word
    	FOR Bit_Counter = 1 TO 16
        IF wData.15 = 1 THEN 'MSB first
        GOSUB SendOne
        ELSE
        GOSUB SendZero
        ENDIF
        WData = wData << 1
    	NEXT Bit_Counter
    	RETURN
    '------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ---------
    Send:
    	GOSUB StartCommunication
    	GOSUB OutByte
    	GOSUB StopCommunication
    	RETURN
    '------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ---------'** INITIALIZATION (see page 12 of the DATA SHEET STV5730)
    
    
    Init:
    
    
    	HIGH Clk: HIGH Sda: HIGH Csn
    	WData = $3000: GOSUB Send 'Init STV5730
    	WData = $3000: GOSUB Send
    	WData = $00DB: GOSUB Send
    	WData = $1000: GOSUB Send
    	RETURN
    '------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ---------	
    'PAGE MODE INITIALIZATION
    Mode_page: 
    
    	WData = $00CC: GOSUB Send 'Registry initialization (tip at address 12)
    	WData = $150F: GOSUB Send 'Zoom 
    	WData = $1201: GOSUB Send 'Color 
    	WData = $1FC5: GOSUB Send 'Control
    	WData = $15A1: GOSUB Send 'Position (horizontal 33, Vertical 22)
    	WData = $193E: GOSUB Send 'Fashion 
    
    	WData = $00C0: GOSUB Send 'Set row attributes (tip to first line address)
        WData = $10C4: GOSUB Send '(vertical position = 4, characters with border, characters displayed, horizontal position = 0)
        WData = $10C4: GOSUB Send '(vertical position = 4, characters with border, characters displayed, horizontal position = 0)
        WData = $10C4: GOSUB Send '(vertical position = 4, characters with border, characters displayed, horizontal position = 0)
    	WData = $10C8: GOSUB Send
    	FOR iCount = 0 TO 2	
        WData = $10C0: GOSUB Send '(vertical position = 0, characters with border, characters displayed, horizontal position = 0)
    	NEXT iCount 'Same for the next 10 lines
        WData = $10C8
    	 
        GOSUB Delete_Screen
    	RETURN
    
    '------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ---------
    Mode_mixed: 'INITIALIZATION IN JOINT MODE
    
    	WData = $00CC: GOSUB Send 'Registry initialization (tip at address 12)
    	WData = $1000: GOSUB Send 'Zoom (1pixel / dot - 1 pixel / line)
    	WData = $1204: GOSUB Send 'Color (red background, line, character background)
    	WData = $1FD4: GOSUB Send 'Control (mixed mode, character background controlled by BE, display on, color character by character attribute
    				'0.5s flashing, duty cycle 0.5, STV sync, PAL, external luminance level, normal full page mode 
    	WData = $15A1: GOSUB Send 'Position (horizontal 33, Vertical 22)
    	WData = $183E: GOSUB Send 'Mode (disconnected BAR, synch pulse detection, internal mute, 32-line mute time, re-inserted sync, 6dB video gain
    				'Color coder in use, video out2 = video in, video out2 low impedance, normal mode, no delay compensation,
    				'M sync with vertical sync
    
    	WData = $00C0: GOSUB Send 'Set row attributes (tip to first line address)
    	FOR iCount = 0 TO 10	
        WData = $10C4: GOSUB Send '(vertical position = 4, characters with border, characters displayed, horizontal position = 0)
    	NEXT iCount 'Same for the following lines
    	GOSUB Delete_screen
    	RETURN
    Best, Ed
    Last edited by Demon; - 16th June 2017 at 18:40. Reason: Code tags

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,519


    Did you find this post helpful? Yes | No

    Default Re: A little HELP!!

    Hi Ed,
    Don't you have two or three threads regarding this already, is there a need for yet a new one? And can you please use the appropriate code-tags when posting code. Doing so preserves the indentation of the code making it easier to read. Anyhow...

    Do you have the correct crystal frequency for NTSC clocking the STV5730A?

    I only took a brief look in the datasheet (and I don't have any experience with the chip) but it looks to me like PAL/NTCS is selected by bit 8 in the control register (0=NTSC, 1=PAL) in your code there are two places where it seems to set the control register (at least that's what the comments says) and both places have BIT 8 = 1 (ie PAL).

    In the Mode_Page subroutine
    Code:
    WData = $1FC5: GOSUB Send 'Control
    In the Mode_Mixed subroutine
    Code:
    WData = $1FD4: GOSUB Send
    If PAL/NTCS switch is the problem that's where you need to change the code.

    /Henrik.

    EDIT: I see you that you probably tried to use the code tags but got the syntax wrong so thumbs up for trying at least :-)

  3. #3
    Join Date
    Mar 2011
    Location
    Los Angeles, California
    Posts
    322


    Did you find this post helpful? Yes | No

    Default Re: A little HELP!!

    Thanks Henrik!
    I thought the syntax was to place "Code:" before doing a paste of the code? I tried to find your original syntax instructions and keep getting "invalid forum option". How do I expand the "$1FC5" and "$1FD4" to see the bit pattern?

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,519


    Did you find this post helpful? Yes | No

    Default Re: A little HELP!!

    Hi Ed,
    Use a calculator capable of displaying hex, decimal, binary (such as the one included in Windows) or, if you want an exercise, use a pen and a piece of paper.

    What clock frequency are you using for chip?

    Please see this link for the vBulletin syntax.

    /Henrik.

  5. #5
    Join Date
    Mar 2011
    Location
    Los Angeles, California
    Posts
    322


    Did you find this post helpful? Yes | No

    Default Re: A little HELP!!

    Hi Henrik!
    Thank you again! The xtal is 14.318. (NTSC) I have to go to the dentist today for a some surgery so I will look at the hex to binary after that. My guess is I am only looking at the last two digits, just the C5 in $1FC5?

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,519


    Did you find this post helpful? Yes | No

    Default Re: A little HELP!!

    No, the registers are 16 bits wide, bits are labeled 0-15 (as usual) and you're interested in bit 8 (ie the 9th bit) which would then be the least significant bit in the high byte of the 16-bit Word. But really, look at it at as one 16bit value, convert the hex value you have to binary and compart at against the datasheet.

    In fact, do that for "everything" and you might find something else that isn't right for your application - and you'll learn a lot.

    /Henrik.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts