SPE035 Audio Module & Flash LEDs problem

jensmith25

Senior Member
Hi all,

I've got the SPE035 MP3 module with the associated AXE171 14m2 board working nicely but I want to do what I thought was simple and flash the two onboard LEDs once every 2 seconds.

The problem is I can either
1) flash the LEDs
2) play the mp3
but not both together.

I've tried loads of different options and I know it's looping the LEDs that is stopping the programme so how do I integrate it so both work? I've tried toggle and that doesn't even flash the LEDs.

The track runs continuously.

This code has the LEDs flashing correctly but no mp3 playing. I tried integrating it with the onboard switch to see if that would help but pressing the switch doesn't stop the LEDs flashing or start the MP3 player.

Code:
#Picaxe 14M2

' Play mp3 files on audio pcb Axe171 in continuous loop
' © Small Scale Lights / JS Miniatures 2016-2017

Symbol TX = B.4
Symbol RX = C.3
Symbol BUSY_PIN = pinC.2
Symbol BAUD_FREQ = M8
symbol mdefault = m4
Symbol BAUD = T9600_8
Symbol cmd = b0
Symbol arg = w1 ; b3:b2
Symbol arg.lsb = b2
Symbol arg.msb = b3
Symbol varA = w2

High TX ; set TX pin high for idle high serial
Pause 2000
SerTxd("Starting", CR, LF )
SerTxd("Select microSD Card", CR, LF )
cmd = $09 : arg = $0002 : Gosub Send
Pause 4000
SerTxd("Set volume 16", CR, LF )
cmd = $06 : arg = 16 : Gosub Send
Pause 1000

	if pinC.0 = 0 then
	do
		high B.2, B.5
		pause 500
		low B.2, B.5
		pause 2000
	loop
	endif
	
' Play track 1
cmd = $12 : arg = $0001 : Gosub Send

' Repeat forever
cmd = $08 : arg = $0002 : Gosub Send

Sertxd("Done", CR, LF )
Stop
	

Send:
 SetFreq BAUD_FREQ
 Pause 10
 SerOut TX, BAUD, ( $7E, $FF, $06, cmd, $00, arg.msb, arg.lsb, $EF )
 SetFreq MDEFAULT
 Return
 
 end
 

PhilHornby

Senior Member
Code:
    do  <-----------------***
        high B.2, B.5
        pause 500
        low B.2, B.5
        pause 2000
    loop ***----------------->
    endif
Once in there, there is no escape from that 'do...loop' ... which is probably not what you want!

Removing the "do" and "loop" will fix that, but the logic might still not be what you want.

On the M2, you could make use of the 'multi-tasking', so that LED blinking happens in one 'task' and mp3 control happens in the other. You'll have to remove the 'setfreqs' though (not allowed in multitasking prog).
 

jensmith25

Senior Member
I assumed the 'setfreqs' were required as part of the programme so when I tried multi-taking and the error came up I assumed I couldn't do it that way.

Is it okay to remove them?

EDIT:
Tried it and the MP3 player won't play. It looks like you need the 'setfreq' commands. Unless I've done something else wrong.
Code:
#Picaxe 14M2

' Play mp3 files on audio pcb Axe171 in continuous loop
' © Small Scale Lights / JS Miniatures 2016-2017

start0:
	do
		high B.2, B.5
		pause 500
		low B.2, B.5
		pause 2000
	loop
	
start1:
Symbol TX = B.4
Symbol RX = C.3
Symbol BUSY_PIN = pinC.2
'Symbol BAUD_FREQ = M8
'symbol mdefault = m4
Symbol BAUD = T9600_8
Symbol cmd = b0
Symbol arg = w1 ; b3:b2
Symbol arg.lsb = b2
Symbol arg.msb = b3
Symbol varA = w2

High TX ; set TX pin high for idle high serial
Pause 2000
SerTxd("Starting", CR, LF )
SerTxd("Select microSD Card", CR, LF )
cmd = $09 : arg = $0002 : Gosub Send
Pause 4000
SerTxd("Set volume 16", CR, LF )
cmd = $06 : arg = 16 : Gosub Send
Pause 1000
	
' Play track 1
cmd = $12 : arg = $0001 : Gosub Send

