PDA

View Full Version : A little HELP!!



Ramius
- 16th June 2017, 04:12
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.



'************************************************* ***************
'* 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

HenrikOlsson
- 16th June 2017, 06:33
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

WData = $1FC5: GOSUB Send 'Control

In the Mode_Mixed subroutine

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 :-)

Ramius
- 16th June 2017, 12:44
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?

HenrikOlsson
- 16th June 2017, 13:07
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 (https://www.vbulletin.org/forum/misc.php?do=bbcode#code) for the vBulletin syntax.

/Henrik.

Ramius
- 16th June 2017, 15:47
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?

HenrikOlsson
- 16th June 2017, 18:09
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.

Demon
- 16th June 2017, 18:41
Code: is inserted by the system.

[ Code ] at start.
[ / Code ] at end.

without spaces

Ramius
- 16th June 2017, 21:28
Thank you! I forgot the brackets! Boy do I feel dumb! Back to the code, so I did a hex to binary and binary to hex and came up with $1FC5 should be $1085 and $1FD4 should be $1284. It did not make a change so it must be something else or I did not convert correctly?

HenrikOlsson
- 16th June 2017, 21:59
No, that doesn't look correct to me.
$1FC5 = 0001 1111 1100 0101
$1085 = 0001 0000 1000 0101

That's a lot more changes than one bit.

/Henrik.

Ramius
- 16th June 2017, 23:26
I probably tried to do too much at one time such as turn off the blinking, set it to mixed mode, etc.

Ramius
- 17th June 2017, 20:01
Okay so I did just the one bit change making it $1EC5. It helped. the $1FD4 I made $1ED4. Some how the video with text is being placed below the sync level! I can see sync, burst, and the video appears to be below the sync pulse! The sync pulse should be a negative .3 volts while video is positive .7 volts. Maybe I have a bad chip? There is also a "Mode Register" and I thought it had a value of $00CC and I think I am looking at the wrong register?

HenrikOlsson
- 18th June 2017, 08:15
Hi Ed,
If you're talking about the line WData = $00CC: GOSUB Send it's a command that makes the address pointer in the chip point at address 12 (which apparently is the Zoom register and makes the pointer increment automatically for each data write following the command. The mode register is at address 16 so, as far as I can see, it is being set to either $183E or $193E depending on which of the two subroutines are being called.

/Henrik.

Ramius
- 18th June 2017, 17:49
Hi Henrik!
Again thank you, thank you, thank you! Some settings do not make any sense to me. $183E for example sets M8 to a low impedance state while $193E sets M8 to a high impedance state. It would seem that M8 should be high impedance at all times. I did try to e-mail the author and the e-mail bounced. The first picture is of the video out. Note the bar at the bottom which is below the sync level and should be at the top. Second picture shows what a TV will display. The third photo shows the input video (color bars). Note nothing is below the sync level.

HenrikOlsson
- 18th June 2017, 19:23
I'm afraid I don't know how it's supposed to configured to do what you want and I don't have much experience with composite video signals. All I can do is read the datasheet....

/Henrik.

Ramius
- 18th June 2017, 22:39
Hi Henrik!
Not a problem, at least you are not working with the new digital format of video signals! There are just a bunch of settings that are possible and why certain choices were made make absolutely no sense to me. For example, unless you have some type of noise problems, low impedance is rarely used. In the mode register there is an option to use the BAR pin and a CSYNC pin which suggests to me you can input your incoming video signal and use it as a reference for the sync pulses. The M7 bit appears to output the video in signal which to me would say it ignores any text insertion i.e. bypasses the function of the chip. Since I am also a ham radio operator (WB6NSN) the guy who wrote the program is also a ham (F6CSX) so I will try his e-mail address list on the international ham radio listing. Hopefully he knows English. I certainly do appreciate more than I can express my sincerest thanks for all your help. Just for informational purposes only, in the first picture, the three what look like bars is called color burst as is a reference signal to make sure the colors are correct. Just before the bars are the horizontal sync pulses which go down, across, and up much like a 3 sided rectangle. Below the sync pulses should only be the vertical sync pulses and it is showing the text video which should be above the horizontal sync pulse level. No idea why the video is looking like this or how it went negative. I am not giving up yet! Best, Ed

aerostar
- 20th June 2017, 13:00
Hi, I have dug out some code I used for this chip, but it is PAL, you should be able to change the appropriate bit(s) to NTSC.

It puts the word TEST. on 3rd line at right hand side of the screen.

It also detects synchs and will auto switch mode as necessary, and when there is no incoming video it will display that No Synchs message on screen.

I have modified the code from the original, it had a lot of debug stuff in it, I have not tested since although it should work, (it compiles OK) , I post to let you check the values in the code you have.

I will try and test in the next few days when I get some video stuff resurected.

Just a note it is much easier to put the values in as binary eg %0000000011001100 rather than have to work it out when debugging.




'************************************************* ***************
'* Name : STV-SYNCHS RELEASE *
'* Author : BOB LEGGETT *
'* Notice : Copyright (c) 2009 *
'* : All Rights Reserved *
'* Date : around 2009 or so rehashed now '17 *
'* Version : 1.0 *
'* Notes : VIDEO IDENT *
'* : *
'************************************************* ***************



' WORKS USES SYNC FOR SWITCHING BETWEEN MIXED AND FULL TEXT MODE
' GOING FROM VID IN TO TEXT AND BACK TO VID IN

@ device PIC16F628A,HS_OSC,BOD_ON,MCLR_ON,PWRT_ON

INCLUDE "ALLDIGITAL.pbp"

define OSC 4


'TV CHIP CONNECTIONS



'---------------------------------------------------------------

'16f628a

TVSDA VAR PORTB.1 '0 OUTPUT pin 11 stv
CS0 VAR PORTB.0 '0 OUTPUT pin 13 stv
TVSCL VAR PORTB.5 '0 OUTPUT pin 12 stv
SYNCH0 VAR PORTB.2 '1 'INPUT to pin 7 stvchip
HEARTBEAT VAR PORTB.6 'OUTPUT 0 led
'---------------------------------------------------------------

ZOOMREG CON %0000000011001100 ' 12 ZOOM REGISTER
COLREG CON %0000000011001101 ' 13 COLOUR REGISTER
CONREG CON %0000000011001110 ' 14 CONTROL REGISTER
POSREG CON %0000000011001111 ' 15 POSITION REGISTER
MODEREG CON %0000000011010000 ' 16 MODE REGISTER


ICOUNT VAR BYTE
BITCOUNTER VAR BYTE
WDATA VAR WORD
CHARCOUNTER VAR BYTE '
LINECOUNTER VAR BYTE '


STVCHAR VAR BYTE
ASCCHAR VAR BYTE
CHARS VAR BYTE
CHARS2 VAR BYTE
TEMP VAR BYTE
TEMP1 VAR BYTE
COUNTER VAR BYTE
PULSES VAR BYTE
CURRENTMODE0 VAR BYTE

'----------------------------------------------------------------
' TOPLEFT CON 0
' TOPMIDDLE CON 5
' TOPRIGHT CON 10
' BOTLEFT CON 2560 '10*256
' BOTMIDDLE CON 2565 '(10*256)+ 5
' BOTRIGHT CON 2570 '(10*256)+ 10
'----------------------------------------------------------------

DATA @0,"TEST.",$FF,"NO SYNCHS RECEIVED",$FF



'----------------------------------------------------------------
'628
TRISB=%10011100
'----------------------------------------------------------------


PAUSE 500

HIGH HEARTBEAT


GOSUB Init

PAUSE 500
GOSUB Init

CURRENTMODE0=255 ' FORCES TRYSYNCHS TO SET MODE FIRST TIME


Demo:

CHARCOUNTER = 0
LINECOUNTER = 0
' CURRENTMODE0 = 0 '0 = MIXED 1 = TEXT
gosub CLS
GOSUB TRYSYNCHS '==================================


TEMP = 0



LOOPER:
GOSUB HEADER ' LINE 3 RIGHT HAND SIDE TEST.
IF CURRENTMODE0=1 THEN
GOSUB NOVIDEO ' DISPLAYS NO VIDEO IF NO INCOMING SYNCHS
ENDIF


GOSUB TRYSYNCHS '===========================


PAUSE 500 'I/2 SECOND DELAY
TOGGLE HEARTBEAT ' LED
GOTO LOOPER 'DO IT FOREVER


DISPLAYCHAR:

WDATA = %0001011100000000 + STVCHAR
GOSUB SEND
RETURN
SETLINE:
WDATA = LINECOUNTER*256 + CHARCOUNTER
GOSUB Send 'position cursor
RETURN



WasteTime: ' WORKS WITH LESS NOPS



pauseus 20 ' was 20 nops

RETURN

StartCommunication:
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime

CS0 = 0 'LOW CS0

GOSUB WasteTime
TVSCL = 0 'LOW TVSCL
GOSUB WasteTime
RETURN

StopCommunication:
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
CS0 = 1 'HIGH CS0

GOSUB WasteTime
RETURN

SendOne:
TVSDA = 1 'HIGH TVSDA
GOSUB WasteTime
TVSCL = 0 'LOW TVSCL
GOSUB WasteTime
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
RETURN

SendZero:
TVSDA = 0 'LOW TVSDA
GOSUB WasteTime
TVSCL = 0 ' LOW TVSCL
GOSUB WasteTime
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
TVSDA = 1 'HIGH TVSDA
GOSUB WasteTime
RETURN

OutByte:
FOR BITCOUNTER = 1 TO 16
IF WDATA.15 = 1 THEN
GOSUB SendOne
ELSE
GOSUB SendZero
ENDIF
WDATA = WDATA << 1
NEXT BITCOUNTER
RETURN

Send:
GOSUB StartCommunication
GOSUB OutByte
GOSUB StopCommunication
RETURN

'-------------------------------------------------------------

Init: ' PAUSE 50 added - seems to improve reliability of init

TVSCL = 1 'HIGH TVSCL
TVSDA = 1 'HIGH TVSDA
CS0 = 1 'HIGH CS0

WDATA = $3000 '%110000 00000000
GOSUB Send ' Init STV5730
PAUSE 50
WDATA = $3000
GOSUB Send
PAUSE 50
WDATA = $00DB '%00000000 11011011
GOSUB Send
PAUSE 50
WDATA = $1000 '%00010000 00000000
GOSUB Send
PAUSE 50
'-------------------------------------------------------------
WDATA = %0000000011001100
GOSUB Send ' Init registers (point to register 12)
PAUSE 50
'-------------------------------------------------------------
WDATA = %0001000000000000 'NORMAL
' WDATA = %0001000011110000 '4 PIXELS HORIZ AND VERT
GOSUB Send ' Zoom ADDRESS 12
PAUSE 50
'-------------------------------------------------------------
WDATA = %0001001000000000

' WDATA = %0001001000000100
GOSUB Send ' Color ADDRESS 13
PAUSE 50
'--------------------------------------------------------

WDATA= %0001101111010100
'CHANGE BIT 0 TO 1 FOR TEXT ONLY
GOSUB Send ' Control ADDRESS 14
'-------------------------------------------------------------
WDATA = %0001011111001111
GOSUB Send ' Position ADDRESS 15
'-------------------------------------------------------------


WDATA = %0001000100101110 '$183E BIT 11 CHANGED TO 0 M4 = 0

GOSUB Send ' Mode ADDRESS 16 %0001100000111110

'-------------------------------------------------------------

WDATA = $00C0 '%00000000 11000000
GOSUB Send ' Set row attributes

FOR ICOUNT = 0 TO 10
WDATA = $10C4 '%00010000 11000100
' WDATA =%0001000010000111
GOSUB Send
NEXT ICOUNT
RETURN

CLS:
'character=$0B 'SPACE
TEMP1=0 ' LINECOUNTER
TEMP =0 'CHARCOUNTER
loop2:

WDATA = 0 ' LINECOUNTER*256 + CHARCOUNTER ADDRESS
GOSUB Send


LOOP3: ' :CHARACTERS
WDATA = %0001011100001011 ' 1011 0BH SPACECHARACTER
GOSUB Send
TEMP = TEMP + 1
IF TEMP >= 28 THEN
TEMP = 0
TEMP1=TEMP1 + 1
ENDIF
IF TEMP1 >= 11 THEN SCREENBLANK

GOTO LOOP3

SCREENBLANK:
RETURN

GETSTVCHAR: 'CONVERT ASCII TO STV
STVCHAR =$7F ' FORCES CLOCK PICTURE IF ERROR
LOOKDOWN ASCCHAR,["0123456789- ABCDEFGHIJKLMNOPQRSTUVWXYZ:./'abcdefghijklmnopqrstuvwxyz"],STVCHAR
RETURN

HEADER:
LINECOUNTER=2 'SET START POSITION
CHARCOUNTER=23 'SET CURSOR POSITION
GOSUB SETLINE
FOR CHARS2=0 TO 4
READ CHARS2, ASCCHAR
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
NEXT
RETURN

NOVIDEO:
LINECOUNTER=5 'SET START POSITION
CHARCOUNTER=4 'SET CURSOR POSITION
GOSUB SETLINE
FOR CHARS2=6 TO 23 ' FROM EEPROM DATA
READ CHARS2, ASCCHAR
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
NEXT
RETURN

TRYSYNCHS:

PULSES=0

COUNT SYNCH0,4,PULSES '3MS SHOULD COUNT TO 2 OR 3
IF PULSES > 0 THEN MIXED0
FULL0:

IF CURRENTMODE0=1 THEN RETURN

WDATA= %0000000011001110 'CONTROL REGISTER
GOSUB SEND
WDATA= %0001101111010101
'CHANGE BIT 0 TO 1 FOR TEXT ONLY OTIGINAL

' WDATA= %0001101111010100
'CHANGE BIT 0 TO 1 FOR TEXT ONLY
GOSUB SEND

STAYHERE02:

CURRENTMODE0=1
GOSUB CLS
GOBACK0:
RETURN


MIXED0:
IF CURRENTMODE0=0 THEN RETURN
WDATA= %0000000011001110 'CONTROL REGISTER
GOSUB SEND
WDATA= %0001101111010100
GOSUB SEND

STAYHERE01:

CURRENTMODE0=0
GOSUB CLS
RETURN






Darrel Taylor ALLDIGITAL.pbp if you do not have it.




;************************************************* **************************
;* Name : ALLDIGITAL.pbp *
;* Author : Darrel Taylor *
;* Notice : Copyright (c) 2009 *
;* : All Rights Reserved until Abused *
;* Date : 4/30/2009 *
;* Version : 1.5 (3/7/2011) *
;* Notes : An INCLUDE file that will automatically enable *
;* : all DIGITAL Inputs multiplexed with the ADC or Comparators *
;* : Works with ANY PIC, using either PM or MPASM *
;************************************************* **************************
;* Useage : INCLUDE "AllDigital.pbp" *
;* : yup, that's it. Just include the file and it's All Digital *
;* : Adding this line to your program will display the values *
;* : used to achieve AllDigital ... (if using MPASM) *
;* : DEFINE SHOWDIGITAL 1 *
;************************************************* **************************
;* Versions: 1.0 - Initial release *
;* 5/6/2009 : 1.1 - Added Shared address SFR support for 18F87J50 family *
;* : Thanks to mister_e *
;* 5/9/2009 : 1.2 - Removed MPASM specific opcode (variable), for PM.exe *
;* : Thanks to Tobias *
;* 7/11/2009: 1.3 - Added ANSELA,ANSELB,ANSELD,ANSELE for the 16F72x series*
;* 7/19/2010: 1.4 - Added ANSEL0 and ANSEL1 for the 18F4431 series. *
;* 3/7/2011: 1.5 - Update for latest chips from Microchip *
;************************************************* **************************

;Check 18F45k80 ----
; Uses ANCONx with ANSEL0 and ANSEL1 as bit names
; other PIC's have ANSEL0 and ANSEL1

ASM
;----[Module defaults]------------------------------------------------------
#define SHOWDIGITALDEFAULT 0
ifdef SHOWDIGITAL
SHOWDIGITALRESULT = SHOWDIGITAL
else
SHOWDIGITALRESULT = SHOWDIGITALDEFAULT
endif
ifndef PM_USED
ifndef ADLISTALL
nolist
endif
endif

;----[Attempt to Set a registers Value]-------------------------------------
SetReg macro RegOut, Cin
ifndef PM_USED
ifndef ADLISTALL
nolist
endif
endif

ifdef RegOut
ifndef PM_USED
list
endif
MOVE?CB Cin, RegOut
if (SHOWDIGITALRESULT == 1)
ifndef PM_USED
messg RegOut = Cin
endif
endif
ifndef PM_USED
ifndef ADLISTALL
nolist
endif
endif
endif
endm

;----[A/D Converter registers]----------------------------------------------
HasANSEL = 0
ifdef ANSEL
HasANSEL = 1
SetReg ANSEL , 0 ; if chip has ANSEL's, clear them
endif
ifdef ANSEL0
ifndef ANCON0
HasANSEL = 1
SetReg ANSEL0, 0
endif
endif
ifdef ANSEL1
ifndef ANCON0
HasANSEL = 1
SetReg ANSEL1, 0
endif
endif
ifdef ANSELA
HasANSEL = 1
SetReg ANSELA, 0
endif
ifdef ANSELB
HasANSEL = 1
SetReg ANSELB, 0
endif
ifdef ANSELC
HasANSEL = 1
SetReg ANSELC, 0
endif
ifdef ANSELD
HasANSEL = 1
SetReg ANSELD, 0
endif
ifdef ANSELE
HasANSEL = 1
SetReg ANSELE, 0
endif
ifdef ANSELF
HasANSEL = 1
SetReg ANSELF, 0
endif
ifdef ANSELG
HasANSEL = 1
SetReg ANSELG, 0
endif
ifdef ANSELH
HasANSEL = 1
SetReg ANSELH, 0
endif
ifdef ANSELI
HasANSEL = 1
SetReg ANSELI, 0
endif
ifdef ANSELJ
HasANSEL = 1
SetReg ANSELJ, 0
endif
ifdef ANSELK
HasANSEL = 1
SetReg ANSELK, 0
endif
if (HasANSEL == 0)
ifdef ANCON0 ; Several chips use ANCON0 and ANCON1
ifdef ADSHR ; if chip has shared address SFR's
MOVE?CT 1, WDTCON,ADSHR ; switch to shared address registers
if (SHOWDIGITALRESULT == 1)
messg WDTCON.4 = 1
endif
endif
SetReg ANCON0, 0xFF ;
ifdef PCFG15 ; 0 = Analog with these bits
SetReg ANCON1, 0xFF
else
SetReg ANCON1, 0x7F
endif
ifdef ADSHR ; if chip has shared address SFR's
MOVE?CT 0, WDTCON,ADSHR ; put SFR's back to legacy
if (SHOWDIGITALRESULT == 1)
messg WDTCON.4 = 0
endif
endif
else
ifdef PCFG6 ; Some chips use ADCON1 bits
SetReg ADCON1, 0x7F ; the same way as ANCONx
else
ifdef PCFG3 ; if there's a PCFG3 bit
ifdef ADCON2 ; but has no ADCON2, more than 8 A/D's
SetReg ADCON1, 0x0F ; A/D cfg from table = 0x0F
else
SetReg ADCON1, 7 ; most common, 8 or less A/D ch's
endif
else
ifdef PCFG2
ifdef ADCON1
SetReg ADCON1, 7 ; A/D is 8-bit, 5 ch's
endif
else
ifdef ADCON0 ; if there's an ADCON0
ifndef ADCON1 ; but not an ADCON1
SetReg ADCON0, 0 ; A/D is 8-bit and ADS bits are in ADCON0
endif
endif
endif
endif
endif
endif
endif

;----[Comparators]----------------------------------------------------------
ifdef CMCON
ifdef CMEN0 ; 18F1230/1330
;SetReg CMCON, 0 ; default already
else
ifdef CM2
SetReg CMCON, 7
else
ifdef PM_USED
"ALLDIGITAL: CMCON value not found"
else
messg "ALLDIGITAL: CMCON value not found"
endif
endif
endif
endif

ifdef CMCON0
ifdef NOT_COUTEN
SetReg CMCON0, 0xF1 ; 10F204/206
else
ifdef CMCH
SetReg CMCON0, 0 ; 12F609/615
else
ifdef CM2
SetReg CMCON0, 7 ; 12F635/683,
else ; 16F636/639/684/688/913/914/916/917/946
ifndef PM_USED
"ALLDIGITAL: CMCON0 value not found"
else
messg "ALLDIGITAL: CMCON0 value not found"
endif
endif
endif
endif
endif

ifdef CM1CON0 ; individual comparator controls
ifdef NOT_C1OUTEN
SetReg CM1CON0, 0xF1 ; 12F510/506, 16F526
else
; SetReg CM1CON0, 0 ; these already default to 0 --------------
endif ; 16F882/883/884/886/887/ 610/616
endif ; 16F631/677/685/687/689/690

; these aren't 0, but default to OFF
; 18F24J11/25J11/26J11/44J11/45J11/46J11
; 18F24J50/25J50/26J50/44J50/45J50/46J50
ifdef CM2CON0
ifdef NOT_C2OUTEN
SetReg CM2CON0, 0xF1
else
; SetReg CM2CON0, 0 ; already default to 0 -----see above-
endif
endif

; CM1CON ; these aren't 0, but default to OFF
; 18F65J50/66J50/66J55/67J50/66J11/66J16/67J11
; CM2CON ; 18F85J50/86J50/86J55/87J50/86J11/86J16/87J11

ifndef PM_USED
list
endif
ENDASM

Ramius
- 20th June 2017, 20:13
Thank you! Thank you! Thank you! It will be exciting to try it.

Ed

aerostar
- 21st June 2017, 10:01
Hi,

I have compiled and programmed a 16f628a and it all works fine.:)

Pics a bit fuzzy due slow shutter.

Remember the code posted is the PAL version you need to change the bit(s) for NTSC.

Cannot test on NTSC as no suitable equipment.


84388439

Ramius
- 21st June 2017, 12:34
Wow! Looks Great! Would you know which bits to change? I ask since I was not successful with my previous program.

Thanks, Ed

aerostar
- 21st June 2017, 14:40
looks like it is bit 8 of control regester for NTSC



Search for %0000000011001110

Immediately below you will see gosub send, this points the chip to address 14

the next instruction is the actual values that are to be sent
change bit 8 to be a 0

There are 3 places I think that need to be changed

in label FULL0: and MIXED0: and INIT:

FULL0:

IF CURRENTMODE0=1 THEN RETURN

WDATA= %0000000011001110 'CONTROL REGISTER
GOSUB SEND
WDATA= %0001101111010101 ' <<<<< change bit 8 to 0 (far right is bit zero)


FULL0:

IF CURRENTMODE0=1 THEN RETURN


WDATA= %0000000011001110 'CONTROL REGISTER
GOSUB SEND
WDATA= %0001101111010101 ' <<<< change bit 8 to a 0 (far right is bit zero)


In the init routine look for this

WDATA= %0001101111010100 ' change bit 8 to a 0 (far right is bit zero)
'CHANGE BIT 0 TO 1 FOR TEXT ONLY
GOSUB Send ' Control ADDRESS 14


I do not think anything else needs to be done - but I could be wrong.!!

The init routine for the chip under certain circumstances will auto up the address, that is why there is no
WDATA= %0000000011001110 'CONTROL REGISTER
prior to it.

Sorry cannot help much more on the settings.

aerostar
- 22nd June 2017, 11:40
Looks likely I can run a partial test on NTSC, I have found the appropriate crystal deep in the odd box, and I have the possible loan of a multi monitor, it is rather old but if it still works it will do NTSC.

I have found the original picbasic files on the web, and that compiles fine for 16F628a. The only thing I have to change are the port numbers to suit my pic/sstv board, all operations will be unchanged.

I do not have a NTSC source, so it would not be a full test, but if text appears, then that should at least prove the NTSC side is working.

It will be a few days before I get the chance to do this.

In the meantime please post if you get your board working on NTSC.

Ramius
- 22nd June 2017, 21:48
Hi Aerostar!
I cannot tell how much I appreciate what you are doing! The same as you I have to make some port changes to accommodate wiring. I think I set the TRISB settings correctly and well as the register changes you recommended. This is probably going to sound strange and when I run the code it gets stuck (stops) at "Pause 500"! not sure why?


'************************************************* ***************
'* Name : STV-SYNCHS RELEASE *
'* Author : BOB LEGGETT *
'* Notice : Copyright (c) 2009 *
'* : All Rights Reserved *
'* Date : around 2009 or so rehashed now '17 *
'* Version : 1.0 *
'* Notes : VIDEO IDENT *
'* : *
'************************************************* ***************

' WORKS USES SYNC FOR SWITCHING BETWEEN MIXED AND FULL TEXT MODE
' GOING FROM VID IN TO TEXT AND BACK TO VID IN

INCLUDE "ALLDIGITAL.pbp"

define OSC 20

#CONFIG
__config _HS_OSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
#ENDCONFIG


'TV CHIP CONNECTIONS


'---------------------------------------------------------------

'16f628a

TVSDA VAR PORTB.4 '0 OUTPUT pin 11 stv was b.1
CS0 VAR PORTB.6 '0 OUTPUT pin 13 stv was b.0
TVSCL VAR PORTB.5 '0 OUTPUT pin 12 stv was b.5
SYNCH0 VAR PORTB.7 '1 'INPUT to pin 7 stvchip was b.2
HEARTBEAT VAR PORTB.6 'OUTPUT 0 led was b.6
'---------------------------------------------------------------

ZOOMREG CON %0000000011001100 ' 12 ZOOM REGISTER
COLREG CON %0000000011001101 ' 13 COLOUR REGISTER
CONREG CON %0000000011001110 ' 14 CONTROL REGISTER
POSREG CON %0000000011001111 ' 15 POSITION REGISTER
MODEREG CON %0000000011010000 ' 16 MODE REGISTER


ICOUNT VAR BYTE
BITCOUNTER VAR BYTE
WDATA VAR WORD
CHARCOUNTER VAR BYTE '
LINECOUNTER VAR BYTE '

STVCHAR VAR BYTE
ASCCHAR VAR BYTE
CHARS VAR BYTE
CHARS2 VAR BYTE
TEMP VAR BYTE
TEMP1 VAR BYTE
COUNTER VAR BYTE
PULSES VAR BYTE
CURRENTMODE0 VAR BYTE

'----------------------------------------------------------------
' TOPLEFT CON 0
' TOPMIDDLE CON 5
' TOPRIGHT CON 10
' BOTLEFT CON 2560 '10*256
' BOTMIDDLE CON 2565 '(10*256)+ 5
' BOTRIGHT CON 2570 '(10*256)+ 10
'----------------------------------------------------------------

DATA @0,"TEST.",$FF,"NO SYNCHS RECEIVED",$FF



'----------------------------------------------------------------
'628
TRISB=%10000100
'----------------------------------------------------------------


PAUSE 500

HIGH HEARTBEAT


GOSUB Init

PAUSE 500
GOSUB Init

CURRENTMODE0=255 ' FORCES TRYSYNCHS TO SET MODE FIRST TIME


Demo:

CHARCOUNTER = 0
LINECOUNTER = 0
' CURRENTMODE0 = 0 '0 = MIXED 1 = TEXT
gosub CLS
GOSUB TRYSYNCHS '==================================


TEMP = 0



LOOPER:
GOSUB HEADER ' LINE 3 RIGHT HAND SIDE TEST.
IF CURRENTMODE0=1 THEN
GOSUB NOVIDEO ' DISPLAYS NO VIDEO IF NO INCOMING SYNCHS
ENDIF


GOSUB TRYSYNCHS '===========================


PAUSE 500 'I/2 SECOND DELAY
TOGGLE HEARTBEAT ' LED
GOTO LOOPER 'DO IT FOREVER


DISPLAYCHAR:

WDATA = %0001011100000000 + STVCHAR
GOSUB SEND
RETURN
SETLINE:
WDATA = LINECOUNTER*256 + CHARCOUNTER
GOSUB Send 'position cursor
RETURN



WasteTime: ' WORKS WITH LESS NOPS



pauseus 20 ' was 20 nops

RETURN

StartCommunication:
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime

CS0 = 0 'LOW CS0

GOSUB WasteTime
TVSCL = 0 'LOW TVSCL
GOSUB WasteTime
RETURN

StopCommunication:
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
CS0 = 1 'HIGH CS0

GOSUB WasteTime
RETURN

SendOne:
TVSDA = 1 'HIGH TVSDA
GOSUB WasteTime
TVSCL = 0 'LOW TVSCL
GOSUB WasteTime
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
RETURN

SendZero:
TVSDA = 0 'LOW TVSDA
GOSUB WasteTime
TVSCL = 0 ' LOW TVSCL
GOSUB WasteTime
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
TVSDA = 1 'HIGH TVSDA
GOSUB WasteTime
RETURN

OutByte:
FOR BITCOUNTER = 1 TO 16
IF WDATA.15 = 1 THEN
GOSUB SendOne
ELSE
GOSUB SendZero
ENDIF
WDATA = WDATA << 1
NEXT BITCOUNTER
RETURN

Send:
GOSUB StartCommunication
GOSUB OutByte
GOSUB StopCommunication
RETURN

'-------------------------------------------------------------

Init: ' PAUSE 50 added - seems to improve reliability of init

TVSCL = 1 'HIGH TVSCL
TVSDA = 1 'HIGH TVSDA
CS0 = 1 'HIGH CS0

WDATA = $3000 '%110000 00000000
GOSUB Send ' Init STV5730
PAUSE 50
WDATA = $3000
GOSUB Send
PAUSE 50
WDATA = $00DB '%00000000 11011011
GOSUB Send
PAUSE 50
WDATA = $1000 '%00010000 00000000
GOSUB Send
PAUSE 50
'-------------------------------------------------------------
WDATA = %0000000011001100
GOSUB Send ' Init registers (point to register 12)
PAUSE 50
'-------------------------------------------------------------
WDATA = %0001000000000000 'NORMAL
' WDATA = %0001000011110000 '4 PIXELS HORIZ AND VERT
GOSUB Send ' Zoom ADDRESS 12
PAUSE 50
'-------------------------------------------------------------
WDATA = %0001001000000000

' WDATA = %0001001000000100
GOSUB Send ' Color ADDRESS 13
PAUSE 50
'--------------------------------------------------------

WDATA= %0001101011010100
'CHANGE BIT 0 TO 1 FOR TEXT ONLY
GOSUB Send ' Control ADDRESS 14
'-------------------------------------------------------------
WDATA = %0001011111001111
GOSUB Send ' Position ADDRESS 15
'-------------------------------------------------------------


WDATA = %0001000100101110 '$183E BIT 11 CHANGED TO 0 M4 = 0

GOSUB Send ' Mode ADDRESS 16 %0001100000111110

'-------------------------------------------------------------

WDATA = $00C0 '%00000000 11000000
GOSUB Send ' Set row attributes

FOR ICOUNT = 0 TO 10
WDATA = $10C4 '%00010000 11000100
' WDATA =%0001000010000111
GOSUB Send
NEXT ICOUNT
RETURN

CLS:
'character=$0B 'SPACE
TEMP1=0 ' LINECOUNTER
TEMP =0 'CHARCOUNTER
loop2:

WDATA = 0 ' LINECOUNTER*256 + CHARCOUNTER ADDRESS
GOSUB Send


LOOP3: ' :CHARACTERS
WDATA = %0001011100001011 ' 1011 0BH SPACECHARACTER
GOSUB Send
TEMP = TEMP + 1
IF TEMP >= 28 THEN
TEMP = 0
TEMP1=TEMP1 + 1
ENDIF
IF TEMP1 >= 11 THEN SCREENBLANK

GOTO LOOP3

SCREENBLANK:
RETURN

GETSTVCHAR: 'CONVERT ASCII TO STV
STVCHAR =$7F ' FORCES CLOCK PICTURE IF ERROR
LOOKDOWN ASCCHAR,["0123456789- ABCDEFGHIJKLMNOPQRSTUVWXYZ:./'abcdefghijklmnopqrstuvwxyz"],STVCHAR
RETURN

HEADER:
LINECOUNTER=2 'SET START POSITION
CHARCOUNTER=23 'SET CURSOR POSITION
GOSUB SETLINE
FOR CHARS2=0 TO 4
READ CHARS2, ASCCHAR
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
NEXT
RETURN

NOVIDEO:
LINECOUNTER=5 'SET START POSITION
CHARCOUNTER=4 'SET CURSOR POSITION
GOSUB SETLINE
FOR CHARS2=6 TO 23 ' FROM EEPROM DATA
READ CHARS2, ASCCHAR
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
NEXT
RETURN

TRYSYNCHS:

PULSES=0

COUNT SYNCH0,4,PULSES '3MS SHOULD COUNT TO 2 OR 3
IF PULSES > 0 THEN MIXED0
FULL0:

IF CURRENTMODE0=1 THEN RETURN

WDATA= %0000000011001110 'CONTROL REGISTER
GOSUB SEND
WDATA= %0001101011010101 ' was 0001101111010101
'CHANGE BIT 0 TO 1 FOR TEXT ONLY OTIGINAL

'WDATA= %0001101111010100
'CHANGE BIT 0 TO 1 FOR TEXT ONLY
GOSUB SEND

STAYHERE02:

CURRENTMODE0=1
GOSUB CLS
GOBACK0:
RETURN


MIXED0:
IF CURRENTMODE0=0 THEN RETURN
WDATA= %0000000011001110 'CONTROL REGISTER
GOSUB SEND
WDATA= %0001101011010101 'was 0001101111010100
GOSUB SEND

STAYHERE01:

CURRENTMODE0=0
GOSUB CLS
RETURN



I hope I pasted the code correctly this time!!!

Best, Ed

aerostar
- 22nd June 2017, 22:51
Have just glanced at your code, first thing I noticed was


You have 2 declarations for Port B.6 this may well be your problem

TVSDA VAR PORTB.4 '0 OUTPUT pin 11 stv was b.1
CS0 VAR PORTB.6 '0 OUTPUT pin 13 stv was b.0 <<<<<<<<<<<<<<<<<<<<<<<<<
TVSCL VAR PORTB.5 '0 OUTPUT pin 12 stv was b.5
SYNCH0 VAR PORTB.7 '1 'INPUT to pin 7 stvchip was b.2
HEARTBEAT VAR PORTB.6 'OUTPUT 0 led was b.6 <<<<<<<<<<<<<<<<<<<<<<<<<<<<


I will have another look tomorrow as it is bedtime over here (UK) and I am tired.


Thought.... as you are only using digital ports PORT B you do not need the include file.
The file just makes all Analog ports digital - it works fine on 628a and others BUT may not work on newer chips, as I mostly use these or similar.

Ramius
- 23rd June 2017, 03:49
I will try that a little later. Right now the program freezes right after the TRISB statement at the Pause 500. Comment out the Pause 500 at it stops at the High Heartbeat! I am so confused!:confused:

aerostar
- 23rd June 2017, 11:42
I have got the monitor that does NTSC, changing the appropriate bit 8 in the register 14 and with the 14.318 xtal in the STV board, I get a picture with readable text, see below.

However the display is not in the correct place and there is no colour. Further investigation needed!!

It sort of looks like the timing is wrong somewhere probably another setting needs to be changed.

8440

Ramius
- 23rd June 2017, 12:22
Looks Great! I am still stuck with my program freezing right after the TRISB statement at the Pause 500. Comment out the Pause 500 at it stops at the High Heartbeat! I am so confused!:confused:

aerostar
- 24th June 2017, 13:54
News

I have NTSC display full colour and in the correct position. Problem was low voltage on my STV board, when that was fixed it worked straight away.

Code attached
Program your 628a with the hex code, if it works on your 628A then you have a compiler prob or something, if it does not work you may have a naff 628a.

Also I compile with Picbasic Pro Ver 2.60C - I think you compile using MPLAB, not sure of your PB version, try compiling the 628a code with the PBP compiler.

heartbeat led remarked out

cmcon added in, but not needed as you are not using port A

TRIS B changed to reflect your ports use.




'************************************************* ***************
'* Name : STV-SYNCHS RELEASE *
'* Author : BOB LEGGETT *
'* Notice : Copyright (c) 2009 *
'* : All Rights Reserved *
'* Date : around 2009 or so rehashed now '17 *
'* Version : 1.0 *
'* Notes : VIDEO IDENT *
'* : *
'************************************************* ***************



' WORKS USES SYNC FOR SWITCHING BETWEEN MIXED AND FULL TEXT MODE
' GOING FROM VID IN TO TEXT AND BACK TO VID IN

@ device PIC16f628a,HS_OSC,BOD_ON,MCLR_ON,PWRT_ON



define OSC 20


'TV CHIP CONNECTIONS



'---------------------------------------------------------------
'16f628a ED definitions

TVSDA VAR PORTB.4 '0 OUTPUT pin 11 stv was b.1
CS0 VAR PORTB.6 '0 OUTPUT pin 13 stv was b.0
TVSCL VAR PORTB.5 '0 OUTPUT pin 12 stv was b.5
SYNCH0 VAR PORTB.7 '1 'INPUT to pin 7 stvchip was b.2
'HEARTBEAT VAR PORTB.6 'OUTPUT 0 led was b.6
'---------------------------------------------------------------

'16f628a

' TVSDA VAR PORTB.1 '0 OUTPUT pin 11 stv
' CS0 VAR PORTB.0 '0 OUTPUT pin 13 stv
' TVSCL VAR PORTB.5 '0 OUTPUT pin 12 stv
' SYNCH0 VAR PORTB.2 '1 'INPUT to pin 7 stvchip
' HEARTBEAT VAR PORTB.6 'OUTPUT 0 led
'---------------------------------------------------------------

ZOOMREG CON %0000000011001100 ' 12 ZOOM REGISTER
COLREG CON %0000000011001101 ' 13 COLOUR REGISTER
CONREG CON %0000000011001110 ' 14 CONTROL REGISTER
POSREG CON %0000000011001111 ' 15 POSITION REGISTER
MODEREG CON %0000000011010000 ' 16 MODE REGISTER



ICOUNT VAR BYTE
BITCOUNTER VAR BYTE
WDATA VAR WORD
CHARCOUNTER VAR BYTE '
LINECOUNTER VAR BYTE '


STVCHAR VAR BYTE
ASCCHAR VAR BYTE
CHARS VAR BYTE
CHARS2 VAR BYTE
TEMP VAR BYTE
TEMP1 VAR BYTE
COUNTER VAR BYTE
PULSES VAR BYTE
CURRENTMODE0 VAR BYTE

'----------------------------------------------------------------
' TOPLEFT CON 0
' TOPMIDDLE CON 5
' TOPRIGHT CON 10
' BOTLEFT CON 2560 '10*256
' BOTMIDDLE CON 2565 '(10*256)+ 5
' BOTRIGHT CON 2570 '(10*256)+ 10
'----------------------------------------------------------------

DATA @0,"NTSC ",$FF,"NO SYNCHS RECEIVED",$FF



'----------------------------------------------------------------
'628
' TRISB=%10011100
TRISB = %10001111
CMCON=7
'----------------------------------------------------------------


PAUSE 500

' HIGH HEARTBEAT


GOSUB Init

PAUSE 500
GOSUB Init

CURRENTMODE0=255 ' FORCES TRYSYNCHS TO SET MODE FIRST TIME


Demo:

CHARCOUNTER = 0
LINECOUNTER = 0
' CURRENTMODE0 = 0 '0 = MIXED 1 = TEXT
gosub CLS
GOSUB TRYSYNCHS '==================================


TEMP = 0



LOOPER:
GOSUB HEADER ' LINE 3 RIGHT HAND SIDE TEST.
IF CURRENTMODE0=1 THEN
GOSUB NOVIDEO ' DISPLAYS NO VIDEO IF NO INCOMING SYNCHS
ENDIF


GOSUB TRYSYNCHS '===========================


' PAUSE 500 'I/2 SECOND DELAY
' TOGGLE HEARTBEAT ' LED
GOTO LOOPER 'DO IT FOREVER


DISPLAYCHAR:

WDATA = %0001011100000000 + STVCHAR
GOSUB SEND
RETURN
SETLINE:
WDATA = LINECOUNTER*256 + CHARCOUNTER
GOSUB Send 'position cursor
RETURN



WasteTime: ' WORKS WITH LESS NOPS



pauseus 20 ' was 20 nops

RETURN

StartCommunication:
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime

CS0 = 0 'LOW CS0

GOSUB WasteTime
TVSCL = 0 'LOW TVSCL
GOSUB WasteTime
RETURN

StopCommunication:
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
CS0 = 1 'HIGH CS0

GOSUB WasteTime
RETURN

SendOne:
TVSDA = 1 'HIGH TVSDA
GOSUB WasteTime
TVSCL = 0 'LOW TVSCL
GOSUB WasteTime
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
RETURN

SendZero:
TVSDA = 0 'LOW TVSDA
GOSUB WasteTime
TVSCL = 0 ' LOW TVSCL
GOSUB WasteTime
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
TVSDA = 1 'HIGH TVSDA
GOSUB WasteTime
RETURN

OutByte:
FOR BITCOUNTER = 1 TO 16
IF WDATA.15 = 1 THEN
GOSUB SendOne
ELSE
GOSUB SendZero
ENDIF
WDATA = WDATA << 1
NEXT BITCOUNTER
RETURN

Send:
GOSUB StartCommunication
GOSUB OutByte
GOSUB StopCommunication
RETURN

'-------------------------------------------------------------

Init: ' PAUSE 50 added - seems to improve reliability of init

TVSCL = 1 'HIGH TVSCL
TVSDA = 1 'HIGH TVSDA
CS0 = 1 'HIGH CS0

WDATA = $3000 '%110000 00000000
GOSUB Send ' Init STV5730
PAUSE 50
WDATA = $3000
GOSUB Send
PAUSE 50
WDATA = $00DB '%00000000 11011011
GOSUB Send
PAUSE 50
WDATA = $1000 '%00010000 00000000
GOSUB Send
PAUSE 50
'-------------------------------------------------------------
WDATA = %0000000011001100
GOSUB Send ' Init registers (point to register 12)
PAUSE 50
'-------------------------------------------------------------
WDATA = %0001000000000000 'NORMAL
' WDATA = %0001000011110000 '4 PIXELS HORIZ AND VERT
GOSUB Send ' Zoom ADDRESS 12
PAUSE 50
'-------------------------------------------------------------
WDATA = %0001001000000000

' WDATA = %0001001000000100
GOSUB Send ' Color ADDRESS 13
PAUSE 50
'--------------------------------------------------------


WDATA= %0001101011010100 'BIT 8 = 0 FOR NTSC



'CHANGE BIT 0 TO 1 FOR TEXT ONLY
GOSUB Send ' Control ADDRESS 14
'-------------------------------------------------------------
WDATA = %0001011111001111
GOSUB Send ' Position ADDRESS 15
'-------------------------------------------------------------


WDATA = %0001000000101110 '$183E BIT 11 CHANGED TO 0 M4 = 0
GOSUB Send ' Mode ADDRESS 16 %0001100000111110

'-------------------------------------------------------------

WDATA = $00C0 '%00000000 11000000
GOSUB Send ' Set row attributes

FOR ICOUNT = 0 TO 10
WDATA = $10C4 '%00010000 11000100
' WDATA =%0001000010000111
GOSUB Send
NEXT ICOUNT
RETURN

CLS:
'character=$0B 'SPACE
TEMP1=0 ' LINECOUNTER
TEMP =0 'CHARCOUNTER
loop2:

WDATA = 0 ' LINECOUNTER*256 + CHARCOUNTER ADDRESS
GOSUB Send


LOOP3: ' :CHARACTERS
WDATA = %0001011100001011 ' 1011 0BH SPACECHARACTER
GOSUB Send
TEMP = TEMP + 1
IF TEMP >= 28 THEN
TEMP = 0
TEMP1=TEMP1 + 1
ENDIF
IF TEMP1 >= 11 THEN SCREENBLANK

GOTO LOOP3

SCREENBLANK:
RETURN

GETSTVCHAR: 'CONVERT ASCII TO STV
STVCHAR =$7F ' FORCES CLOCK PICTURE IF ERROR
LOOKDOWN ASCCHAR,["0123456789- ABCDEFGHIJKLMNOPQRSTUVWXYZ:./'abcdefghijklmnopqrstuvwxyz"],STVCHAR
RETURN

HEADER:
LINECOUNTER=2 'SET START POSITION
CHARCOUNTER=23 'SET CURSOR POSITION
GOSUB SETLINE
FOR CHARS2=0 TO 4
READ CHARS2, ASCCHAR
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
NEXT
RETURN

NOVIDEO:
LINECOUNTER=5 'SET START POSITION
CHARCOUNTER=4 'SET CURSOR POSITION
GOSUB SETLINE
FOR CHARS2=6 TO 23 ' FROM EEPROM DATA
READ CHARS2, ASCCHAR
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
NEXT
RETURN

TRYSYNCHS:

PULSES=0

COUNT SYNCH0,4,PULSES '3MS SHOULD COUNT TO 2 OR 3
IF PULSES > 0 THEN MIXED0
FULL0:

IF CURRENTMODE0=1 THEN RETURN

WDATA= %0000000011001110 'CONTROL REGISTER
GOSUB SEND
WDATA= %0001101011010101 'NTSC



' WDATA= %0001101011010101 'NTSC BIT 8 = 0
'CHANGE BIT 0 TO 1 FOR TEXT ONLY OTIGINAL

' WDATA= %0001101111010100
'CHANGE BIT 0 TO 1 FOR TEXT ONLY
GOSUB SEND

STAYHERE02:

CURRENTMODE0=1
GOSUB CLS
GOBACK0:
RETURN


MIXED0:
IF CURRENTMODE0=0 THEN RETURN
WDATA= %0000000011001110 'CONTROL REGISTER
GOSUB SEND
WDATA= %0001100111010100 'ntsc



' WDATA= %0001101011010100 'NTSC BIT 8 = 0
GOSUB SEND

STAYHERE01:

CURRENTMODE0=0
GOSUB CLS
RETURN



HEX code for programmer compiled from above code




:100000006C28B400841780048413FA30A6000030F2
:10001000A7005120A00AA50AA201A30100083405E7
:10002000A600640000083405A7002606270534064C
:100030000319A20A0319A30A2708A600A403031997
:10004000A5030319A00B11282208672883161C1486
:100050001A0883169B0A6728A301A200FF30A20793
:10006000031CA307031C67280330A100E6303A20D5
:100070002E28A101FC3EA000A109031C4528FF3049
:100080000000A00703184028A0076400A10F3F2824
:1000900008000310A00DA10DFF3E031849282008F9
:1000A00067281030A800A101A001A70CA60C031C12
:1000B0005F282208A00723080318230FA107A10C1B
:1000C000A00CA50CA40CA80B5528240867288313A2
:1000D000031383126400080083168F308600831296
:1000E00007309F000130A300F4302D20DE200130C6
:1000F000A300F4302D20DE20FF30C200BE01C40179
:100100002C21CE21C701A12164004208013C031D1E
:100110008A28B721CE21832800304607BA0017303D
:100120000318013EBB00DA2008004408A600A7011E
:10013000A2010130A3005120B8002508B9003E08F3
:100140003807BA0039080318013EBB00DA2008005E
:100150001430392008008616A8200613A82086121D
:10016000A82008008616A8200617A8200800061652
:10017000A8208612A8208616A82008000612A8200B
:100180008612A8208616A8200616A820080001308E
:10019000BD00640011303D020318D9286400BB1F64
:1001A000D328B720D428BE200310BA0DBB0DBD0F35
:1001B000C9280800AB20C720B22008008616061602
:1001C0000617BA013030BB00DA2032302C20BA01D9
:1001D0003030BB00DA2032302C20DB30BA00BB01DB
:1001E000DA2032302C20BA011030BB00DA20323055
:1001F0002C20CC30BA00BB01DA2032302C20BA01DE
:100200001030BB00DA2032302C20BA011230BB0093
:10021000DA2032302C20D430BA001A30BB00DA2079
:10022000CF30BA001730BB00DA202E30BA001030C1
:10023000BB00DA20C030BA00BB01DA20C301640081
:100240000B30430203182B29C430BA001030BB0016
:10025000DA20C30F1F290800C801C701BA01BB017A
:10026000DA200B30BA001730BB00DA20C70A64006E
:100270001C304702031C3E29C701C80A64000B302A
:10028000480203184429312908007F30C600FF3096
:10029000A200A20A2208433C031CA02955213C02CB
:1002A000031D49292208C600A02901308A0022081E
:1002B0005C3E03188A0A82003034313432343334DD
:1002C0003434353436343734383439342D342034FA
:1002D000413442344334443445344634473448345A
:1002E00049344A344B344C344D344E344F3450340A
:1002F00051345234533454345534563457345834BA
:1003000059345A343A342E342F3427346134623419
:1003100063346434653466346734683469346A3409
:100320006B346C346D346E346F34703471347234B9
:1003300073347434753476347734783479347A3469
:1003400008000230C4001730BE009520C0016400D0
:10035000053040020318B629400883169B0083121B
:100360002620BC0045218C20C00FA729080005309D
:10037000C4000430BE0095200630C0006400183070
:1003800040020318CD29400883169B0083122620C3
:10039000BC0045218C20C00FBE290800C5010430D7
:1003A000A200A3010630840080300120C500640053
:1003B000013045020318EF2964004208013C031D87
:1003C000E2290800CE30BA00BB01DA20D530BA00ED
:1003D0001A30BB00DA200130C2002C210800640072
:1003E0004208003C031DF5290800CE30BA00BB01CD
:1003F000DA20D430BA001930BB00DA20C2012C2137
:020400000800F2
:02400E00663F0B
:104200004E005400530043002000FF004E004F00BA
:104210002000530059004E00430048005300200086
:104220005200450043004500490056004500440047
:02423000FF008D
:00000001FF




8441

Ramius
- 24th June 2017, 17:30
Hi Aerostar!
Thank you, Thank you, Thank you! I do not know how to save your hex code to a file? Second the statement "@ device PIC16f628a,HS_OSC,BOD_ON,MCLR_ON,PWRT_ON" does not allow me to compile the program, had to change it to a config. I am using Micro Code Studio Plus 5.0.0.5 PBPX 3.1.0.4 and MPLAB IDE V8.92. I did try 4 different 16F628A's and end up with the same results. I do have pin 4 of the 16F628A tied to +5v through a 4.7k resistor as i understand this to be the MCLR for the 16F628A. I believe our code is identical except for the config statement as I added the config to your code so it would compile. Not sure what else to change, maybe if you have time you can compile my version and see if it will work? I did order some more STV5730's which should be here any day now.



'************************************************* ***************
'* Name : STV-SYNCHS RELEASE *
'* Author : BOB LEGGETT *
'* Notice : Copyright (c) 2009 *
'* : All Rights Reserved *
'* Date : around 2009 or so rehashed now '17 *
'* Version : 1.0 *
'* Notes : VIDEO IDENT *
'* : *
'************************************************* ***************



' WORKS USES SYNC FOR SWITCHING BETWEEN MIXED AND FULL TEXT MODE
' GOING FROM VID IN TO TEXT AND BACK TO VID IN

' @ device PIC16f628a,HS_OSC,BOD_ON,MCLR_ON,PWRT_ON
#CONFIG
__config _HS_OSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
#ENDCONFIG


define OSC 20


'TV CHIP CONNECTIONS



'---------------------------------------------------------------
'16f628a ED definitions

TVSDA VAR PORTB.4 '0 OUTPUT pin 11 stv was b.1
CS0 VAR PORTB.6 '0 OUTPUT pin 13 stv was b.0
TVSCL VAR PORTB.5 '0 OUTPUT pin 12 stv was b.5
SYNCH0 VAR PORTB.7 '1 INPUT to pin 7 stvchip was b.2
'HEARTBEAT VAR PORTB.6 OUTPUT 0 led was b.6
'---------------------------------------------------------------

'16f628a

' TVSDA VAR PORTB.1 '0 OUTPUT pin 11 stv
' CS0 VAR PORTB.0 '0 OUTPUT pin 13 stv
' TVSCL VAR PORTB.5 '0 OUTPUT pin 12 stv
' SYNCH0 VAR PORTB.2 '1 INPUT to pin 7 stvchip
' HEARTBEAT VAR PORTB.6 ' OUTPUT 0 led
'---------------------------------------------------------------

ZOOMREG CON %0000000011001100 ' 12 ZOOM REGISTER
COLREG CON %0000000011001101 ' 13 COLOUR REGISTER
CONREG CON %0000000011001110 ' 14 CONTROL REGISTER
POSREG CON %0000000011001111 ' 15 POSITION REGISTER
MODEREG CON %0000000011010000 ' 16 MODE REGISTER



ICOUNT VAR BYTE
BITCOUNTER VAR BYTE
WDATA VAR WORD
CHARCOUNTER VAR BYTE '
LINECOUNTER VAR BYTE '


STVCHAR VAR BYTE
ASCCHAR VAR BYTE
CHARS VAR BYTE
CHARS2 VAR BYTE
TEMP VAR BYTE
TEMP1 VAR BYTE
COUNTER VAR BYTE
PULSES VAR BYTE
CURRENTMODE0 VAR BYTE

'----------------------------------------------------------------
' TOPLEFT CON 0
' TOPMIDDLE CON 5
' TOPRIGHT CON 10
' BOTLEFT CON 2560 '10*256
' BOTMIDDLE CON 2565 '(10*256)+ 5
' BOTRIGHT CON 2570 '(10*256)+ 10
'----------------------------------------------------------------

DATA @0,"NTSC ",$FF,"NO SYNCHS RECEIVED",$FF



'----------------------------------------------------------------
'628
' TRISB=%10011100
TRISB = %10001111
CMCON=7
'----------------------------------------------------------------


PAUSE 500

' HIGH HEARTBEAT


GOSUB Init

PAUSE 500
GOSUB Init

CURRENTMODE0=255 ' FORCES TRYSYNCHS TO SET MODE FIRST TIME


Demo:

CHARCOUNTER = 0
LINECOUNTER = 0
' CURRENTMODE0 = 0 '0 = MIXED 1 = TEXT
gosub CLS
GOSUB TRYSYNCHS '==================================


TEMP = 0



LOOPER:
GOSUB HEADER ' LINE 3 RIGHT HAND SIDE TEST.
IF CURRENTMODE0=1 THEN
GOSUB NOVIDEO ' DISPLAYS NO VIDEO IF NO INCOMING SYNCHS
ENDIF


GOSUB TRYSYNCHS '===========================


' PAUSE 500 'I/2 SECOND DELAY
' TOGGLE HEARTBEAT ' LED
GOTO LOOPER 'DO IT FOREVER


DISPLAYCHAR:

WDATA = %0001011100000000 + STVCHAR
GOSUB SEND
RETURN
SETLINE:
WDATA = LINECOUNTER*256 + CHARCOUNTER
GOSUB Send 'position cursor
RETURN



WasteTime: ' WORKS WITH LESS NOPS



pauseus 20 ' was 20 nops

RETURN

StartCommunication:
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime

CS0 = 0 'LOW CS0

GOSUB WasteTime
TVSCL = 0 'LOW TVSCL
GOSUB WasteTime
RETURN

StopCommunication:
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
CS0 = 1 'HIGH CS0

GOSUB WasteTime
RETURN

SendOne:
TVSDA = 1 'HIGH TVSDA
GOSUB WasteTime
TVSCL = 0 'LOW TVSCL
GOSUB WasteTime
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
RETURN

SendZero:
TVSDA = 0 'LOW TVSDA
GOSUB WasteTime
TVSCL = 0 ' LOW TVSCL
GOSUB WasteTime
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
TVSDA = 1 'HIGH TVSDA
GOSUB WasteTime
RETURN

OutByte:
FOR BITCOUNTER = 1 TO 16
IF WDATA.15 = 1 THEN
GOSUB SendOne
ELSE
GOSUB SendZero
ENDIF
WDATA = WDATA << 1
NEXT BITCOUNTER
RETURN

Send:
GOSUB StartCommunication
GOSUB OutByte
GOSUB StopCommunication
RETURN

'-------------------------------------------------------------

Init: ' PAUSE 50 added - seems to improve reliability of init

TVSCL = 1 'HIGH TVSCL
TVSDA = 1 'HIGH TVSDA
CS0 = 1 'HIGH CS0

WDATA = $3000 '%110000 00000000
GOSUB Send ' Init STV5730
PAUSE 50
WDATA = $3000
GOSUB Send
PAUSE 50
WDATA = $00DB '%00000000 11011011
GOSUB Send
PAUSE 50
WDATA = $1000 '%00010000 00000000
GOSUB Send
PAUSE 50
'-------------------------------------------------------------
WDATA = %0000000011001100
GOSUB Send ' Init registers (point to register 12)
PAUSE 50
'-------------------------------------------------------------
WDATA = %0001000000000000 'NORMAL
' WDATA = %0001000011110000 '4 PIXELS HORIZ AND VERT
GOSUB Send ' Zoom ADDRESS 12
PAUSE 50
'-------------------------------------------------------------
WDATA = %0001001000000000

' WDATA = %0001001000000100
GOSUB Send ' Color ADDRESS 13
PAUSE 50
'--------------------------------------------------------


WDATA= %0001101011010100 'BIT 8 = 0 FOR NTSC



'CHANGE BIT 0 TO 1 FOR TEXT ONLY
GOSUB Send ' Control ADDRESS 14
'-------------------------------------------------------------
WDATA = %0001011111001111
GOSUB Send ' Position ADDRESS 15
'-------------------------------------------------------------


WDATA = %0001000000101110 '$183E BIT 11 CHANGED TO 0 M4 = 0
GOSUB Send ' Mode ADDRESS 16 %0001100000111110

'-------------------------------------------------------------

WDATA = $00C0 '%00000000 11000000
GOSUB Send ' Set row attributes

FOR ICOUNT = 0 TO 10
WDATA = $10C4 '%00010000 11000100
' WDATA =%0001000010000111
GOSUB Send
NEXT ICOUNT
RETURN

CLS:
'character=$0B 'SPACE
TEMP1=0 ' LINECOUNTER
TEMP =0 'CHARCOUNTER
loop2:

WDATA = 0 ' LINECOUNTER*256 + CHARCOUNTER ADDRESS
GOSUB Send


LOOP3: ' :CHARACTERS
WDATA = %0001011100001011 ' 1011 0BH SPACECHARACTER
GOSUB Send
TEMP = TEMP + 1
IF TEMP >= 28 THEN
TEMP = 0
TEMP1=TEMP1 + 1
ENDIF
IF TEMP1 >= 11 THEN SCREENBLANK

GOTO LOOP3

SCREENBLANK:
RETURN

GETSTVCHAR: 'CONVERT ASCII TO STV
STVCHAR =$7F ' FORCES CLOCK PICTURE IF ERROR
LOOKDOWN ASCCHAR,["0123456789- ABCDEFGHIJKLMNOPQRSTUVWXYZ:./'abcdefghijklmnopqrstuvwxyz"],STVCHAR
RETURN

HEADER:
LINECOUNTER=2 'SET START POSITION
CHARCOUNTER=23 'SET CURSOR POSITION
GOSUB SETLINE
FOR CHARS2=0 TO 4
READ CHARS2, ASCCHAR
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
NEXT
RETURN

NOVIDEO:
LINECOUNTER=5 'SET START POSITION
CHARCOUNTER=4 'SET CURSOR POSITION
GOSUB SETLINE
FOR CHARS2=6 TO 23 ' FROM EEPROM DATA
READ CHARS2, ASCCHAR
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
NEXT
RETURN

TRYSYNCHS:

PULSES=0

COUNT SYNCH0,4,PULSES '3MS SHOULD COUNT TO 2 OR 3
IF PULSES > 0 THEN MIXED0
FULL0:

IF CURRENTMODE0=1 THEN RETURN

WDATA= %0000000011001110 'CONTROL REGISTER
GOSUB SEND
WDATA= %0001101011010101 'NTSC



' WDATA= %0001101011010101 'NTSC BIT 8 = 0
'CHANGE BIT 0 TO 1 FOR TEXT ONLY OTIGINAL

' WDATA= %0001101111010100
'CHANGE BIT 0 TO 1 FOR TEXT ONLY
GOSUB SEND

STAYHERE02:

CURRENTMODE0=1
GOSUB CLS
GOBACK0:
RETURN


MIXED0:
IF CURRENTMODE0=0 THEN RETURN
WDATA= %0000000011001110 'CONTROL REGISTER
GOSUB SEND
WDATA= %0001100111010100 'ntsc



' WDATA= %0001101011010100 'NTSC BIT 8 = 0
GOSUB SEND

STAYHERE01:

CURRENTMODE0=0
GOSUB CLS
RETURN


Many thanks, Ed

P.S. If you wish to e-mail me files my e-mail is [email protected]

aerostar
- 24th June 2017, 18:37
You use highlite text, copy and paste as you would in word processing.

To save the hex code ,put mouse at top left of hexcode, the pointer will change to something that looks like a capital I,the vertical part should just touch the left side of the colon on the top line, single left mouse click, use the slide bar on the right of the hex code to scroll down to the bottom of the code, move the mouse pounter to the last character, so the vertical part of the I just touches the right hand side of the F, hold the shift button down and then single left mouse click that will highlite the code, then Control C that will copy all the highlited text, now run notepad, right click on blank area and select paste, the hex code will appear, now save this as whatever name you wish with the extension as .hex. You can then load it into your programmer.

I will look at trying your code tomorrow sometime.

I would suggest you edit and mask your email as it will get picked up by the spam bots - write it as edcannady at earthlink dot net

Ramius
- 25th June 2017, 03:58
Hi Aerostar!
Your hex code works (sort of). If there is no video then I get a blue screen with "NTSC" and NO SYNCHS RECEIVED"! :D
If I input a video source then only the video input source displays with no text.

Thank you for the e-mail recommendation, I get a ton of spam as it is!

My code will not compile with the statement "@ device PIC16f628a,HS_OSC,BOD_ON,MCLR_ON,PWRT_ON"
The 16F628A data sheet shows they made changes from MCLR TO MCLRE, ETC.
I had to switch to #CONFIG and I believe it is completely wrong as the results when I change this cause things to go "spiritual" (technical term ;) ).

aerostar
- 26th June 2017, 09:02
Hi Aerostar!
Your hex code works (sort of). If there is no video then I get a blue screen with "NTSC" and NO SYNCHS RECEIVED"! :D
If I input a video source then only the video input source displays with no text.


My code will not compile with the statement "@ device PIC16f628a,HS_OSC,BOD_ON,MCLR_ON,PWRT_ON"
The 16F628A data sheet shows they made changes from MCLR TO MCLRE, ETC.
I had to switch to #CONFIG and I believe it is completely wrong as the results when I change this cause things to go "spiritual" (technical term ;) ).

I will try and find a NTSC source to check the operation, I did connect a Pal video source to see what would happen, and it showed a black and white picture with the text overlaid.

"@ device PIC16f628a,HS_OSC,BOD_ON,MCLR_ON,PWRT_ON" is for the earlier versions of PBP, before 3, I looked at the 16f628a .inc file (PBP260C) and it says mclr, if I compile with mclre it errors.

Further to follow in due time.

Ramius
- 26th June 2017, 12:31
Thank you! I really appreciate all that you are doing. If there is something I can do please ask.

Best, Ed

Ramius
- 27th June 2017, 12:49
Hi Aerostar!
Okay so the code works (sort of)! If I give the STV5730 an NTSC source I only get the video from the source. Remove the source and I get the Blue screen with the "NTSC No Synchs Received message"!
How can I get the text to overlay the incoming video?

Thanks, Ed

aerostar
- 28th June 2017, 06:53
Hi Aerostar!
Okay so the code works (sort of)! If I give the STV5730 an NTSC source I only get the video from the source. Remove the source and I get the Blue screen with the "NTSC No Synchs Received message"!
How can I get the text to overlay the incoming video?

Thanks, Ed

See post 31--- I am sorting out an NTSC source to test under your conditions !!!!!

aerostar
- 28th June 2017, 10:30
Here is code, hex file and other files made by PBP3 , Microchip assembler, tested working with my NTSC source.

I used a second STV NTSC board as the video source (top board in picture) , connected that output to the input of the original board board (bottom board in picture), and it switches back and forth OK.

Top BNC is video input, bottom BNC is video output on the boards. Micros are 628a pics

With no input to the bottom board, you see the NTSC. and the No synchs message, with NTSC input from the top board, bottom BNC, NTSC. is overlayed on the incoming video, my top board board puts out NTSC VIDEO SOURCE.

Compiled (with help of friend) PBP 3.1.0.1, mplab 8.92 MCS version 5.00.5 and programmed with pickit 2 v2.61 programmer. this I think matches your software setup - your programmer unknown.

84438444

Ramius
- 28th June 2017, 12:40
WOW! :eek: That really looks really great! :D Thank you for the files too! My programmer is a PICSTART PLUS and that should not make any difference. Two questions, how did you wire your STV5730A? Second question, have you tried to have the text be a color? Again, what a great job!!!

Ed :D

aerostar
- 28th June 2017, 13:33
WOW! :eek: That really looks really great! :D Thank you for the files too! My programmer is a PICSTART PLUS and that should not make any difference. Two questions, how did you wire your STV5730A? Second question, have you tried to have the text be a color? Again, what a great job!!!

Ed :D

And to prove it really does work - see below - wobbly camera as it was my phone and had to have the other hand to make the connection to the top board at the same time.


https://youtu.be/avboBHnFz5U

Part of the PCB lay out was on the net way back 2003 or earlier, done with the free version of Protel as was then, I modified it to fit what I wanted and had the boards made as it was a commercial job. The text was only used as white but should be able to change using the color register I think.

If I get chance I will see if I still have the board layout - it will take a day or more - have to dig in to old backups etc and when I get the time.

Ramius
- 28th June 2017, 21:42
It looks really great! :D Fantastic job! Just the schematic would be fine, just want to check the values of the components used for the STV5730A.

Best, Ed

aerostar
- 29th June 2017, 09:51
From the depths of the old files I found this -


8445

On the STV PDF, it shows Circuitry around pins 5 and 6 I incorporated this, but I see the schematic above does not, I think as long as you have a good smoothed 5 volt power supply with good decoupling caps, there should not be a problem. However he does not show decoupling caps on his 9-12V DC circuit, 100N/220N should be in parallel with his 47uF caps and be close to the regulator.

On my board R3 (3k3) not fitted, My board, and the program you have uses CSYNC to work out the switching of modes, from what I remember I found odd problems using the MUTE, but cannot remember exactly what ! I think it did not always change the level when it should have or took a while to change.

Different coloured characters, It is in
DISPLAYCHAR:

WDATA = %0001011100000000 + STVCHAR

Bits 10,9, and 8 internal ram buffer, page 7 of my PDF, according to the STV data control the colour of the character.

You will have to try that when you get your system running correctly

Ramius
- 29th June 2017, 12:33
Again my greatest thanks! I just received three new STV5730A's so I will build the boards with the same component values you are using. Again, Thank you!

aerostar
- 29th June 2017, 13:08
Out of interest what supplier are you using to get the chips and what price ?

The schematic is not mine - it was used as a guide, however the values of resistors etc are the same, and what is used in the STV pdf.

Ramius
- 30th June 2017, 18:45
Hi Aerostar!:D
Just wanted to update everyone on the progress! The schematic was a big help! I had used a different schematic and had character timing problems. One line would be shifted left and the next line was 1 pixel right! Now the text is perfect thanks to you! Again I appreciate everything you have done. You are the best!

Sincerely, Ed :D

Ramius
- 3rd July 2017, 12:54
Hi Aerostar!
For some reason, probably needing new glasses,;) I miss your question about where to buy and cost! Here is the link: https://www.utsource.net/search.aspx?keyWords=STV5730A&SchWay=1&page=1

