Hi all.
Code is pretty much exactly the same as the working code I was using on the 14M2 a year or so ago, but it refuses to co-operate.
I suspect I have done something wrong, when porting the code to the 40X2 chip.
Here is the code that is supposed to work:
This code returns a value of 32768 for dta, which is REALLY wrong - can someone offer any pointers as to what I have done wrong in the code?
If you set dta to 451(1C3) using dta=$1C3, then once it has clocked that to the module, the debug window should show the value of dta as being 451, but it says it is 32768????
Code is pretty much exactly the same as the working code I was using on the 14M2 a year or so ago, but it refuses to co-operate.
I suspect I have done something wrong, when porting the code to the 40X2 chip.
Here is the code that is supposed to work:
Code:
'SOMO tester code thing
'VErsion 1A
#picaxe 40x2
#no_data
#no_table
symbol control=b0 'Used for control bits - don't use for anything else
symbol dta=w6 'Data to module is a word(16-bit) value
symbol x=b5 'X marks the spot...
symbol mask=bit0 'Mask word for the shiftout proceedure
symbol MSB=$8000 'Most Significant Bit position is bit 16
symbol sda=B.6 'Serial data output is on port B.6
symbol scl=B.7 'Serial clock output is on port B.7
init:
high scl 'Set clock idle state high
low sda 'Set data idle state low
low B.4 'Ensure RESET is allowed to idle-high(548 pull-down transistor NOT active)
wait 3 'Allow things to start up
dta=$1C3 'Select track #451
gosub somo 'Instruct SOMO module to play track represented by value of dta
high scl 'Set clock idle state high
low sda 'Set data idle state low
gosub piezo 'Beep piezo as confirmation of completion of talking to SOMO.
debug
stop
'================================
'CLOCK DATA TO MODULE SUBROUTINE:
'================================
somo:
'gosub rst 'Reset module first
low scl 'Pull clock-line low
pause 2 'Start-bit time
for x = 1 to 16 'Start of shiftout code
mask = dta and MSB / MSB
low sda
if mask=0 then skipMSB
high sda
skipMSB:
if x = 16 then skippulse
pulsout scl,20 '100uS minimum pulse-width for clock or data lines
dta = dta * 2
skippulse:
next x 'End of shiftout code
high scl 'Pull clock-line high
pause 2 'End-bit time
return
'rst:
' high B.4 'Reset module
' pause 5 'Reset pulse-width as per manual ver 3.0
' low B.4 '"Release" reset
' pause 300 'Reset to first bit wait time as per manual ver 3.0
' return
'=======================
'BEEP PIEZO SUB-ROUTINE:
'=======================
piezo:
high A.1 'Turn on piezo beeper via 548
pause 150 'Wait some time
low A.1 'Turn off piezo beeper via 548
return
If you set dta to 451(1C3) using dta=$1C3, then once it has clocked that to the module, the debug window should show the value of dta as being 451, but it says it is 32768????