; ***** first version (Friday morning), works after a few resets ; osd02.asm: works after several resets, sometimes changes sync or brightness, before displaying desired picture ; endless Ethan works fast ; removed surplus NOPs for optimal timing: didnt work with minimal timing ; try with 2-3 nops: endless loop (thanthan...) makes pic instable, keeps switching randomly ; try with 3 nops everywhere: now it works again (after several tries) ; once scrolling starts, very stable ; try slowing down scrolling (added wait125): works ok, no errors ; so the transmit seems to work ok, must be something else ; tried adding 1250µs wait after each transmit: seems to work less well ??? ; reduced to 125µs: no better ; removed wait again: still very hard to start (>50 tries) ; strange: now everything is back to where it was 5 lines ago, but still doesnt work anymore ; as suspected, now osd0.hex doesnt work either anymore --> electronic problem LIST P=PIC18F2550 #include loops Equ 0x22 ; Zähler für Warteschleife loops2 Equ 0x23 ; Zähler für Warteschleife count equ 0x24 ; universal counter OSD_L equ 0x25 OSD_H equ 0x26 count2 equ 0x27 count3 equ 0x28 temp equ 0x29 OSD_CSN equ 0x00 ; STV5730A ChipSelect Out OSD_CLK equ 0x01 ; STV5730A Data Clock Out OSD_DATA equ 0x02 ; STV5730A Data Out OSD_SYNC equ 0x03 ; STV5730A Sync Detected In Init movlw B'11111000' ; PortB 0-2 output movwf TRISB bcf INTCON2,RBPU call wait125 ; call Wait ; wait for the OSD chip to stabilize rst_osd clrf OSD_L movlw 0x30 movwf OSD_H movlw 0x10 call tx_osd ; send 0x3000 clrf OSD_L movlw 0x30 movwf OSD_H movlw 0x10 call tx_osd ; send 0x3000 movlw 0xDB movwf OSD_L clrf OSD_H movlw 0x10 call tx_osd ; send 0x00db clrf OSD_L movlw 0x10 movwf OSD_H call tx_osd ; send 0x1000 ; init osd registers clrf OSD_H movlw B'11001100' ; Zoom Register (#12) movwf OSD_L movlw 0x10 call tx_osd ; send 0000000011001100 --> select zoom reg (12) movlw B'00010000' movwf OSD_H clrf OSD_L movlw 0x10 call tx_osd ; send 0001000000000000 --> write zoom reg (12) movlw B'00010000' movwf OSD_H clrf OSD_L movlw 0x10 call tx_osd ; send 0001000000000000 --> write color reg (13) movlw B'00011011' movwf OSD_H movlw B'11010100' movwf OSD_L movlw 0x10 call tx_osd ; send 0001001111010100 --> write control reg (14) movlw B'00010000' movwf OSD_H movlw B'00000000' movwf OSD_L movlw 0x10 call tx_osd ; send 0001100000100000 --> write (32/32) to position register (15) movlw B'00010001' movwf OSD_H movlw B'00001100' movwf OSD_L movlw 0x10 call tx_osd ; send 0001000100100100 --> mode register (16) ClrScr clrf OSD_L clrf OSD_H movlw 0x10 call tx_osd ; set cursor to 0,0 movlw 0x02 movwf count3 movlw D'60' movwf count2 ; 16-bit counter to clear 308 characters ClrLoop ; write 255 "a" into screen memory movlw B'00010111' movwf OSD_H movlw 0x64 ; 0x0B = " " movwf OSD_L movlw 0x10 call tx_osd decfsz count2 bra ClrLoop decfsz count3 bra ClrLoop clrf OSD_L clrf OSD_H movlw 0x10 call tx_osd ; set cursor to 0,0 ClrRows movlw B'00000000' movwf OSD_H movlw B'11000000' movwf OSD_L movlw 0x10 call tx_osd ; set write pointer to row attribute #0 movlw D'12' movwf count2 RowLoop movlw B'00010000' movwf OSD_H movlw B'11000000' movwf OSD_L movlw 0x10 call tx_osd ; write '0001000011000000' to rows 0-11 decfsz count2 bra RowLoop ; debug: write something again to control register clrf OSD_H movlw B'11001110' ; Control Register (#14) movwf OSD_L movlw 0x10 call tx_osd ; send 0000000011001110 --> select control reg movlw B'00011011' movwf OSD_H movlw B'11010101' movwf OSD_L movlw 0x10 call tx_osd ; write to C TestMsg clrf OSD_L clrf OSD_H movlw 0x10 call tx_osd ; set cursor to 0,0 movlw B'11010100' movwf temp TestLup movlw 0x10 movwf OSD_L movlw B'00010111' movwf OSD_H movlw 0x10 call tx_osd ; write "E" call Wait movlw 0x3d movwf OSD_H movlw 0x08 call tx_osd ; write "t" call Wait movlw 0x31 movwf OSD_H movlw 0x08 call tx_osd ; write "h" call Wait movlw 0x2a movwf OSD_H movlw 0x08 call tx_osd ; write "a" call Wait movlw 0x37 movwf OSD_H movlw 0x08 call tx_osd ; write "n" call Wait ; goto TestLup ; test: toggle between fullscreen and overlay mode clrf OSD_H movlw B'11001110' ; Control Register (#14) movwf OSD_L movlw 0x10 call tx_osd ; send 0000000011001110 --> select control reg movlw B'00011011' movwf OSD_H btg temp,0 movff temp,OSD_L movlw 0x10 call tx_osd ; toggle bit0 in control reg goto TestLup loop goto loop btfsc PORTB,OSD_SYNC bra nosync ; set mixed screen mode clrf OSD_H movlw B'11001110' ; Control Register (#14) movwf OSD_L movlw 0x10 call tx_osd ; send 0000000011001110 --> select control reg movlw B'00011011' movwf OSD_H movlw B'11010100' movwf OSD_L movlw 0x10 call tx_osd ; send 0001001111010100 --> write control reg goto loop nosync ; set full screen mode clrf OSD_H movlw B'11001111' ; Control Register (#14) movwf OSD_L movlw 0x10 call tx_osd ; send 0000000011001110 --> select control reg movlw B'00011011' movwf OSD_H movlw B'11010100' movwf OSD_L movlw 0x10 call tx_osd ; send 0001001111010100 --> write control reg goto loop ;************************************************************** ; sends 8 or 16-bit word to OSD controller ; w must contain word length (8 or 16) ; for 8-bit transaction, store data into OSD_H tx_osd movwf count bsf PORTB,OSD_CLK ; make sure clk is high nop ; for safe timing nop ; for safe timing nop ; for safe timing bcf PORTB,OSD_CSN ; set csn low (selected) nop ; for safe timing nop ; for safe timing nop ; for safe timing loop1 bcf PORTB,OSD_CLK ; clk output low nop ; for safe timing nop ; for safe timing nop ; for safe timing rlcf OSD_L ; rotate low byte left into carry rlcf OSD_H ; rotate high byte left into carry bc hi ; branch if carry bcf PORTB,OSD_DATA ; set OSD data out low bra end1 hi bsf PORTB,OSD_DATA ; set OSD data out high end1 nop ; for safe timing (CLK low time = 200ns) nop ; for safe timing nop ; for safe timing bsf PORTB,OSD_CLK ; CLK high --> data valid decfsz count ; skip next cmd if count is now zero bra loop1 ; process next bit nop ; for safe timing nop ; for safe timing nop ; for safe timing bsf PORTB,OSD_CSN ; csn high (deselected) nop ; for safe timing (4µs CSN_high_duration) nop ; for safe timing (4µs CSN_high_duration) nop ; for safe timing (4µs CSN_high_duration) nop ; for safe timing (4µs CSN_high_duration) nop ; for safe timing (4µs CSN_high_duration) nop ; for safe timing (4µs CSN_high_duration) nop ; for safe timing (4µs CSN_high_duration) nop ; for safe timing (4µs CSN_high_duration) nop ; for safe timing (4µs CSN_high_duration) nop ; for safe timing (4µs CSN_high_duration) return ;********************************************************** ; Warteschleife 250 ms Wait movlw D'200' ; 500 ms Pause movwf loops Wai movlw D'249' ; Zeitkonstante für 2.5ms movwf loops2 Wai2 nop ; 83 cycles = 10µs (assuming 12 MIPS) nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop decfsz loops2, F ; 1 ms vorbei? goto Wai2 ; nein, noch nicht ; decfsz loops, F ; 250 ms vorbei? goto Wai ; nein, noch nicht retlw 0 ; das Warten hat ein Ende wait125 clrf loops,0 ; this loop takes about 125µs loop250 decfsz loops,1,0 ; 255 cycles bra loop250 return end