Best, Ed

Ramius
- 10th July 2017, 01:37
Hi!
Not sure if anyone is still watching this thread and I would love to ask a few more questions if it would be okay?

Thanks, Ed

MikeGTN
- 11th July 2017, 13:24
Hi Ed,

Seems like you are making some progress on this project. I was tempted to purchase some chips from the supplier, but now think will wait a while longer to see how your results conclude. I was a little concerned given how long these devices have been EOL about them being actually genuine. So will be an interesting story to hear how you finally progress & about any discoveries you make along the way.

Certainly aerostar has proven the code for usage on the NTSC video standard with real life testing of his original prototype boards.

Mike.

aerostar
- 13th July 2017, 21:48
The chips as far as I know were never cloned, so I would say UTsource are genuine. It is a specialised IC and were used by cctv companies and video equipment manufacturers. In the UK they are still being used in the Amateur radio fraternity. It is a long time since EOL, but they are still very useful.

If you go here http://dunstabledownsradioclub.org and choose TV Streams, GB3TZ in beacon mode (when not being used) the display is done using the STV chip, controlled by a Pic micro - (done in assembler, not by me) , the Pic also controls the repeater logic.

My involvement in these chips - way back in 2003ish was to insert time overlay in cctv systems which did not have their own OSD, and using MSF or GPS to provide accurate time.

