' OSDCSX.bas version 2.0 'Incrustateur de texte avec STV5730A et PIC 16F628 - 4 MHz ' Source pour PICBasic PRO ' Risto Kõiva 2001, F1FCO & F6CSX, mars 2003 ' tourne sur platine incrustateur F1UBZ (partie RS232/MAX232 inutile) ou demo board STV5730 ' mode page, barres de couleur 'changement cyclique de la couleur du fond ' affichage bande 23cm ou 70 cm selon état de la pin 18 (RA1) ' ** DÉFINITION HARDWARE ** CMCON = 7 'mets le 16F628 en mode digital sur le PORT A Clk VAR PORTB.5 Sda VAR PORTB.6 Csn VAR PORTB.4 Mute VAR PORTB.7 ' 0 si synchro valide, 1 si pas de synchro Mode VAR PORTB.3 'pin #9 , 0 = mode Page, 1 = Mode mixte On_off VAR PORTA.2 ' Arrêt de l'incrustateur : pin #1, 0=off, 1=on Band VAR PORTA.1 'incrustation 23 cm si 0 ou 70 cm si 1 INPUT Mode INPUT Mute INPUT On_off INPUT Band OUTPUT Clk OUTPUT Sda OUTPUT Csn '** DEFINITION DES 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 ' ** DEBUT DU PROGRAMME ** GOSUB Init 'initialisation GOSUB Mode_mixte 'Mode mixte par défaut GOSUB affiche_mixte b1=1 b2=1 b3=0 Boucle: b1= On_off IF b1= 0 THEN Incrust_off 'surveille le bouton On_off b4= Band IF b4 = 0 THEN W1= $02 W2= $03 ELSE W1= $07 W2= $00 ENDIF b3=MODE 'lit l'entrée MODE IF b3=b2 THEN Saute 'on ne change rien IF b3=1 THEN 'Si MODE = 1 : Mode Mixte, incrustation sur l'image GOSUB Mode_mixte GOSUB affiche_mixte b2 = b3 ELSE GOSUB Mode_page ' Mode Page: Mire FOR c=0 TO 6 wData = $00CD : GOSUB Send ' (pointe à l'adresse 13) wData = $1000 + ($201 * c) : GOSUB Send 'change de couleur de fond GOSUB affiche_page PAUSE 2000 NEXT c b3=Mode 'lit le mode b2=~b3 'b2 n'est pas égal à b3, on ne saute pas et on recommence ENDIF PAUSE 500 GOTO Boucle Saute: PAUSE 200 GOTO Boucle END '-------------------------------------------------------------------------------------------------------------------------------------------------------------- Incrust_off : ' Pas d'incrustation. On se met en mode mixte et on efface l'écran GOSUB Mode_mixte PAUSE 100 b1=1 b3=Mode 'lit le mode b2=~b3 'b2 n'est pas égal à b3, on ne saute pas GOTO Boucle '-------------------------------------------------------------------------------------------------------------------------------------------------------------- Efface_ecran: ' Pas d'incrustation wData = 0 : GOSUB Send ' pointe en haut à gauche de l'écran (0,0) c=1 FOR c=1 TO 308 'on efface l'écran avec des espaces (0B) wData = $1700+$0B : GOSUB Send '$1700: background disabled, caractère blanc non clignotant NEXT c RETURN '-------------------------------------------------------------------------------------------------------------------------------------------------------------- affiche_mixte: 'affichage en mode incrustation wData = 0 : GOSUB Send 'ne pas omettre cette ligne : position 0,0 wData = $1780 + $6E : GOSUB Send 'parabole clignottante wData = $170B : GOSUB Send 'espace 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 'espace wData = $170B : GOSUB Send 'espace wData = $170B : GOSUB Send 'espace 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 'espace wData = $170B : GOSUB Send 'espace wData = $170B : GOSUB Send 'espace 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 '-------------------------------------------------------------------------------------------------------------------------------------------------------------- affiche_page: 'affichage en mode page ' Première ligne en Zoom maxi wData = 0 : GOSUB Send 'ne pas omettre cette ligne : position 0,0 Ligne 0 wData = $1F0B : GOSUB Send 'espace wData = $1F00 + $11 : GOSUB Send 'F avec arrière plan bleu 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 'ligne 1 wData = $170B : GOSUB Send 'espace wData = $170B : GOSUB Send 'espace wData = $1700 + $1A : GOSUB Send 'O avec arrière plan noir 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 'espace wData = $170B : GOSUB Send 'espace wData = $170B : GOSUB Send 'espace wData = $170B : GOSUB Send 'espace 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 'ligne 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 'espace wData = $1700 + $38 : GOSUB Send 'o wData = $1700 + $3E : GOSUB Send 'u wData = $170B : GOSUB Send 'espace 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 ' Barres de couleur , 4 lignes FOR iCount = $0 TO $3 wData = $300 + $100*iCount : GOSUB Send 'pointe au début de la ligne 3 wData = $170B : GOSUB Send 'espace wData = $170B : GOSUB Send 'espace wData = $1877 : GOSUB Send 'noir 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 'blanc NEXT iCount wData = $700 : GOSUB Send FOR iCount = $1 TO $8 wData = $170B : GOSUB Send 'espace NEXT iCount wData = $1700 + $5F : GOSUB Send '* wData = $1700 + $5F : GOSUB Send '* wData = $1700 + $5F : GOSUB Send '* wData = $170B : GOSUB Send 'espace wData = $1780 + W1 : GOSUB Send '2 ou 7 wData = $1780 + W2 : GOSUB Send '3 ou 0 wData = $1780 + $2C : GOSUB Send 'c wData = $1780 + $36 : GOSUB Send 'm wData = $170B : GOSUB Send 'espace wData = $1700 + $5F : GOSUB Send '* wData = $1700 + $5F : GOSUB Send '* wData = $1700 + $5F : GOSUB Send '* PAUSE 1000 RETURN '-------------------------------------------------------------------------------------------------------------------------------------------------------------- WasteTime: 'temporisation 2 cycles d'horloge ASM nop nop ENDASM RETURN '-------------------------------------------------------------------------------------------------------------------------------------------------------------- StartCommunication: ' début de transmission Fig 2 page 12 notice STV5730A HIGH Clk : GOSUB WasteTime ' Clock à 1 LOW Csn : GOSUB WasteTime ' Chip select à 0 LOW Clk : GOSUB WasteTime ' Clock à 0 RETURN '-------------------------------------------------------------------------------------------------------------------------------------------------------------- StopCommunication: ' fin de transmission HIGH Clk : GOSUB WasteTime ' Clock à 1 HIGH Csn : GOSUB WasteTime ' Chip select à 1 RETURN '-------------------------------------------------------------------------------------------------------------------------------------------------------------- SendOne: 'envoi d'un bit 0 HIGH Sda : GOSUB WasteTime LOW Clk : GOSUB WasteTime HIGH Clk : GOSUB WasteTime RETURN '-------------------------------------------------------------------------------------------------------------------------------------------------------------- SendZero: 'envoi d'un bit 1 LOW Sda : GOSUB WasteTime LOW Clk : GOSUB WasteTime HIGH Clk : GOSUB WasteTime HIGH Sda : GOSUB WasteTime RETURN '-------------------------------------------------------------------------------------------------------------------------------------------------------------- OutByte: ' envoi d'un mot de 16 bits FOR Bit_Counter = 1 TO 16 IF wData.15 = 1 THEN ' MSB en premier GOSUB SendOne ELSE GOSUB SendZero ENDIF wData = wData << 1 NEXT Bit_Counter RETURN '-------------------------------------------------------------------------------------------------------------------------------------------------------------- Send: GOSUB StartCommunication GOSUB OutByte GOSUB StopCommunication RETURN '-------------------------------------------------------------------------------------------------------------------------------------------------------------- Init: ' ** INITIALISATION ( voir page 12 du DATA SHEET STV5730) 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 '-------------------------------------------------------------------------------------------------------------------------------------------------------------- Mode_page: ' INITIALISATION EN MODE PAGE wData = $00CC : GOSUB Send ' Initialisation des registres (pointe à l'adresse 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 ' Mode wData = $00C0 : GOSUB Send ' Set row attributes (pointe à l'adresse de la première ligne) wData = $10C4 : GOSUB Send '(position verticale=4 , caractères avec bordure, caractères affichés, position horizontale =0) wData = $10C4 : GOSUB Send '(position verticale=4 , caractères avec bordure, caractères affichés, position horizontale =0) wData = $10C4 : GOSUB Send '(position verticale=4 , caractères avec bordure, caractères affichés, position horizontale =0) wData = $10C8 : GOSUB Send FOR iCount = 0 TO 2 wData = $10C0 : GOSUB Send '(position verticale=0 , caractères avec bordure, caractères affichés, position horizontale =0) NEXT iCount ' Idem pour les 10 lignes suivantes wData = $10C8 GOSUB Efface_ecran RETURN '-------------------------------------------------------------------------------------------------------------------------------------------------------------- Mode_mixte: 'INITIALISATION EN MODE MIXTE wData = $00CC : GOSUB Send ' Initialisation des registres (pointe à l'adresse 12) wData = $1000 : GOSUB Send ' Zoom (1pixel/point - 1 pixel/ligne) wData = $1204 : GOSUB Send ' Color (fond de page, trait, fond de caractère rouges) wData = $1FD4 : GOSUB Send ' Control (mode mixte,fond de caractère controlé par BE,display on, couleur caract selon attribut caract ' clignottement 0.5s, rapport cyclique 0.5, synchro par le STV, PAL, niveau luminance externe, mode full page normal wData = $15A1 : GOSUB Send ' Position (horizontal 33, Vertical 22) wData = $183E : GOSUB Send ' Mode (BAR déconnecté, détection de pulse synchro,Mute interne,cte temps mute 32 lignes, synchro réinsérée, gain video 6dB ' codeur couleur en service, video out2 = video in, video out2 low impedance, mode normal, pas de compensation de delai, ' mute non synchro avec synchro verticale wData = $00C0 : GOSUB Send ' Set row attributes (pointe à l'adresse de la première ligne) FOR iCount = 0 TO 10 wData = $10C4 : GOSUB Send '(position verticale=4 , caractères avec bordure, caractères affichés, position horizontale =0) NEXT iCount ' Idem pour les lignes suivantes GOSUB Efface_ecran RETURN