' Repeat forever
cmd = $08 : arg = $0002 : Gosub Send

Sertxd("Done", CR, LF )
Stop
	

Send:
 'SetFreq BAUD_FREQ
 Pause 10
 SerOut TX, BAUD, ( $7E, $FF, $06, cmd, $00, arg.msb, arg.lsb, $EF )
 'SetFreq MDEFAULT
 Return
 
 end
 
Last edited:

PhilHornby

Senior Member
Ah...

The multi-tasking environment is a bit weird (if you ask me!). The processor is actually running @ 16MHz, which means up to 4 tasks can run at their normal 4MHz. You don't use the _16 variants of variables though - you use the default (or _4) versions. There isn't a T9600_4 Serial baud rate constant - which means you can't use Serout @ 9600bps to talk to the SPE035.

However, you can use HSEROUT - which fortuitously uses the same hardware pin ... so no re-wiring necessary. Use B9600_4 as the baud rate.

P.S.

I don't know what the consequences are, of that 'STOP' statement in 'Task 1' (I've never tried it). You may need to swap it for an empty 'do...loop'; though the manual implies that's how it's actually implemented. The final 'end' statement can be removed, as there is no path to it.
 

jensmith25

Senior Member
Swapping 'Serout' for 'Hserut' is giving me a syntax error on 'HSerOut..... code'
Code:
 HSerOut TX, BAUD, ( $7E, $FF, $06, cmd, $00, arg.msb, arg.lsb, $EF )
 

PhilHornby

Senior Member
Yes, it uses a different syntax (and you need to issue a HSERSETUP command first). I'm on my way out of the door now - but if you've not sussed it by the time I get back, I'll post an example.
 

jensmith25

Senior Member
That might be useful as I'm struggling to integrate it into the code to know what to remove and what is needed. All my attempts are coming up with syntax errors.
 

PhilHornby

Senior Member
Turns out I didn't read through your code very thoroughly :eek:

On the 14M2, HSEROUT only works with B.0 (or at a pinch with C.1) ... and you're using B.4

So, to proceed with the multi-tasking route, you'd need to re-wire the project.

As the program stands at the moment, you could probably just alter the order it does things ... i.e. play the MP3's, then enter the LED flashing code. Or even, dare I suggest it, use 'Flashing' LEDs?

Is this a solution to an actual problem? ... or just experimentation?
 

jensmith25

Senior Member
I don't want to rewire it. That's going to be difficult given the layout of the board and it's designed so the mother board and MP3 player plug into each other.

This is an actual problem and needs an urgent solution. It's for a customer.

I could use flashing LEDs but I needed a slow flash - once every 2 seconds and the flashing LEDs are 0.5sec flash rate.
 

AllyCat

Senior Member
Hi,

The PICaxe "multitasking" seems to have so many (often unexpected) "restrictions" that I've never found a use for it. However, TOGGLE can be very helpful; for example to flash a LED every 2 seconds (i.e. on for 1 sec, off for 1 sec), you could simply use "PAUSE 1000 : TOGGLE LED" in a loop (but see below).

The way I would solve the problem is to remove all the (longer) PAUSE commands and replace the subsequent operations (e.g. changing the state of a LED) by an "event" or "Alarm". Consider your main program as a "checklist" which will be worked through at least once every second (and maybe much faster). At the end of the "list" could be a "GOTO main" (but "other syntax is available").

In the list may be many things that don't need to be done (e,g waiting until a track finishes), so just skip over them to the next item. To flash a LED slowly you might use:

Code:
#picaxe 14m2
symbol RedLEDalarm = b10    ; any spare variable
symbol timetick = b11    ; To syncronise main loop
symbol RedLED = c.4      ; LED port.pin
;...
main:
     INC RedLEDalarm        ; "Count" the elapsed time
     IF RedLEDalarm > 4 THEN
         TOGGLE RedLED
         RedLEDalarm = 0     ; Reset the time counter
     ENDIF
;....
   DO : LOOP UNTIL timetick <> time      ; Wait for a total of one second to have elapsed
      timetick = time
     GOTO main