Ramius
- 14th July 2017, 02:54
Hi All!
When I purchased the chips the fact that they were offering large quantities at a discount suggested they were still being manufactured. Okay back to the code stuff. In the beginning of the code there are "con" statements and yet there does not seem to be any reference to these statements. Why are these statements part of the code? "NTSC." appears on the screen with or without a video reference. I wish to get to the point where I can place text such as STBRPM (Starboard RPM) and PORTRPM (Port RPM with a variable of 4 digits following the text while there is a video input signal from a camera. How can this be done? Maybe I could start with something simple such as moving the "NTSC." from the right side of the screen to the left? Again my greatest thanks!

Ed

aerostar
- 14th July 2017, 11:31
Some "Con" statements left over from debug etc code that was stripped out as I said somewhere earlier, and were also used as memory jogger.

NTSC. will appear as this program always sends on screen refresh regardless of whether there is video input or not, it is down to you what you wish to be displayed with or without incoming video, it was for video repeater ident.


This is the part you need to understand about placing text on screen

HEADER:
LINECOUNTER=2 'SET START POSITION ********* line 3 from top (0-2 = 3!)
CHARCOUNTER=23 'SET CURSOR POSITION***********Character position start 23rd from left
GOSUB SETLINE
FOR CHARS2=0 TO 4
READ CHARS2, ASCCHAR
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
NEXT
RETURN

NOVIDEO:
LINECOUNTER=5 'SET START POSITION
CHARCOUNTER=4 'SET CURSOR POSITION
GOSUB SETLINE
FOR CHARS2=6 TO 23 ' FROM EEPROM DATA
READ CHARS2, ASCCHAR
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
NEXT
RETURN

with regards to getting your RPMs on screen the DIG command would probably help,

so if you had a reading of 2400 as rpm in a word byte RPM, I THINK (following is UNTESTED)

ASCCHAR = RPM DIG 1
This gives a value of 2, and as it happens the character matrix in the chip will display 2 as if you look at the table the numbers come first

then
GOSUB DISPLAYCHAR

then

ASCCHAR = RPM DIG 2
This gives a value of 4

and so on to dig 4, you could make a loop to do this.

Not quite sure what happens if the value is below 1000, but you could easily check that prior to doing DIG 4 and put a blank there instead, skipping the DIG 4.

Ramius
- 14th July 2017, 17:09
Thank you and I am feeling incredibly stupid right now, even after 4 Excedrin's! I think I understand part of this, "RPM" is the variable where the RPM reading is stored? "DIG" is the number of digits to be displayed? So RPM DIG 4 would display 4 digits? Where do you inset the "ASCCHAR = RPM DIG 4? I think this line goes after "GOSUB SETLINE"? Then how do you display "RPM" in front of the reading? Please excuse what seems to be basic, simple questions and once I stop having brain craps things should get better!

Ed

aerostar
- 14th July 2017, 18:20
Thank you and I am feeling incredibly stupid right now, even after 4 Excedrin's! I think I understand part of this, "RPM" is the variable where the RPM reading is stored? "DIG" is the number of digits to be displayed? So RPM DIG 4 would display 4 digits? Where do you inset the "ASCCHAR = RPM DIG 4? I think this line goes after "GOSUB SETLINE"? Then how do you display "RPM" in front of the reading? Please excuse what seems to be basic, simple questions and once I stop having brain craps things should get better!

Ed

If I asked you what the 2nd digit was of 2400 (normal reading left to right) you would immediately tell me 4 - congratulations you have just done a DIG 2,

RPM is a variable name suggested where you would store the reading from whatever interface you have on the motors.


DIG X just gives you the value of the single digit starting from the left hand side.

so if as I said above your RPM was 2400

DIG 4 would return 0 ie the last digit of 2400.

DIG 2 would return 4 ie the second digit


You set the line where you want the data to be shown
set the cursor where you want the first character of your data to start



For "RPM" in front

ASCCHAR="R"
GOSUB GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR

repeat the above 3 lines for "P", "M" and " "


now use the RPM word variable where you have stored your reading (RPM for instance)

ASCCHAR = RPM DIG 1
This gives a value of 2, and as it happens the character matrix in the chip will display 2 as if you look at the table the numbers come first

then
GOSUB DISPLAYCHAR

then

ASCCHAR = RPM DIG 2
This gives a value of 4
GOSUB DISPLAYCHAR


ASCCHAR = RPM DIG 3
This gives a value of 0
GOSUB DISPLAYCHAR

ASCCHAR = RPM DIG 4
This gives a value of 0
GOSUB DISPLAYCHAR


so on the screen at the line you have selected starting at the position you have selected, you would have RPM 2400

Ramius
- 14th July 2017, 21:52
Hi!
My code does not work!!:confused: NTSC. no longer displays which is understandable. The code complies and when I run it nothing is displayed! Must have missed something basic?





'************************************************* ***************
'* Name : NTSC-1 *
'* Author : Ed Cannady *
'* Notice : Copyright (c) 2017 *
'* : All Rights Reserved *
'* Date : 06-30-17 *
'* Version : 1.0 *
'* Notes : VIDEO IDENT *
'* : WITH GREAT HELP FROM AEROSTAR *
'************************************************* ***************

' WORKS USES SYNC FOR SWITCHING BETWEEN MIXED AND FULL TEXT MODE
' GOING FROM VID IN TO TEXT AND BACK TO VID IN

#CONFIG

__config _HS_OSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF

#ENDCONFIG

define OSC 20

'---------------------------------------------------------------
'16f628a ED definitions

TVSDA VAR PORTB.4 '0 OUTPUT to pin 11 of stv chip
CS0 VAR PORTB.6 '0 OUTPUT to pin 13 of stv chip
TVSCL VAR PORTB.5 '0 OUTPUT to pin 12 of stv chip
SYNCH0 VAR PORTB.7 '1 INPUT to pin 7 of stv chip
'---------------------------------------------------------------

ZOOMREG CON %0000000011001100 ' 12 ZOOM REGISTER
COLREG CON %0000000011001101 ' 13 COLOUR REGISTER
CONREG CON %0000000011001110 ' 14 CONTROL REGISTER
POSREG CON %0000000011001111 ' 15 POSITION REGISTER
MODEREG CON %0000000011010000 ' 16 MODE REGISTER


ICOUNT VAR BYTE
BITCOUNTER VAR BYTE
WDATA VAR WORD
CHARCOUNTER VAR BYTE
LINECOUNTER VAR BYTE


STVCHAR VAR BYTE
ASCCHAR VAR BYTE
CHARS VAR BYTE
CHARS2 VAR BYTE
TEMP VAR BYTE
TEMP1 VAR BYTE
COUNTER VAR BYTE
PULSES VAR BYTE
CURRENTMODE0 VAR BYTE
PRPM VAR WORD

'----------------------------------------------------------------
' TOPLEFT CON 0
' TOPMIDDLE CON 5
' TOPRIGHT CON 10
' BOTLEFT CON 2560 '10*256
' BOTMIDDLE CON 2565 '(10*256)+ 5
' BOTRIGHT CON 2570 '(10*256)+ 10
'----------------------------------------------------------------

DATA @0,"NTSC.",$FF,"NO SYNCHS RECEIVED",$FF

TRISB = %10001111

'----------------------------------------------------------------

PAUSE 500

GOSUB Init

PAUSE 500
GOSUB Init

CURRENTMODE0=255 ' FORCES TRYSYNCHS TO SET MODE FIRST TIME


Demo:

CHARCOUNTER = 0
LINECOUNTER = 0
' CURRENTMODE0 = 0 '0 = MIXED 1 = TEXT
gosub CLS
GOSUB TRYSYNCHS '==================================


TEMP = 0



LOOPER:
PRPM = 6789
GOSUB HEADER ' LINE 3 RIGHT HAND SIDE TEST.
IF CURRENTMODE0=1 THEN
GOSUB NOVIDEO ' DISPLAYS NO VIDEO IF NO INCOMING SYNCHS
ENDIF


GOSUB TRYSYNCHS '===========================


' PAUSE 500 'I/2 SECOND DELAY
' TOGGLE HEARTBEAT ' LED
GOTO LOOPER 'DO IT FOREVER


DISPLAYCHAR:

WDATA = %0001010000000000 + STVCHAR

' 11 10 9 8 7654 3210
' WDATA = %0001 0 1 1 1 0000 0000 + STVCHAR

' bit 11 = character background 0 = disabled 1 = enabled

' bit 10 = red
' bit 09 = green
' bit 08 = blue

' 000 = black
' 001 = blue
' 010 = green
' 011 = cyan
' 100 = red
' 101 = magenta
' 110 = yellow
' 111 = white

' bit 7 = blink 1=enable 0=disable

GOSUB SEND
RETURN
SETLINE:
WDATA = LINECOUNTER*256 + CHARCOUNTER
GOSUB Send 'position cursor
RETURN



WasteTime: ' WORKS WITH LESS NOPS

pauseus 20 ' was 20 nops
RETURN

StartCommunication:
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime

CS0 = 0 'LOW CS0

GOSUB WasteTime
TVSCL = 0 'LOW TVSCL
GOSUB WasteTime
RETURN

StopCommunication:
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
CS0 = 1 'HIGH CS0

GOSUB WasteTime
RETURN

SendOne:
TVSDA = 1 'HIGH TVSDA
GOSUB WasteTime
TVSCL = 0 'LOW TVSCL
GOSUB WasteTime
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
RETURN

SendZero:
TVSDA = 0 'LOW TVSDA
GOSUB WasteTime
TVSCL = 0 ' LOW TVSCL
GOSUB WasteTime
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
TVSDA = 1 'HIGH TVSDA
GOSUB WasteTime
RETURN

OutByte:
FOR BITCOUNTER = 1 TO 16
IF WDATA.15 = 1 THEN
GOSUB SendOne
ELSE
GOSUB SendZero
ENDIF
WDATA = WDATA << 1
NEXT BITCOUNTER
RETURN

Send:
GOSUB StartCommunication
GOSUB OutByte
GOSUB StopCommunication
RETURN

'-------------------------------------------------------------

Init: ' PAUSE 50 added - seems to improve reliability of init

TVSCL = 1 'HIGH TVSCL
TVSDA = 1 'HIGH TVSDA
CS0 = 1 'HIGH CS0

WDATA = $3000 '%110000 00000000
GOSUB Send ' Init STV5730
PAUSE 50
WDATA = $3000
GOSUB Send
PAUSE 50
WDATA = $00DB '%00000000 11011011
GOSUB Send
PAUSE 50
WDATA = $1000 '%00010000 00000000
GOSUB Send
PAUSE 50
'-------------------------------------------------------------
WDATA = %0000000011001100
GOSUB Send ' Init registers (point to register 12)
PAUSE 50
'-------------------------------------------------------------
WDATA = %0001000000000000 'NORMAL
' WDATA = %0001000011110000 '4 PIXELS HORIZ AND VERT
GOSUB Send ' Zoom ADDRESS 12
PAUSE 50
'-------------------------------------------------------------
WDATA = %0001001000000000

' WDATA = %0001001000000100
GOSUB Send ' Color ADDRESS 13
PAUSE 50
'--------------------------------------------------------

WDATA= %0001101011010100
'CHANGE BIT 0 TO 1 FOR TEXT ONLY
GOSUB Send ' Control ADDRESS 14
'-------------------------------------------------------------
WDATA = %0001011111001111
GOSUB Send ' Position ADDRESS 15
'-------------------------------------------------------------


WDATA = %0001000100101110 '$183E BIT 11 CHANGED TO 0 M4 = 0

GOSUB Send ' Mode ADDRESS 16 %0001100000111110

'-------------------------------------------------------------

WDATA = $00C0 '%00000000 11000000
GOSUB Send ' Set row attributes

FOR ICOUNT = 0 TO 10
WDATA = $10C4 '%00010000 11000100
' WDATA =%0001000010000111
GOSUB Send
NEXT ICOUNT
RETURN

CLS:
'character=$0B 'SPACE
TEMP1=0 ' LINECOUNTER
TEMP =0 'CHARCOUNTER
loop2:

WDATA = 0 ' LINECOUNTER*256 + CHARCOUNTER ADDRESS
GOSUB Send


LOOP3: ' :CHARACTERS
WDATA = %0001011100001011 ' 1011 0BH SPACECHARACTER
GOSUB Send
TEMP = TEMP + 1
IF TEMP >= 28 THEN
TEMP = 0
TEMP1=TEMP1 + 1
ENDIF
IF TEMP1 >= 11 THEN SCREENBLANK

GOTO LOOP3

SCREENBLANK:
RETURN

GETSTVCHAR: ' CONVERT ASCII TO STV
STVCHAR =$7F ' FORCES CLOCK PICTURE IF ERROR
LOOKDOWN ASCCHAR,["0123456789- ABCDEFGHIJKLMNOPQRSTUVWXYZ:./'abcdefghijklmnopqrstuvwxyz"],STVCHAR
RETURN

HEADER:
LINECOUNTER=12 'SET START POSITION
CHARCOUNTER=1 'SET CURSOR POSITION
GOSUB SETLINE
' FOR CHARS2=0 TO 4
' READ CHARS2, ASCCHAR
ASCCHAR = "P"
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
ASCCHAR = "R"
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
ASCCHAR = "P"
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
ASCCHAR = "M"
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
ASCCHAR = PRPM DIG 1
GOSUB DISPLAYCHAR
ASCCHAR = PRPM DIG 2
GOSUB DISPLAYCHAR
ASCCHAR = PRPM DIG 3
GOSUB DISPLAYCHAR
ASCCHAR = PRPM DIG 4
GOSUB DISPLAYCHAR
' gosub GETSTVCHAR 'CONVERT ASCII TO STV
' GOSUB DISPLAYCHAR
' NEXT
RETURN

NOVIDEO:
LINECOUNTER=5 ' SET START POSITION
CHARCOUNTER=4 ' SET CURSOR POSITION
GOSUB SETLINE
FOR CHARS2=6 TO 23 ' FROM EEPROM DATA
READ CHARS2, ASCCHAR
gosub GETSTVCHAR ' CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
NEXT
RETURN

TRYSYNCHS:

PULSES=0

COUNT SYNCH0,4,PULSES' 3MS SHOULD COUNT TO 2 OR 3
IF PULSES > 0 THEN MIXED0

FULL0:

IF CURRENTMODE0=1 THEN RETURN

WDATA= %0000000011001110'CONTROL REGISTER
GOSUB SEND
WDATA= %0001101011010101
' CHANGE BIT 0 TO 1 FOR TEXT ONLY ORIGINAL

' WDATA= %0001101111010100
' CHANGE BIT 0 TO 1 FOR TEXT ONLY
GOSUB SEND

STAYHERE02:

CURRENTMODE0=1
GOSUB CLS
GOBACK0:
RETURN


MIXED0:
IF CURRENTMODE0=0 THEN RETURN
WDATA= %0000000011001110 ' CONTROL REGISTER
GOSUB SEND
WDATA= %0001101011010100
GOSUB SEND

STAYHERE01:

CURRENTMODE0=0
GOSUB CLS
RETURN

aerostar
- 15th July 2017, 13:33
Some booboos from both of us !

The DIG operation I got reversed, DIG 0 gives the units, DIG 1 the tens, and so on, the example I found on how it worked was ambiguous and I did say it was all untested in post 48.


To get it on the screen the variable was wrong it needed to be changed from ASCCHAR to STVCHAR, but only for DIG use.

HEADER:
LINECOUNTER=12 'SET START POSITION

There is no line 12 ! check the STV spec it has 11 rows so valid would be 0 - 10.

I have put back the "NTSC" as that should always work, if what you have done after does not show but NTSC does then the problem must be in the new code addition.

I found one wdata that had a bit incorrect and have corrected those, easily done if the codestudio cursor is in the wrong place and you type something.

I would suggest small changes to the code, try it, if it works fine go on to next changes. Also perhaps save each version as you go with a number in the file name so you can easily go back to the last working.


Base colour and text is back to white on blue as it was a setting I knew that worked.

Try the enclosed hex file generated from Your post with corrections as above, files called NTSC-RPM. Works fine on my test boards.

Ramius
- 15th July 2017, 16:14
Again my greatest thanks! Two confusions, first the NTSC. only works with no video in and second the PRPM 6789 only displays with no video input!? I thought the "NOVIDEO" subroutine meant it was for when there is no video input?

aerostar
- 15th July 2017, 18:25
With no incoming video you should have the NTSC the RPM and the NO SYNCHS DETECTED.

With a video signal coming in you should have NTSC and the RPM only on the screen and overlaying the incoming video picture.

I had reconverted by boards back to PAL, but have just changed just 1 back to NTSC and was using a PAL input for an incoming signal for test input.

I have got hold of a Raspberry PI which can be set to output NTSC so will try that some time tomorrow to see if it works as it should.

I wonder if you have your board correctly wired especially vin to vout pin 1 and 28 and no connection on vout2 pin 26, pins 20 to 23 grounded, pin 24 to 25 connected

Ramius
- 15th July 2017, 20:55
I believe everything is wired correctly. Yes pin 1 to 28 is connected. Pin 26 (Vout2) goes through a 3.3k resistor per the schematic and removing the resistor does not make a difference. Yes 20-23 are grounded. Before the software changes, NTSC. appeared both with video in and no video in. No video in will display the "No Synchs received" message with NTSC. and the PRPM 6789 message. Now with video in nothing is displayed almost as if our added code is in the wrong subroutine section?

Ramius
- 16th July 2017, 00:50
Hi!
I took a previous version and inserted the additional code and it worked sort of! The PRPM now appears in both the mode with a video input and without a video input! You wrote "I found one wdata that had a bit incorrect and have corrected those, easily done if the codestudio cursor is in the wrong place and you type something." Not sure which or where so maybe this was the cause? There is something else I cannot seem to change and that is the size of the characters! You can see in the code I changed the zoom register to all zeros which should make the characters the smallest possible, however any line number greater than line 8 is off the screen! Is there more than one register I need to change?

Thanks, Ed

P.S. attached is the code without the wdata bit change.

aerostar
- 16th July 2017, 11:12
Looks like we both doing the same thing, attached is my corrected version

I have tested this with NTSC output from RPi and it switches and displays correctly.

I have moved the text, also the RPM and NTSC so that it only appears when there is incoming video.

Regarding the text size I think you will have to play with the POSITION REGISTER - never tried that but that should do something. The STV data sheet does not give much idea as to what that does !

Use my hex file and see if it works on yours.

Should have changed the file name - memory lapse.

aerostar
- 16th July 2017, 12:05
I had a quick look at the Position Register and put this in

WDATA = %0001001000001111 '%0001 011111 001111
GOSUB Send ' Position ADDRESS 15

It moved the lines up and I could get line 9 showing - still missing line 10 at the moment.

Looks like Row Attributes may also be involved.

Will have to ask my friend who did the assembler version if he did anything to Row Attributes.

Ramius
- 17th July 2017, 01:18
Hi Aerostar!
I had thought that this was the character size:

WDATA = %0001000011110000 '4 PIXELS HORIZ AND VERT !
GOSUB Send ' Zoom ADDRESS 12

So I changed it to: WDATA = %0001000000000000 and it made no difference in the text size!

I would also be curious if your setup displays actual red characters as mine seems like a light pink.

Here is a picture of my board;)

