by JavaRN » Sun Aug 12, 2007 7:21 pm
by JavaRN
Sun Aug 12, 2007 7:21 pm
I've connected everything for my SP03, but I cannot communicate. I tested the connections with a multimeter and everything seems ok the parts seems to be connected in the right way. I am including a copy of the program I am using to connect to the SP03, if anyone can see any errors (logical) please tell me because I cannot find anything wrong:
(Note: This is not my work, I got it from NovaOne, just a copy and paste, may be I forgot something)
' Constants and vars for I2C comm
CONST SDA = 15 'Use port 15 for Data, constant SDA
CONST SCL = 16 'Use port 16 for Clock, constant SCL
DIM I2cBuf AS BYTE 'Buffer Byte
DIM I2cAddr AS BYTE 'Address Byte
DIM I2cReg AS BYTE 'Register Byte
DIM I2cData AS BYTE 'Data Byte
DIM I2cBit AS BYTE 'Bit index for shifting loops
DIM I2cTx AS BYTE 'Transmitted Byte
DIM I2cRx AS BYTE 'Recieved Byte
DELAY 6000
MUSIC "c"
Main:
I2cAddr = &Hc4 'SP03 default address
GOSUB FillSpeechBuffer
GOTO main
FillSpeechBuffer:
GOSUB I2cStart 'Start sequence
I2cBuf = I2cAddr
GOSUB I2cOutByte 'Send SP03 address
I2cBuf = 0
GOSUB I2cOutByte 'Select Command Register
GOSUB I2cOutByte 'Send NOP
GOSUB I2cOutByte 'Max volume = Zero??
I2cBuf = &H05
GOSUB I2cOutByte 'Speech Speed
I2cBuf = &H03
GOSUB I2cOutByte 'Speech Pitch
'** Followed by the ASCII characters (85 maximum) of the words you would like RN to say for example, Hello
I2cBuf = &H48 'H
GOSUB I2cOutByte
I2cBuf = &H65 'e
GOSUB I2cOutByte
I2cBuf = &H6C 'l
GOSUB I2cOutByte
I2cBuf = &H6C 'l
GOSUB I2cOutByte
I2cBuf = &H06F 'o
GOSUB I2cOutByte
I2cBuf = 0 'Nul
GOSUB I2cOutByte
GOSUB I2cStop
RETURN
' Start speech
Start_Speech:
GOSUB I2cStart 'Start sequence
I2cBuf = I2cAddr
GOSUB I2cOutByte 'Send SP03 address
I2cBuf = 0
GOSUB I2cOutByte 'Select Command Register
GOSUB I2cOutByte 'Send NOP
I2cBuf = 0
GOSUB I2cOutByte 'Max volume = Zero??
I2cBuf = &H05
GOSUB I2cOutByte 'Speech Speed
I2cBuf = &H03
GOSUB I2cOutByte 'Speech Pitch
RETURN
' Say Something
say_hello:
I2cBuf = &H48 'H
GOSUB I2cOutByte
I2cBuf = &H65 'e
GOSUB I2cOutByte
I2cBuf = &H6C 'l
GOSUB I2cOutByte
I2cBuf = &H6C 'l
GOSUB I2cOutByte
I2cBuf = &H06F ' o
GOSUB I2cOutByte
I2cBuf = 0 'Nul
GOSUB I2cOutByte
GOSUB I2cStop
RETURN
' Start the I2C communcation
I2cStart:
OUT SDA,1 'Ensure data and clock lines are both high
OUT SCL,1
OUT SDA,0 'Sent start bit, ie lower data line while clock line is high
OUT SCL,0 'Lower clock line ready to start clocking data.
RETURN
' Stop the I2C communication
I2cStop:
OUT SCL,1
OUT SDA,1 'Sent stop bit, ie raise data line while clock high
RETURN
I2cByteWrite:
GOSUB I2cStart 'Send start bit
I2cBuf = I2cAddr
GOSUB I2cOutByte 'Send module address
I2cBuf = I2cReg
GOSUB I2cOutByte 'Send the register number you wish to read
I2cBuf = I2cData
GOSUB I2cOutByte 'Send Data
GOSUB I2cStop 'Send stop bit
RETURN
' reading a byte from the I2C device
I2cByteRead:
GOSUB I2cStart 'Send start bit
I2cBuf = I2cAddr
GOSUB I2cOutByte 'Send module address
I2cBuf = I2cReg
GOSUB I2cOutByte 'Send the register number you wish to read
GOSUB I2cStart 'Send the required repeated start bit
I2cBuf = I2cAddr OR 1 'set write enable bit
GOSUB I2cOutByte 'Send the module address with write enable bit set
GOSUB I2cInByte 'Read required data
I2cData = I2cBuf 'copy data from buffer Byte
GOSUB I2cStop 'Send stop bit
RETURN
' Output a byte to the I2C device
I2cOutByte:
FOR I2cBit = 0 TO 7
I2cTx = I2cBuf AND &H80 'Mask off all but the Most significant bit
IF I2cTx <> 0 THEN 'Test the BSB and set up data ie
OUT SDA,1 'data = 1
ELSE
OUT SDA,0 'data = 0
ENDIF
OUT SCL, 1
OUT SCL, 0 'Clock the data out
I2cBuf = I2cBuf << 1
NEXT I2cBit
OUT SDA, 0
OUT SCL, 1
OUT SCL, 0 'clock in the Ack' bit, and ignore it.
RETURN
' Reading a byte from the I2C device
I2cInByte:
I2cBuf =0 'clear input buffer byte
OUT SDA, 1
I2cRx = IN(SDA) 'release data line for input
FOR I2cBit = 0 TO 7
OUT SCL, 1
I2cRx = IN(SDA) 'Read one bit of the byte
OUT SCL, 0 'Pull clock low, ready for next bit
I2cBuf = I2cBuf << 1 'Shift the Data buffer one bit left
IF I2cRx <> 0 THEN
I2cBuf = I2cBuf +1 'if the data is a one set the Least Significant bit in the buffer
ENDIF
NEXT I2cBit
OUT SDA, 0
OUT SCL, 1
OUT SCL, 0 'clock in the Ack' bit, and ignore it.
RETURN
I've connected everything for my SP03, but I cannot communicate. I tested the connections with a multimeter and everything seems ok the parts seems to be connected in the right way. I am including a copy of the program I am using to connect to the SP03, if anyone can see any errors (logical) please tell me because I cannot find anything wrong:
(Note: This is not my work, I got it from NovaOne, just a copy and paste, may be I forgot something)
' Constants and vars for I2C comm
CONST SDA = 15 'Use port 15 for Data, constant SDA
CONST SCL = 16 'Use port 16 for Clock, constant SCL
DIM I2cBuf AS BYTE 'Buffer Byte
DIM I2cAddr AS BYTE 'Address Byte
DIM I2cReg AS BYTE 'Register Byte
DIM I2cData AS BYTE 'Data Byte
DIM I2cBit AS BYTE 'Bit index for shifting loops
DIM I2cTx AS BYTE 'Transmitted Byte
DIM I2cRx AS BYTE 'Recieved Byte
DELAY 6000
MUSIC "c"
Main:
I2cAddr = &Hc4 'SP03 default address
GOSUB FillSpeechBuffer
GOTO main
FillSpeechBuffer:
GOSUB I2cStart 'Start sequence
I2cBuf = I2cAddr
GOSUB I2cOutByte 'Send SP03 address
I2cBuf = 0
GOSUB I2cOutByte 'Select Command Register
GOSUB I2cOutByte 'Send NOP
GOSUB I2cOutByte 'Max volume = Zero??
I2cBuf = &H05
GOSUB I2cOutByte 'Speech Speed
I2cBuf = &H03
GOSUB I2cOutByte 'Speech Pitch
'** Followed by the ASCII characters (85 maximum) of the words you would like RN to say for example, Hello
I2cBuf = &H48 'H
GOSUB I2cOutByte
I2cBuf = &H65 'e
GOSUB I2cOutByte
I2cBuf = &H6C 'l
GOSUB I2cOutByte
I2cBuf = &H6C 'l
GOSUB I2cOutByte
I2cBuf = &H06F 'o
GOSUB I2cOutByte
I2cBuf = 0 'Nul
GOSUB I2cOutByte
GOSUB I2cStop
RETURN
' Start speech
Start_Speech:
GOSUB I2cStart 'Start sequence
I2cBuf = I2cAddr
GOSUB I2cOutByte 'Send SP03 address
I2cBuf = 0
GOSUB I2cOutByte 'Select Command Register
GOSUB I2cOutByte 'Send NOP
I2cBuf = 0
GOSUB I2cOutByte 'Max volume = Zero??
I2cBuf = &H05
GOSUB I2cOutByte 'Speech Speed
I2cBuf = &H03
GOSUB I2cOutByte 'Speech Pitch
RETURN
' Say Something
say_hello:
I2cBuf = &H48 'H
GOSUB I2cOutByte
I2cBuf = &H65 'e
GOSUB I2cOutByte
I2cBuf = &H6C 'l
GOSUB I2cOutByte
I2cBuf = &H6C 'l
GOSUB I2cOutByte
I2cBuf = &H06F ' o
GOSUB I2cOutByte
I2cBuf = 0 'Nul
GOSUB I2cOutByte
GOSUB I2cStop
RETURN
' Start the I2C communcation
I2cStart:
OUT SDA,1 'Ensure data and clock lines are both high
OUT SCL,1
OUT SDA,0 'Sent start bit, ie lower data line while clock line is high
OUT SCL,0 'Lower clock line ready to start clocking data.
RETURN
' Stop the I2C communication
I2cStop:
OUT SCL,1
OUT SDA,1 'Sent stop bit, ie raise data line while clock high
RETURN
I2cByteWrite:
GOSUB I2cStart 'Send start bit
I2cBuf = I2cAddr
GOSUB I2cOutByte 'Send module address
I2cBuf = I2cReg
GOSUB I2cOutByte 'Send the register number you wish to read
I2cBuf = I2cData
GOSUB I2cOutByte 'Send Data
GOSUB I2cStop 'Send stop bit
RETURN
' reading a byte from the I2C device
I2cByteRead:
GOSUB I2cStart 'Send start bit
I2cBuf = I2cAddr
GOSUB I2cOutByte 'Send module address
I2cBuf = I2cReg
GOSUB I2cOutByte 'Send the register number you wish to read
GOSUB I2cStart 'Send the required repeated start bit
I2cBuf = I2cAddr OR 1 'set write enable bit
GOSUB I2cOutByte 'Send the module address with write enable bit set
GOSUB I2cInByte 'Read required data
I2cData = I2cBuf 'copy data from buffer Byte
GOSUB I2cStop 'Send stop bit
RETURN
' Output a byte to the I2C device
I2cOutByte:
FOR I2cBit = 0 TO 7
I2cTx = I2cBuf AND &H80 'Mask off all but the Most significant bit
IF I2cTx <> 0 THEN 'Test the BSB and set up data ie
OUT SDA,1 'data = 1
ELSE
OUT SDA,0 'data = 0
ENDIF
OUT SCL, 1
OUT SCL, 0 'Clock the data out
I2cBuf = I2cBuf << 1
NEXT I2cBit
OUT SDA, 0
OUT SCL, 1
OUT SCL, 0 'clock in the Ack' bit, and ignore it.
RETURN
' Reading a byte from the I2C device
I2cInByte:
I2cBuf =0 'clear input buffer byte
OUT SDA, 1
I2cRx = IN(SDA) 'release data line for input
FOR I2cBit = 0 TO 7
OUT SCL, 1
I2cRx = IN(SDA) 'Read one bit of the byte
OUT SCL, 0 'Pull clock low, ready for next bit
I2cBuf = I2cBuf << 1 'Shift the Data buffer one bit left
IF I2cRx <> 0 THEN
I2cBuf = I2cBuf +1 'if the data is a one set the Least Significant bit in the buffer
ENDIF
NEXT I2cBit
OUT SDA, 0
OUT SCL, 1
OUT SCL, 0 'clock in the Ack' bit, and ignore it.
RETURN
F'dan il-passatemp ghandek bzonn zewg affarijiet - FLUS u HIN. Zewg affarijiet li huma skarsi hafna u li jien minnhom ghandi vera ftit!