The last part of the above example synchronises the loop/list to run exactly once every second (two seconds with SETFREQ m8 !), but the loop might run faster and time<>timetick used to select some slower actions like flashing LEDs.

Cheers, Alan.
 

jensmith25

Senior Member
Thanks Alan. I'm sorry but my coding knowledge is just too poor to know how to integrate that into the code. I tried and I got the LEDs flashing slowly but the MP3 player isn't playing. The same issue I always run into whatever I do. One works, the other doesn't.

My best solution at this point, given I want to ship this today, is to just turn the outputs 'on' and use a flasher chip to flash once every second. Faster than he wants but they only do 1hz or 2hz chips.
 

AllyCat

Senior Member
Hi,

Sorry but it's difficult to see what the program is intended/required to do. There are commands for Track 1 , Repeat Forever and Stop, but they are all blocked by the LED code. PinC.0 only determines if the LEDs start to flash, it cannot stop them.

Post the program that controls the MP3 as required and maybe we can add the LED code. What is c.0 required to do and is it 0 or 1 when pressed ?

However, in the code in #1 have you tried putting the block of LED code immediately before the "Done" line.

Cheers, Alan.
 

PhilHornby

Senior Member
I only suggested the multi-tasking approach, because I thought this was going to 'grow' into a bigger project.