Best, Ed

8451

aerostar
- 17th July 2017, 12:18
Actually the zoom was already set at minimum.

Not played with colour oops sorry color!! but Never Twice Same Color sets have a HUE/TINT control that you can alter on the screen.

I now have worked out getting all lines on screen, it is combined with position and line characteristics. Removed the border area around the characters

Here are the values I have used to get the attached picture.

WDATA Values to be changed to values below

In init routine

'-------------------------------------------------------------
WDATA = %0001001100001111 ' was %0001 011111 001111
GOSUB Send ' Position ADDRESS 15 *****
'-------------------------------------------------------------

and in this

FOR ICOUNT = 0 TO 10
WDATA = %0001000010000001 '<<<<<$10c4 originally
' WDATA =%0001000010000111
GOSUB Send
NEXT ICOUNT

that should! sort the screen out.

8452

Quick and dirty code to do screen fill as a subroutine - modified CLS routine

Run it with no external video input

This is where I put the call, once it has done the Xs it will not go further remeber to comment out GOSUB HEADER.




LOOPER:
'GOSUB HEADER ' LINE 3 RIGHT HAND SIDE TEST.
GOSUB FILLSCREEN
STOPHERE:
GOTO STOPHERE


I put this at the very bottom of current code.



'----------------------debug fills screen with X------------------

