Mr.Henrik wrote the code...me just put together parts...
BUT : even if in Proteus the signal(s) appears to be OK, the HU-JVC don't react at all !
Maybe the "timming" need to be more accurate ?! At this point, I'm hopeless and stuck
... Any help will be appreciated !
Hex and dns attached...
Code:
;***************************************************************************
;*
;* Test variant, using 2N3904 on output - PORTC.0
;*
;***************************************************************************
@ DEVICE PIC16F684, HS_OSC, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_OFF
DEFINE OSC 20
include "ALLDIGITAL.pbp"
TRISA= 000011
PORTA= 000011
PORTC= 000000
CMCON0 = 000111 ' Disable analog comparators.
VRCON = 000000 ' Disable Comparator Voltage Reference
ANSEL = 000000 ' Set pin'S to digital
ADCON0 = 000000 ' Set up A/D converter - OFF
Pause 1000
i VAR BYTE
j VAR BYTE
OutBuffer VAR BYTE[8]
BitsToSend VAR BYTE
Main:
if porta.0 = 0 then gosub VolUp ' just for test
if porta.1 = 0 then gosub VolDn ' just for test
Pause 100 ' do it for 0.1 sec
Goto Main
'-----------------------------------------------------------------------
SendPreamble:
; 01110111 01110111 01010101 11
OutBuffer[0] = 010001 ; 101110 REVERSED BECAUSE OF USING TRANSISTOR AT OUTPUT !!!
OutBuffer[1] = 010001 ; 101110
OutBuffer[2] = 010101 ; 101010
OutBuffer[3] = 111100 ; 000011
BitsToSend = 26
GOSUB SendBits
RETURN
'-----------------------------------------------------------------------
AGC:
TRISC.0 = 1 ; 0
PauseUs 8584
TRISC.0 = 0 ; 1
PauseUs 4292
RETURN
'-----------------------------------------------------------------------
SendPostAmble:
' 01111111 11111111 11111111 11111111 11110111 01110111 01110101 010111
OutBuffer[0] = 000001 ; 111110
OutBuffer[1] = 000000 ; 111111
OutBuffer[2] = 000000 ; 111111
OutBuffer[3] = 000000 ; 111111
OutBuffer[4] = 110000 ; 001111
BitsToSend = 36
GOSUB SendBits
RETURN
'-----------------------------------------------------------------------
SendFinalAmble:
' 01111111 11111111 11111111 11111111 11111111 11111111 11111111 111111
OutBuffer[0] = 000001 ; 111110
OutBuffer[1] = 000000 ; 111111
OutBuffer[2] = 000000 ; 111111
OutBuffer[3] = 000000 ; 111111
OutBuffer[4] = 000000 ; 111111
OutBuffer[5] = 000000 ; 111111
OutBuffer[6] = 000000 ; 111111
OutBuffer[7] = 000000 ; 111111
BitsToSend = 54
GOSUB SendBits
RETURN
'-----------------------------------------------------------------------
VolUp:
Gosub AGC
;==============================
GOSUB SendPreAmble ; one
' Volume Up
OutBuffer[0] = 010101 ; 101010
OutBuffer[1] = 101010 ; 010101
OutBuffer[2] = 111110 ; 000001
BitsToSend = 17
GOSUB SendBits
GOSUB SendPostAmble
;==============================
gosub SendPreamble ; two
' Volume Up
OutBuffer[0] = 010101 ; 101010
OutBuffer[1] = 101010 ; 010101
OutBuffer[2] = 111110 ; 000001
BitsToSend = 17
GOSUB SendBits
GOSUB SendPostAmble
;==============================
gosub sendPreamble ; three
' Volume Up
OutBuffer[0] = 010101 ; 101010
OutBuffer[1] = 101010 ; 010101
OutBuffer[2] = 111110 ; 000001
BitsToSend = 17
GOSUB SendBits
GOSUB SendFinalAmble
RETURN ; end command
'-----------------------------------------------------------------------
VolDn:
Gosub AGC
;==============================
GOSUB SendPreAmble
' 01111010 11110101 0101
' Volume Down
OutBuffer[0] = 100001 ; 011110
OutBuffer[1] = 010000 ; 101111
OutBuffer[2] = 110101 ; 001010
BitsToSend = 20
GOSUB SendBits
GOSUB SendPostAmble
;==============================
GOSUB SendPreAmble
' 01111010 11110101 0101
' Volume Down
OutBuffer[0] = 100001 ; 011110
OutBuffer[1] = 010000 ; 101111
OutBuffer[2] = 110101 ; 001010
BitsToSend = 20
GOSUB SendBits
GOSUB SendPostAmble
;==============================
GOSUB SendPreAmble
' 01111010 11110101 0101
' Volume Down
OutBuffer[0] = 100001 ; 011110
OutBuffer[1] = 010000 ; 101111
OutBuffer[2] = 110101 ; 001010
BitsToSend = 20
GOSUB SendBits
GOSUB SendFinalAmble
RETURN
'-----------------------------------------------------------------------
SendBits:
BitsToSend = BitsToSend - 1
For i = 0 to BitsToSend
TRISC.0 = OutBuffer.0[i]
PauseUs 536
@ nop
@ nop ; for 536.5 us
NEXT
RETURN
'-----------------------------------------------------------------------
END
Bookmarks