Would this code do what you want? (it's your code, with the LED stuff moved after the MP3 stuff)

Code:
[COLOR=navy]#Picaxe [/COLOR][COLOR=black]14M2[/COLOR]
[COLOR=green]' Play mp3 files on audio pcb Axe171 in continuous loop
' © Small Scale Lights / JS Miniatures 2016-2017[/COLOR]
[COLOR=blue]Symbol TX [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=blue]B.4
Symbol RX [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=blue]C.3
Symbol [/COLOR][COLOR=purple]BUSY_PIN [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=purple]pinC.2[/COLOR]
[COLOR=blue]Symbol [/COLOR][COLOR=black]BAUD_FREQ [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=blue]M8
symbol mdefault [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=blue]m4
Symbol BAUD [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=blue]T9600_8
Symbol [/COLOR][COLOR=purple]cmd [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=purple]b0[/COLOR]
[COLOR=blue]Symbol [/COLOR][COLOR=purple]arg [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=purple]w1 [/COLOR][COLOR=green]; b3:b2[/COLOR]
[COLOR=blue]Symbol [/COLOR][COLOR=purple]arg[/COLOR][COLOR=black].lsb [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=purple]b2[/COLOR]
[COLOR=blue]Symbol [/COLOR][COLOR=purple]arg.msb [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=purple]b3[/COLOR]
[COLOR=blue]Symbol [/COLOR][COLOR=purple]varA [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=purple]w2[/COLOR]
[COLOR=blue]High TX [/COLOR][COLOR=green]; set TX pin high for idle high serial[/COLOR]
[COLOR=blue]Pause [/COLOR][COLOR=navy]2000[/COLOR]
[COLOR=blue]SerTxd([/COLOR][COLOR=red]"Starting"[/COLOR][COLOR=black], [/COLOR][COLOR=blue]CR[/COLOR][COLOR=black], [/COLOR][COLOR=blue]LF )
SerTxd([/COLOR][COLOR=red]"Select microSD Card"[/COLOR][COLOR=black], [/COLOR][COLOR=blue]CR[/COLOR][COLOR=black], [/COLOR][COLOR=blue]LF )[/COLOR]
[COLOR=purple]cmd [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]$09 [/COLOR][COLOR=black]: [/COLOR][COLOR=purple]arg [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]$0002 [/COLOR][COLOR=black]: [/COLOR][COLOR=blue]Gosub [/COLOR][COLOR=black]Send[/COLOR]
[COLOR=blue]Pause [/COLOR][COLOR=navy]4000[/COLOR]
[COLOR=blue]SerTxd([/COLOR][COLOR=red]"Set volume 16"[/COLOR][COLOR=black], [/COLOR][COLOR=blue]CR[/COLOR][COLOR=black], [/COLOR][COLOR=blue]LF )[/COLOR]
[COLOR=purple]cmd [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]$06 [/COLOR][COLOR=black]: [/COLOR][COLOR=purple]arg [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]16 [/COLOR][COLOR=black]: [/COLOR][COLOR=blue]Gosub [/COLOR][COLOR=black]Send[/COLOR]
[COLOR=blue]Pause [/COLOR][COLOR=navy]1000[/COLOR]
[COLOR=green];     if pinC.0 = 0 then
;     do
;           high B.2, B.5
;           pause 500
;           low B.2, B.5
;           pause 2000
;     loop
;     endif
      
' Play track 1[/COLOR]
[COLOR=purple]cmd [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]$12 [/COLOR][COLOR=black]: [/COLOR][COLOR=purple]arg [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]$0001 [/COLOR][COLOR=black]: [/COLOR][COLOR=blue]Gosub [/COLOR][COLOR=black]Send[/COLOR]
[COLOR=green]' Repeat forever[/COLOR]
[COLOR=purple]cmd [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]$08 [/COLOR][COLOR=black]: [/COLOR][COLOR=purple]arg [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]$0002 [/COLOR][COLOR=black]: [/COLOR][COLOR=blue]Gosub [/COLOR][COLOR=black]Send[/COLOR]
[COLOR=blue]Sertxd([/COLOR][COLOR=red]"Done"[/COLOR][COLOR=black], [/COLOR][COLOR=blue]CR[/COLOR][COLOR=black], [/COLOR][COLOR=blue]LF )[/COLOR]
[COLOR=green];
; Flash LEDs (if C.0 low)
;[/COLOR]
[COLOR=blue]do
      if [/COLOR][COLOR=purple]pinC.0 [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]0 [/COLOR][COLOR=blue]then
            high B.2[/COLOR][COLOR=black], [/COLOR][COLOR=blue]B.5
            pause [/COLOR][COLOR=navy]500
            [/COLOR][COLOR=blue]low B.2[/COLOR][COLOR=black], [/COLOR][COLOR=blue]B.5
            pause [/COLOR][COLOR=navy]2000
      [/COLOR][COLOR=blue]endif
loop
      [/COLOR]
[COLOR=black]Send:
 [/COLOR][COLOR=blue]SetFreq [/COLOR][COLOR=black]BAUD_FREQ
 [/COLOR][COLOR=blue]Pause [/COLOR][COLOR=navy]10
 [/COLOR][COLOR=blue]SerOut TX[/COLOR][COLOR=black], [/COLOR][COLOR=blue]BAUD[/COLOR][COLOR=black], [/COLOR][COLOR=blue]( [/COLOR][COLOR=navy]$7E[/COLOR][COLOR=black], [/COLOR][COLOR=navy]$FF[/COLOR][COLOR=black], [/COLOR][COLOR=navy]$06[/COLOR][COLOR=black], [/COLOR][COLOR=purple]cmd[/COLOR][COLOR=black], [/COLOR][COLOR=navy]$00[/COLOR][COLOR=black], [/COLOR][COLOR=purple]arg[/COLOR][COLOR=black].msb, [/COLOR][COLOR=purple]arg.lsb[/COLOR][COLOR=black], [/COLOR][COLOR=navy]$EF [/COLOR][COLOR=blue])
 SetFreq MDEFAULT
 Return
 
 [/COLOR]
 

jensmith25

Senior Member
Hi Alan,

This is the code that works to play the MP3 player in a continuous loop. We had to amend the code from the Picaxe standard via instruction PDF because we need it in a continuous loop rather than playing one track after another with a pause in between. There's a SPE035_Full_Instructions.pdf that gives you a lot more commands you can use.

I just need the LEDs to flash while the MP3 player is playing, preferably a 0.5sec flash with a 2 sec pause so it's a quick flash every 2 seconds. I don't need C.0 - I was just trying that to see if it would work as that's an example in the Picaxe instructions using the onboard switch, but it doesn't work for flashing, only static on/off.

Code:
#Picaxe 14M2

' Play mp3 files on audio pcb Axe171 in continuous loop
' © Small Scale Lights / JS Miniatures 2016 - 2017

Symbol TX = B.4
Symbol RX = C.3
Symbol BUSY_PIN = pinC.2
Symbol BAUD_FREQ = M8
symbol mdefault = m4
Symbol BAUD = T9600_8
Symbol cmd = b0
Symbol arg = w1 ; b3:b2
Symbol arg.lsb = b2
Symbol arg.msb = b3
Symbol varA = w2

High B.2, B.5

High TX ; set TX pin high for idle high serial
Pause 2000
SerTxd("Starting", CR, LF )
SerTxd("Select microSD Card", CR, LF )
cmd = $09 : arg = $0002 : Gosub Send
Pause 4000
SerTxd("Set volume 16", CR, LF )
cmd = $06 : arg = 16 : Gosub Send
Pause 1000

' Play track 1
cmd = $12 : arg = $0001 : Gosub Send

' Repeat forever
cmd = $08 : arg = $0002 : Gosub Send

Sertxd("Done", CR, LF )
Stop

Send:
 SetFreq BAUD_FREQ
 Pause 10
 SerOut TX, BAUD, ( $7E, $FF, $06, cmd, $00, arg.msb, arg.lsb, $EF )
 SetFreq MDEFAULT
 Return
 
 end
 

jensmith25

Senior Member
I only suggested the multi-tasking approach, because I thought this was going to 'grow' into a bigger project.

Would this code do what you want? (it's your code, with the LED stuff moved after the MP3 stuff)

Code:
[COLOR=navy]#Picaxe [/COLOR][COLOR=black]14M2[/COLOR]
[COLOR=green]' Play mp3 files on audio pcb Axe171 in continuous loop
' © Small Scale Lights / JS Miniatures 2016-2017[/COLOR]
[COLOR=blue]Symbol TX [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=blue]B.4
Symbol RX [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=blue]C.3
Symbol [/COLOR][COLOR=purple]BUSY_PIN [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=purple]pinC.2[/COLOR]
[COLOR=blue]Symbol [/COLOR][COLOR=black]BAUD_FREQ [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=blue]M8
symbol mdefault [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=blue]m4
Symbol BAUD [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=blue]T9600_8
Symbol [/COLOR][COLOR=purple]cmd [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=purple]b0[/COLOR]
[COLOR=blue]Symbol [/COLOR][COLOR=purple]arg [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=purple]w1 [/COLOR][COLOR=green]; b3:b2[/COLOR]
[COLOR=blue]Symbol [/COLOR][COLOR=purple]arg[/COLOR][COLOR=black].lsb [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=purple]b2[/COLOR]
[COLOR=blue]Symbol [/COLOR][COLOR=purple]arg.msb [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=purple]b3[/COLOR]
[COLOR=blue]Symbol [/COLOR][COLOR=purple]varA [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=purple]w2[/COLOR]
[COLOR=blue]High TX [/COLOR][COLOR=green]; set TX pin high for idle high serial[/COLOR]
[COLOR=blue]Pause [/COLOR][COLOR=navy]2000[/COLOR]
[COLOR=blue]SerTxd([/COLOR][COLOR=red]"Starting"[/COLOR][COLOR=black], [/COLOR][COLOR=blue]CR[/COLOR][COLOR=black], [/COLOR][COLOR=blue]LF )
SerTxd([/COLOR][COLOR=red]"Select microSD Card"[/COLOR][COLOR=black], [/COLOR][COLOR=blue]CR[/COLOR][COLOR=black], [/COLOR][COLOR=blue]LF )[/COLOR]
[COLOR=purple]cmd [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]$09 [/COLOR][COLOR=black]: [/COLOR][COLOR=purple]arg [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]$0002 [/COLOR][COLOR=black]: [/COLOR][COLOR=blue]Gosub [/COLOR][COLOR=black]Send[/COLOR]
[COLOR=blue]Pause [/COLOR][COLOR=navy]4000[/COLOR]
[COLOR=blue]SerTxd([/COLOR][COLOR=red]"Set volume 16"[/COLOR][COLOR=black], [/COLOR][COLOR=blue]CR[/COLOR][COLOR=black], [/COLOR][COLOR=blue]LF )[/COLOR]
[COLOR=purple]cmd [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]$06 [/COLOR][COLOR=black]: [/COLOR][COLOR=purple]arg [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]16 [/COLOR][COLOR=black]: [/COLOR][COLOR=blue]Gosub [/COLOR][COLOR=black]Send[/COLOR]
[COLOR=blue]Pause [/COLOR][COLOR=navy]1000[/COLOR]
[COLOR=green];     if pinC.0 = 0 then
;     do
;           high B.2, B.5
;           pause 500
;           low B.2, B.5
;           pause 2000
;     loop
;     endif
      
' Play track 1[/COLOR]
[COLOR=purple]cmd [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]$12 [/COLOR][COLOR=black]: [/COLOR][COLOR=purple]arg [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]$0001 [/COLOR][COLOR=black]: [/COLOR][COLOR=blue]Gosub [/COLOR][COLOR=black]Send[/COLOR]
[COLOR=green]' Repeat forever[/COLOR]
[COLOR=purple]cmd [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]$08 [/COLOR][COLOR=black]: [/COLOR][COLOR=purple]arg [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]$0002 [/COLOR][COLOR=black]: [/COLOR][COLOR=blue]Gosub [/COLOR][COLOR=black]Send[/COLOR]
[COLOR=blue]Sertxd([/COLOR][COLOR=red]"Done"[/COLOR][COLOR=black], [/COLOR][COLOR=blue]CR[/COLOR][COLOR=black], [/COLOR][COLOR=blue]LF )[/COLOR]
[COLOR=green];
; Flash LEDs (if C.0 low)
;[/COLOR]
[COLOR=blue]do
      if [/COLOR][COLOR=purple]pinC.0 [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]0 [/COLOR][COLOR=blue]then
            high B.2[/COLOR][COLOR=black], [/COLOR][COLOR=blue]B.5
            pause [/COLOR][COLOR=navy]500
            [/COLOR][COLOR=blue]low B.2[/COLOR][COLOR=black], [/COLOR][COLOR=blue]B.5
            pause [/COLOR][COLOR=navy]2000
      [/COLOR][COLOR=blue]endif
loop
      [/COLOR]
[COLOR=black]Send:
 [/COLOR][COLOR=blue]SetFreq [/COLOR][COLOR=black]BAUD_FREQ
 [/COLOR][COLOR=blue]Pause [/COLOR][COLOR=navy]10
 [/COLOR][COLOR=blue]SerOut TX[/COLOR][COLOR=black], [/COLOR][COLOR=blue]BAUD[/COLOR][COLOR=black], [/COLOR][COLOR=blue]( [/COLOR][COLOR=navy]$7E[/COLOR][COLOR=black], [/COLOR][COLOR=navy]$FF[/COLOR][COLOR=black], [/COLOR][COLOR=navy]$06[/COLOR][COLOR=black], [/COLOR][COLOR=purple]cmd[/COLOR][COLOR=black], [/COLOR][COLOR=navy]$00[/COLOR][COLOR=black], [/COLOR][COLOR=purple]arg[/COLOR][COLOR=black].msb, [/COLOR][COLOR=purple]arg.lsb[/COLOR][COLOR=black], [/COLOR][COLOR=navy]$EF [/COLOR][COLOR=blue])
 SetFreq MDEFAULT
 Return
 
 [/COLOR]
That's working!!!!

So when I did try moving the LED code to the end the bit I did wrong was having the
Code:
 Sertxd("Done", CR, LF )
after the LEDs rather than before and you've removed the 'stop' command?

Thanks very much, that's made my day!
 

PhilHornby

Senior Member
The Sertxd just outputs text to the PC/debugging interface.

I moved the loop that turns the LEDS on/off to the end of the program - so it runs after the SPE035 has been set up. It's a LOOP - it never terminates - so no need for STOP. You can remove the test for C.0 being low, if that's not a required part of the design.
 

AllyCat

Senior Member
Hi,

Glad that it's working.

Just a couple of tips for the future: Put a #TERMINAL 4800 very near the top of the program; it may show what some of the SERTXD commands are for - a powerful debugging tool.

Also, try a IF PINC.0 = 1 THEN : RESET : ENDIF line within the LED flashing loop. It should give you an "escape" function to start the player again, or GOTO/GOSUB to any additional function that might be required (change track or toggle the LEDs on/off, etc.).

Cheers, Alan.
 
Top