FILLSCREEN:
'character=$0B 'SPACE
TEMP1=0 ' LINECOUNTER
TEMP =0 'CHARCOUNTER
loop2a:

WDATA = 0 ' LINECOUNTER*256 + CHARCOUNTER ADDRESS
GOSUB Send


LOOP3a: ' :CHARACTERS 100011
WDATA = %0001011100100011 ' X CHARACTER
GOSUB Send
TEMP = TEMP + 1
IF TEMP >= 28 THEN
TEMP = 0
TEMP1=TEMP1 + 1
ENDIF
IF TEMP1 >= 11 THEN SCREENBLANKA

GOTO LOOP3A

SCREENBLANKA:
RETURN

aerostar
- 18th July 2017, 10:48
Had a play with colors -I found that reducing the drive in the MODE REGISTER, BIT M5, from 6dB to 0dB improved the colours, so M5 needs to be a 0, this will depend on how good the monitor is..



If you mofify the fillscreen to the following you should get lines of ifferent colors.


FILLSCREEN:
'character=$0B 'SPACE
TEMP1=0 ' LINECOUNTER
TEMP =0 'CHARCOUNTER
loop2a:

WDATA = 0 ' LINECOUNTER*256 + CHARCOUNTER ADDRESS
GOSUB Send


LOOP3a: ' :CHARACTERS 100011
WDATA = %0001011100100011 ' X CHARACTER
' WDATA = %0001011101110111
' if temp1 =0 then WDATA = %0001011101110111
if temp1 =1 then WDATA = %0001000001100011
if temp1 =2 then WDATA = %0001000101100011
if temp1 =3 then WDATA = %0001001001100011
if temp1 =4 then WDATA = %0001001101100011
if temp1 =5 then WDATA = %0001010001100011
if temp1 =6 then WDATA = %0001010101100011
if temp1 =7 then WDATA = %0001011001100011
if temp1 >=8 then WDATA = %0001011101100011

