I can.
But since Melanie's already covered the subject, I'll let her.
Bits, Bytes Words and Arrays
http://www.picbasic.co.uk/forum/showthread.php?t=544
<br>
I can.
But since Melanie's already covered the subject, I'll let her.
Bits, Bytes Words and Arrays
http://www.picbasic.co.uk/forum/showthread.php?t=544
<br>
DT
You're Welcome Pedro,
Hope you (and everyone else) had a Happy "Boxing Day"!
<br>
DT
Hi Darrel
Thanks for help of this. I finally got it working, the engineer from the manufacturer found a small bug in their chip firmware. So anyone interested in using this chip should increase the reset time and increase the time for playback also.
See the amended code here :
@ DEVICE XT_OSC,MCLR_OFF,LVP_OFF,WDT_OFF,PROTECT_OFF
DEFINE LOADER_USED 1
' ** Setup the Resonator Frequency, in Mhz **
Define OSC 4
Baud con 84 ' 9600 baud rate
' ** Port configurations **
TX VAR PORTB.5
RX VAR PORTB.2
CLK VAR PORTA.4
DI Var PORTA.0
RESET VAR PORTB.6
PIEZO VAR PORTB.7
DAT VAR WORD
Idx VAR BYTE
counter var byte
volume var word
volume = 65527
'---------------------------------------------------------------------------
Init:
ANSEL = 0 'Configure all pins to digital operation since not using ADC
CMCON = 7 ' disable comparators
begin:
low piezo
dat = $FFF7
serout2 tx,baud,["Voice Volume - 1st Data = ",bin16 dat,13,10]
GOSUB SendDat
dat = $4
' set counter to file no. 4
counter = 4
serout2 tx,baud,["Address 4 of voice file - 2nd Data = ",bin16 dat,13,10]
GOSUB SendDat
playaddr:
dat = $fffe
serout2 tx,baud,["Play/Pause - 3rd Data = ",bin16 dat,13,10]
' GOSUB SendDat
GOSUB Playdata
' --------------------------------------------------------------------------
switch:
'if porta.2=0 then
' counter = counter - 1
' if counter<=1 then counter = 2
' dat = counter
'
' serout2 tx,baud,["Address of voice file - 2nd Data = ",bin16 dat,13,10]
' GOSUB SendDat
' goto playaddr
'endif
if porta.1=0 then
counter = counter + 1
if counter>=7 then counter = 6
dat = counter
serout2 tx,baud,["Address of voice file - 2nd Data = ",bin16 dat,13,10]
GOSUB SendDat
goto playaddr
endif
' Reduce Volume
if porta.2=0 then
volume = volume - 1
if volume<=65520 then volume = 65527
dat = volume
serout2 tx,baud,["Address of voice volume = ",bin16 dat,13,10]
GOSUB SendDat
'goto playaddr
endif
goto switch
STOP
'---------------------------------------------------------------------------
SendDAT:
LOW RESET ; 5ms reset pulse
PAUSE 5
INPUT RESET
PAUSE 300 ; 300ms before data
For Idx = 15 to 0 STEP -1 ; loop thru the bits
LOW CLK ; set CLK LOW
IF dat.0(Idx) THEN
INPUT DI ; if bit = 1 then INPUT, not HIGH
ELSE
LOW DI ; if bit = 0 then LOW
ENDIF
PAUSE 1 ; data settle time
INPUT CLK ; clks data on rising edge
PAUSE 1 ; data read time
NEXT Idx ; do rest of the bits
INPUT DI ; leave data line tri-stated
RETURN
' --------------------------------------------------------------------------
Playdata:
LOW RESET ; 5ms reset pulse
PAUSE 5
INPUT RESET
PAUSE 1250 ; 300ms before data
For Idx = 15 to 0 STEP -1 ; loop thru the bits
LOW CLK ; set CLK LOW
IF dat.0(Idx) THEN
INPUT DI ; if bit = 1 then INPUT, not HIGH
ELSE
LOW DI ; if bit = 0 then LOW
ENDIF
PAUSE 1 ; data settle time
INPUT CLK ; clks data on rising edge
PAUSE 1 ; data read time
NEXT Idx ; do rest of the bits
INPUT DI ; leave data line tri-stated
RETURN
' --------------------------------------------------------------------------
All the best; Happy NEW Year !!!
Wow, you have to wait 1-1/4 seconds after the reset.
That's quite a "Bug".
Especially since the datasheet says ...Well, at least it works!1 second after reset , if no action to the module, the chip will be into standby status within one second if no action after reset.
Happy NEW YEAR!
DT
Thanks Darrel for your help.
All the best and Happy New Year
Robert Quaas
Bookmarks