| Home |
Last Modified: 21 November 2000 |
6172 CAN Micro Controller Module AN006
This application example is not yet completely tested
Digitally controlled audio controller
This example shows how to interface a 6172 with a TDA7434 audio controller.
This IC handles:
If more then one IC of this type is to be handled via the I2C bus, a hardware multiplexer has to be designed to select each IC. This is because the TDA7434 reacts to a fixed I2C device address (100101 binary).
header "Audio controller AN006"
;memory locations
ParAdr: equ 0 ;parameter address for sequence 1
ParDta: equ 1 ;parameter data for sequence 1
DtaBlk: equ 4 ;parameter data for sequence 2
;the TDA7434 has the following parameters:
;adress data
;76543210 76543210
; I = 1 means address autoincrement after write
; |
;xxxI0000 INPUT SELECTOR
; 000 select IN 2
; 001 select IN 1
; 010 select MONO
; 1xx mute
; C non-symmetrical (0) / symmetrical (1) bass cut
; R extended (0) / standard (1) bass range
;xxxI0001 VOLUME
; 0000 0 dB \
; 0001 -1 dB \ 1 dB gain step
; |||| /
; 1111 -15 dB /
; 000 +32 dB \
; 001 +16 dB \
; 010 0 dB \
; 011 -16 dB > 16 dB gain step
; 100 -32 dB /
; 101 -48 dB /
; 110 -64 dB /
; L loudness off (0) / on (1)
;xxxI0010 BASS / TREBLE
; 0000 -14 dB \
; 0001 -12 dB \
; |||| \
; 0111 0 dB \ Treble steps
; 1111 0 dB /
; 1110 +2 dB /
; |||| /
; 1000 +14 dB /
; 0000 -14 dB \
; 0001 -12 dB \
; |||| \
; 0111 0 dB \ Bass steps
; 1111 0 dB /
; 1110 +2 dB /
; |||| /
; 1000 +14 dB /
;xxxI0011 SPEAKER ATTENUATOR LF
;xxxI0100 SPEAKER ATTENUATOR LR
;xxxI0101 SPEAKER ATTENUATOR RF
;xxxI0110 SPEAKER ATTENUATOR RR
; xx000000 0 dB \
; xx000001 -1 dB \ 1 dB steps
; |||||||| /
; xx011000 -24 dB /
; xx011001 -25.5 dB \
; |||||||| > 2.5 dB steps
; xx011111 -37.5 dB /
; xx1xxxxx speaker mute
;xxxI0111 LOUDNESS
; xxx00000 0 dB
; xxx00001 -1 dB
; ||||||||
; xxx01111 -15 dB
; xxx1 loudness flat
;---------------------------------------------------------------------
;initialisation, mute all four outputs
sequence 0
srdy ;READY active
ldwc %00100000 ;speaker mute value
stwm DtaBlk + 3 ;speaker LF
stwm DtaBlk + 4 ;speaker LR
stwm DtaBlk + 5 ;speaker RF
stwm DtaBlk + 6 ;speaker RR
call Seq_4 ;mute all outputs
enasq 0 ;enable sequences
endsq
;----------------------------------------------------------------------
;adjust one of 8 parameters, parameter addres in ParAdr, data in ParDta
sequence 3,,ParDta ;start on write of ParDta
i2sta ;start condition on I2C bus
ldwc %10001010 ;address the chip, R/W bit low
stwm I2OUT ;send address to I2C bus
ldwm ParAdr ;get parameter address
andwc 7 ;unused and I bit low
stwm I2OUT ;send parameter address
i2om ParDta ;send parameter data
i2stp ;stop condition on I2C bus (end)
endsq
;this sequence is executed in about 375 µS
;----------------------------------------------------------------------
;adjust all of 8 parameters, from data in DtaBlkd
sequence 4,,DtaBlk+7 ;start on write of last parameter
i2sta ;start condition on I2C bus
ldwc %10001010 ;address the chip, R/W bit low
stwm I2OUT ;send address to I2C bus
ldwc %00010000 ;parameter address 0, set I bit
stwm I2OUT ;send parameter address
i2om DtaBlk ;Input selector
i2om DtaBlk + 1 ;Volume
i2om DtaBlk + 2 ;Bass/Treble
i2om DtaBlk + 3 ;Speaker LF
i2om DtaBlk + 4 ;Speaker LR
i2om DtaBlk + 5 ;Speaker RF
i2om DtaBlk + 6 ;Speaker RR
i2om DtaBlk + 7 ;Loadness
i2stp ;stop condition on I2C bus (end)
endsq
;this sequence is executed in about 1050 µS
end
Assuming that all 6172 objects are in their default state, the following objects need to be adjusted (if a PDO is used):
|
Index |
Subindex |
Value |
Description |
|---|---|---|---|
|
Use receive PDO1 for a single parameter adjustment of the audio controller |
|||
|
1600h |
0 |
2 |
2 objects in receive PDO 1 |
|
1600h |
1 |
62000108h |
memory location 0 |
|
1600h |
2 |
62000208h |
memory location 1 |
|
Use receive PDO1 for all 8 parameters of the audio controller |
|||
|
1601h |
0 |
2 |
2 object in receive PDO 2 |
|
1601h |
1 |
63200220h |
memory locations 4-7 |
|
1601h |
2 |
63200320h |
memory locations 8-11 |
A parameter of the audio controller now can be changed by:
Copy and Paste this part direct after the declarations in the
canappl.bas program
this program can be found on the 6197 designers kit diskette or
ordered separately as service part together with one of our CAN products.
APPLICATION:
'This simple program is made for one 6172 and a 6390 as CAN bus interface
'the following assumptions are done:
'- 6390 is connected to COM2
'- 6172 ID = 1, CANbus speed = 50 kBAUD
'- assembled sequence file is "AN006.seq"
'- the audio controller is initialized and muted by the sequencer
'- this program asks for a parameter adres and data and sends this
' to the 6172 using one PDO
'- the program ends when nothing (just enter) is entered...
CLS
PRINT "CD Systems 6172 AN006 DEMO program"
PRINT
Activate6390 2,
19200
'6390 works at COM2, 19200 BAUD
SetCANBUSSpeed
50
'CAN BUS at 50 kBAUD
C% = CheckSequence%(1, "AN009.seq") 'download
sequence if not already done
C% = PutU8% (1, &h1600, 0,
2) '2 objects in receive
PDO 1
C% = PutU32% (1, &h1600, 1, &h62000108) 'receive PDO 1 to memory 0
C% = PutU32% (1, &h1600, 2, &h62000208) 'receive PDO 1 to memory 1
C% = PutU8% (1, &h1601, 0,
2) '2 objects in receive
PDO 3
C% = PutU32% (1, &h1601, 1, &h63200220) 'receive PDO 2 to memory 4-7
C% = PutU32% (1, &h1601, 2, &h63200320) 'receive PDO 2 to memory 8-11
SendNMTCommand (1,
1)
'node in operational state
PDO1COB% = (1 + 512) *
32
'receive PDO1 COB ID
PDO2COB% = (1 + 768) *
32
'receive PDO2 COB ID
DO
CLS
PRINT "CD Systems 6172 AN006 DEMO program"
PRINT
PRINT
LINE INPUT "Enter a parameter address: ", ADR$
IF ADR$ <> ""
LINE INPUT "Enter the parameter data : ",
DAT$
IF DAT$ <> ""
PRINT
A% = VAL (ADR$) AND 255
D% = VAL (DAT$) AND 255
SendToCAN (CANIDS$ (PDO1COB% + 2) +
CHR$(A%) + CHR$(D%))
PRINT "New value
transmitted...";
DELAY (2)
END IF
END IF
LOOP UNTIL (ADR$ = "") OR (DAT$ = "")
SendNMTCommand (1,
2)
'stop node
END