GOSUB Send
TEMP = TEMP + 1
IF TEMP >= 28 THEN
TEMP = 0
TEMP1=TEMP1 + 1
ENDIF
IF TEMP1 >= 11 THEN SCREENBLANKA

GOTO LOOP3A

SCREENBLANKA:
RETURN

Ramius
- 18th July 2017, 12:50
Wow! This is really so great! Thank you! I will try the above code just as soon as possible. I loved your screen full of "X's"! If I understand things correctly the text is as small as it can be? FYI, I work at Fox Television so a high quality professional monitor is not difficult to bring home. Did you like how I built the board with the chip? This display is something I have been dreaming about for several years now and it is so wonderful to finally see some light at the end of the tunnel! I also believe the research and development is a major contribution for all others!

Best, Ed

aerostar
- 18th July 2017, 20:56
Board looks great - There is still a demand for analogue OSD despite all the digital stuff around. The chips were hard to find after they had been discontinued, but your find of supplier seems to have lots still, price is good, Ebay prices .... silly.

What are you going to this it for ?, I am guessing at RC aeroplane or boat, video from it and motor speed from port and starboard propulsion units.

Ramius
- 18th July 2017, 21:36
Yes, you are right on! I have an RC submarine called a Typhoon just like the one in my avatar. My first pic project was an electronic compass as you cannot use GPS underwater. A representative from China was going to buy compasses from me and said my compass was too precision as it is accurate to 1/10 of one degree. They only wanted to pay for 1/2 of one degree accuracy. At one point it seemed they only wanted the design and software so I published the information thus putting it in the public domain. The sub has twin drive motors with temperature sensors mounted on the. There is also a roll and pitch sensor, angle sensors on the bow planes, stern planes and rudder. A sensor for speed and another for depth. There is a sensor for battery voltage and current draw. A laser pointer has been added to the "sail" for targeting. The periscope is 3 mm in diameter and about 2" long with a first surface mirror at the top sending picture down the tube through some acromat lenses then a dove prism lens to reverse the image left to right to avoid using a second mirror. Below the dove prism lens is a "snake camera" which is 3/4" square pointed up the periscope. Since it is a small size it is able to pan left and right. One of the larger challenges was being able to transmit video from underwater. With a "strange" antenna configuration video could be transmitted from a depth of 1 meter, possibly more as my Jacuzzi is only 1 meter deep. There are also torpedoes and missiles fueled by compressed air. Others had used Estes rocket motors until one guy fired a missile from his swimming pool, it broke surface tension, make a left turn, cleared the fence, when through a screened in patio, and set fire to a couch that his neighbor was taking a nap on! Since this, we have all gone to compress air. My torpedoes have an optional nose cone made from a foam paint brush soaked in water color the dried. When these torpedoes are fired they leave a small orange trail and a large orange dot on whatever it hits (like duck butts!) So there are a lot of features and sensors that would be great to display the readings of. Okay, that's the basics.

Best, Ed

aerostar
- 19th July 2017, 09:27
Must admit, I did not know about RC Subs, sounds great. Loved the bit about the guy and his rocket and neighbour !

Ramius
- 19th July 2017, 12:50
Glad you liked the story! Estes rocket motors generate their own oxygen therefore if you seal the nichrome with wax to make it waterproof you can fire the missile underwater! The wire does melt so you need a new wire for each firing. Some guys have even built exploding torpedoes which will actually sink plastic model surface ships or Skeedo Barbies! Lol Probably a silly question and I tried your color code and ended up with the first row of "X,s" and the remaining rows of just squares (no X's). Any idea what I could have done wrong?

Thanks, Ed

aerostar
- 19th July 2017, 15:38
Do not think you have done anything wrong. Have a look at the characters in the data sheet - 63H is 1100011
WDATA = %0001000001100011 is what I used, so change it to anything you want.

Try 77H 1110111 also change the page background back to blue if you have changed it - It seems that NTSC/STV is finicky with colours of characters and page background also play with brightness/contrast/colour/tint. I had similar problem until played with the monitor controls and characters.
change this line
if temp1 >=8
to

if temp1 =8 then WDATA = %0001011101100011

then add extra line

if temp1 >=9 then WDATA = %0001011100100011

This will/should give Xs on line 9

Untested but should! work

Ramius
- 20th July 2017, 02:08
Yes you are right! What I did wrong was try it with a video input signal! When you wrote "Blue Background" that was the key to not use a video input source. A video input source gives the rectangles in white only! Do you know if it can work with a video in source? Also how do I play with lines 6 and 7 to try and get a red red and not pink?

Thanks, Ed

aerostar
- 20th July 2017, 11:36
Data sheet says....

Mixed mode : the device is line locked to the
incoming CVBS signal. The text is superimposed
over the CVBS input either in B&W or translucent.
It may also be superimposed in color by using the
R/G/B outputs.

As it stands it switches to white characters on the incoming video.

I have not got a good red out of it, by playing with tint/color/contrast and brightness. If you did manage to get a decent red, that of course would impact on the color of the incoming video signals.

A black background MAY look better instead of blue, - the eye/brain can do funny things with colors.

Ramius
- 20th July 2017, 14:15
Thank you and does what you wrote mean we cannot have color characters over incoming video? Translucent should be fine if it has color.

aerostar
- 21st July 2017, 06:49
As far as I understand that data sheet statement, and of course I may be wrong, no colors over incoming video as well translucent unless you use RGB.

Never tried this, plain white was fine for what I used the chip for.

Ramius
- 21st July 2017, 12:28
That seems kind of strange to me. Any ideas as to how we can test this? Maybe something simple like assigning a color to "NTSC"?

aerostar
- 22nd July 2017, 09:05
I have looked at the BOB4 from decade.net and it looks like their version only does white text on incoming video.

http://www.decadenet.com/bob4/bob4.html

I believe the STV chip was really designed for Menu setups on televisions etc, prior to digital sets, and does not to put color text overlays in incoming video, other chip maker versions also no colour, 1990-2000ish did the same, Maxim, Sanyo.

With digital sets it is now incorporated in a graphics chip onboard.


This is where you can change the character color, it will affect all characters using this routine, text and overlay.

DISPLAYCHAR:

WDATA = %0001010000000000 + STVCHAR

' 11 10 9 8 7654 3210
' WDATA = %0001 0 1 1 1 0000 0000 + STVCHAR

' bit 11 = character background 0 = disabled 1 = enabled

' bit 10 = red
' bit 09 = green
' bit 08 = blue

' 000 = black
' 001 = blue
' 010 = green
' 011 = cyan
' 100 = red
' 101 = magenta
' 110 = yellow
' 111 = white

Ramius
- 22nd July 2017, 12:36
Again my biggest thanks. I will play with it as time permits. Yes I had looked at the BOB4 sometime ago and it was only white from what I remember.
Eagle Tree ( http://www.eagletreesystems.com/index.php?route=product/product&product_id=136) does color text over video, however they would not share any information to customize their product for other purposes such as a sub. This is why I went back to the STV5730. I spent many hours and days searching for a chip to use with no success. Logically speaking, if you can add color text to a fixed color background then you had to generate the background color as well as the color text and "mix" them to produce video. RGB is kind of a strange animal as it can be RGB video and a separate sync or RGB with sync for each color (R-G-B). Maybe I was searching using the wrong search words and missed finding other chips?

Ramius
- 28th August 2017, 01:42
Hi Aerostar!
Somehow I screwed up my working file and now I have rows 1-9 as white squares while rows 10 and 11 are X's! I have done something stupid just not sure what after several days of trying!




'************************************************* ***************
'* Name : NTSC -RPM-V2 *
'* Author : Ed Cannady *
'* Notice : Copyright (c) 2017 *
'* : All Rights Reserved *
'* Date : 06-30-17 *
'* Version : 1.0 *
'* Notes : VIDEO IDENT *
'* : WITH GREAT HELP FROM AEROSTAR *
'************************************************* ***************

' WORKS USES SYNC FOR SWITCHING BETWEEN MIXED AND FULL TEXT MODE
' GOING FROM VID IN TO TEXT AND BACK TO VID IN

#CONFIG

__config _HS_OSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF

#ENDCONFIG

'@ device PIC16F628A,HS_OSC,BOD_ON,MCLR_ON,PWRT_ON 'AEROSTAR SET UP

define OSC 20

'---------------------------------------------------------------
'16f628a ED definitions

TVSDA VAR PORTB.4 '0 OUTPUT to pin 11 of stv chip
CS0 VAR PORTB.6 '0 OUTPUT to pin 13 of stv chip
TVSCL VAR PORTB.5 '0 OUTPUT to pin 12 of stv chip
SYNCH0 VAR PORTB.7 '1 INPUT to pin 7 of stv chip
'---------------------------------------------------------------

ZOOMREG CON %0000000011001100 ' 12 ZOOM REGISTER
COLREG CON %0000000011001101 ' 13 COLOUR REGISTER
CONREG CON %0000000011001110 ' 14 CONTROL REGISTER
POSREG CON %0000000011001111 ' 15 POSITION REGISTER
MODEREG CON %0000000011010000 ' 16 MODE REGISTER


ICOUNT VAR BYTE
BITCOUNTER VAR BYTE
WDATA VAR WORD
CHARCOUNTER VAR BYTE
LINECOUNTER VAR BYTE


STVCHAR VAR BYTE
ASCCHAR VAR BYTE
CHARS VAR BYTE
CHARS2 VAR BYTE
TEMP VAR BYTE
TEMP1 VAR BYTE
COUNTER VAR BYTE
PULSES VAR BYTE
CURRENTMODE0 VAR BYTE
PRPM VAR WORD


'----------------------------------------------------------------
' TOPLEFT CON 0
' TOPMIDDLE CON 5
' TOPRIGHT CON 10
' BOTLEFT CON 2560 '10*256
' BOTMIDDLE CON 2565 '(10*256)+ 5
' BOTRIGHT CON 2570 '(10*256)+ 10
'----------------------------------------------------------------

DATA @0,"NTSC.",$FF,"NO SYNCHS RECEIVED",$FF

TRISB = %10001111

'----------------------------------------------------------------

PAUSE 500



GOSUB Init


PAUSE 500
GOSUB Init

CURRENTMODE0=255 ' FORCES TRYSYNCHS TO SET MODE FIRST TIME


Demo:

CHARCOUNTER = 0
LINECOUNTER = 0
' CURRENTMODE0 = 0 '0 = MIXED 1 = TEXT
gosub CLS
GOSUB TRYSYNCHS '==================================


TEMP = 0



LOOPER:
GOSUB HEADER ' LINE 3 RIGHT HAND SIDE TEST.
GOSUB FILLSCREEN
STOPHERE:
GOTO STOPHERE
' PRPM = 6789
' IF CURRENTMODE0=0 THEN ' ONLY WHEN INCOMING VIDEO SIGNAL
' GOSUB HEADER ' LINE 3 RIGHT HAND SIDE TEST.
' ENDIF
' IF CURRENTMODE0=1 THEN
' GOSUB NOVIDEO ' DISPLAYS NO VIDEO IF NO INCOMING SYNCHS
' ENDIF


GOSUB TRYSYNCHS '===========================


' PAUSE 500 'I/2 SECOND DELAY
' TOGGLE HEARTBEAT ' LED
GOTO LOOPER 'DO IT FOREVER


DISPLAYCHAR:

WDATA = %0001011100000000 + STVCHAR

' 11 10 9 8 7654 3210
' WDATA = %0001 0 1 1 1 0000 0000 + STVCHAR

' bit 11 = character background 0 = disabled 1 = enabled

' bit 10 = red
' bit 09 = green
' bit 08 = blue

' 000 = black
' 001 = blue
' 010 = green
' 011 = cyan
' 100 = red
' 101 = magenta
' 110 = yellow
' 111 = white

' bit 7 = blink 1=enable 0=disable

GOSUB SEND
RETURN
SETLINE:
WDATA = LINECOUNTER*256 + CHARCOUNTER
GOSUB Send 'position cursor
RETURN



WasteTime: ' WORKS WITH LESS NOPS

pauseus 20 ' was 20 nops
RETURN

StartCommunication:
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime

CS0 = 0 'LOW CS0

GOSUB WasteTime
TVSCL = 0 'LOW TVSCL
GOSUB WasteTime
RETURN

StopCommunication:
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
CS0 = 1 'HIGH CS0

GOSUB WasteTime
RETURN

SendOne:
TVSDA = 1 'HIGH TVSDA
GOSUB WasteTime
TVSCL = 0 'LOW TVSCL
GOSUB WasteTime
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
RETURN

SendZero:
TVSDA = 0 'LOW TVSDA
GOSUB WasteTime
TVSCL = 0 ' LOW TVSCL
GOSUB WasteTime
TVSCL = 1 'HIGH TVSCL
GOSUB WasteTime
TVSDA = 1 'HIGH TVSDA
GOSUB WasteTime
RETURN

OutByte:
FOR BITCOUNTER = 1 TO 16
IF WDATA.15 = 1 THEN
GOSUB SendOne
ELSE
GOSUB SendZero
ENDIF
WDATA = WDATA << 1
NEXT BITCOUNTER
RETURN

Send:
GOSUB StartCommunication
GOSUB OutByte
GOSUB StopCommunication
RETURN

'-------------------------------------------------------------


Init: ' PAUSE 50 added - seems to improve reliability of init

TVSCL = 1 'HIGH TVSCL
TVSDA = 1 'HIGH TVSDA
CS0 = 1 'HIGH CS0

WDATA = $3000 '%110000 00000000
GOSUB Send ' Init STV5730
PAUSE 50
WDATA = $3000
GOSUB Send
PAUSE 50
WDATA = $00DB '%00000000 11011011
GOSUB Send
PAUSE 50
WDATA = $1000 '%00010000 00000000
GOSUB Send
PAUSE 50
'-------------------------------------------------------------
WDATA = %0000000011001100
GOSUB Send ' Init registers (point to register 12)
PAUSE 50
'-------------------------------------------------------------
WDATA = %0001000000000000 'NORMAL
' WDATA = %0001000011110000 '4 PIXELS HORIZ AND VERT
GOSUB Send ' Zoom ADDRESS 12
PAUSE 50
'-------------------------------------------------------------
WDATA = %0001001000000000

' WDATA = %0001001000000100
GOSUB Send ' Color ADDRESS 13
PAUSE 50
'--------------------------------------------------------

WDATA= %0001101011010100
'CHANGE BIT 0 TO 1 FOR TEXT ONLY
GOSUB Send ' Control ADDRESS 14
'-------------------------------------------------------------
WDATA = %0001001100001111
' was WDATA = %0001 0111 1100 1111
GOSUB Send ' Position ADDRESS 15
'-------------------------------------------------------------


WDATA = %0001000100101110 '$183E BIT 11 CHANGED TO 0 M4 = 0

GOSUB Send ' Mode ADDRESS 16 %0001100000111110

'-------------------------------------------------------------

WDATA = $00C0 '%00000000 11000000
GOSUB Send ' Set row attributes

FOR ICOUNT = 0 TO 10
WDATA = %0001000010000001 '%00010000 11000100 was $10C4
' WDATA =%0001000010000111
GOSUB Send
NEXT ICOUNT
RETURN

CLS:
'character=$0B 'SPACE
TEMP1=0 ' LINECOUNTER
TEMP =0 'CHARCOUNTER
loop2:

WDATA = 0 ' LINECOUNTER*256 + CHARCOUNTER ADDRESS
GOSUB Send


LOOP3: ' :CHARACTERS
WDATA = %0001011100001011 ' 1011 0BH SPACECHARACTER
GOSUB Send
TEMP = TEMP + 1
IF TEMP >= 28 THEN
TEMP = 0
TEMP1=TEMP1 + 1
ENDIF
IF TEMP1 >= 11 THEN SCREENBLANK

GOTO LOOP3

SCREENBLANK:
RETURN

GETSTVCHAR: 'CONVERT ASCII TO STV
STVCHAR =$7F ' FORCES CLOCK PICTURE IF ERROR
LOOKDOWN ASCCHAR,["0123456789- ABCDEFGHIJKLMNOPQRSTUVWXYZ:./'abcdefghijklmnopqrstuvwxyz"],STVCHAR
RETURN

HEADER:
LINECOUNTER=0 'SET START POSITION
CHARCOUNTER=1 'SET CURSOR POSITION
GOSUB SETLINE
FOR CHARS2=0 TO 4
READ CHARS2, ASCCHAR
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
NEXT

LINECOUNTER=10 'SET START POSITION
CHARCOUNTER=1 'SET CURSOR POSITION
GOSUB SETLINE

ASCCHAR = "P"
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
ASCCHAR = "R"
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
ASCCHAR = "P"
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
ASCCHAR = "M"
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
ASCCHAR = " "
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR

STVCHAR = PRPM DIG 3 '****** DIG VALUES ONLY
GOSUB DISPLAYCHAR 'NEEDS TO BE STVCHAR !!
STVCHAR = PRPM DIG 2
GOSUB DISPLAYCHAR
STVCHAR = PRPM DIG 1
GOSUB DISPLAYCHAR
STVCHAR = PRPM DIG 0
GOSUB DISPLAYCHAR

RETURN

NOVIDEO:
LINECOUNTER=5 'SET START POSITION
CHARCOUNTER=4 'SET CURSOR POSITION
GOSUB SETLINE
FOR CHARS2=6 TO 23 ' FROM EEPROM DATA
READ CHARS2, ASCCHAR
gosub GETSTVCHAR 'CONVERT ASCII TO STV
GOSUB DISPLAYCHAR
NEXT
RETURN

TRYSYNCHS:

PULSES=0

COUNT SYNCH0,4,PULSES '3MS SHOULD COUNT TO 2 OR 3
IF PULSES > 0 THEN MIXED0
FULL0:

IF CURRENTMODE0=1 THEN RETURN

WDATA= %0000000011001110 'CONTROL REGISTER
GOSUB SEND
WDATA= %0001101011010101
'CHANGE BIT 0 TO 1 FOR TEXT ONLY OTIGINAL

' WDATA= %0001101111010100
'CHANGE BIT 0 TO 1 FOR TEXT ONLY
GOSUB SEND

STAYHERE02:

CURRENTMODE0=1
GOSUB CLS
GOBACK0:
RETURN


MIXED0:
IF CURRENTMODE0=0 THEN RETURN
WDATA= %0000000011001110 'CONTROL REGISTER
GOSUB SEND
WDATA= %0001101011010100
GOSUB SEND

STAYHERE01:

CURRENTMODE0=0
GOSUB CLS
RETURN

'----------------------debug fills screen with X------------------

FILLSCREEN:
'character=$0B 'SPACE
TEMP1=0 ' LINECOUNTER
TEMP =0 'CHARCOUNTER
loop2a:

WDATA = 0 ' LINECOUNTER*256 + CHARCOUNTER ADDRESS
GOSUB Send


LOOP3a: ' :CHARACTERS 100011
WDATA = %0001011101100011 ' X CHARACTER
' WDATA = %0001011101110111
' if temp1 =0 then WDATA = %0001011101110111
if temp1 =1 then WDATA = %0001000001100011
if temp1 =2 then WDATA = %0001000101100011
if temp1 =3 then WDATA = %0001001001100011
if temp1 =4 then WDATA = %0001001101100011
if temp1 =5 then WDATA = %0001010001100011
if temp1 =6 then WDATA = %0001010101100011
if temp1 =7 then WDATA = %0001011001100011
if temp1 =8 then WDATA = %0001011101100011
if temp1 >=9 then WDATA = %0001011100100011
GOSUB Send
TEMP = TEMP + 1
IF TEMP >= 28 THEN
TEMP = 0
TEMP1=TEMP1 + 1
ENDIF
IF TEMP1 >= 11 THEN SCREENBLANKA

GOTO LOOP3A

SCREENBLANKA:
RETURN



Thanks, Ed

aerostar
- 29th August 2017, 11:46
rows 1-9 as white squares while rows 10 and 11 are X's


if temp1 =8 then WDATA = %0001011101100011 = white square
if temp1 >=9 then WDATA = %0001011100100011 = X


Also remember rows are 0-10 not 1 - 11

Ramius
- 30th August 2017, 01:44
Thanks Aerostar,
Just another brain cramp on my part. As long as the background is blue then color squares appear. With video, only white squares. I keep searching the internet for a chip that will produce color with a video input and not a generated background. I cannot believe no one has or makes such a chip!

Best, Ed