Serin Problem with VMusic

adumas

Member
Hi... I have been able to get Vmusic to work great, having various push buttons configured directly to the input pins.

In the spirit of trying to better the result, I am now trying to externalize the push buttons so that they are wired to a 08m and the 08m sends serial messages to the 28x1. The goal is to have a number of different 08m chips do different things..

My problem is that when I mix serin and hserin commands both commands seem to fail and I can not get either to work. If I comment out the serin message, then hserin works.

I'm attaching the code and if possible, could someone show me / fix / explain what the syntax should be?

I would greatly appreciate it....
 

Attachments

hippy

Technical Support
Staff member
The problem most likely seems to be in your 'main' loop. To start playing music you check the state of Set_Sw3 (pin3) and start playing when that pin goes high. If the pin isn't high the first time through it enters SerIn where it will wait forever until some data is received.

If data is being sent and received then you'll need to post what the SerTxd status reports are so we can see where the code is going, guess what it's doing and why it may not be working.
 

adumas

Member
You're right..

I commented out the "If Set_Sw3 = 1 Then Interrupt3" and then when I pressed on the push button I get the received value of 2 - which means the 2 chips are talking...

If I then take out the If set_sw3 and then do a goto Interrupt3, that works as well...

e.g.

pause 100

'receive from 08m
serin 1,n2400,b5 'receive external input from 08m

'transmission from 08m = serout 2,n2400,(16)

pause 100

goto Interrupt3

sertxd ("serin activated - end of loop: ",#b5,CR,LF)


If I take out the goto Interrupt3, every time I push the swtich I will correctly send data.

So I'm down to how to be able to have both a serin call and an If statement (If Set_Sw3 = 1 Then Interrupt3) within the same loop structure..
 
Last edited:

hippy

Technical Support
Staff member
It's either one or the other; command via SerIn or detect a button push using If. You could create a more complex connection to the 08M so the 28X1 can tell when the 08M has something to send and read that so it never enters SerIn unless it has to, thus it loops waiting for either a button push or command available.

You might get somewhere with adding timeouts to the SerIn but there's a good chance of missing something sent by the 08M. You could also use real interrupts.

Really it boils down to a design issue and overcoming the blocking nature of SerIn. It should be possible to get this working with what you have but might need an extra I/O line to tell the 08M when it can send.
 

adumas

Member
ewwwwww.... That's a bummer...

My design idea was to split the input between 2-4 08m's and a pic28x1 - no real reason - just wanted to see if I could externalize things...

I've been playing with timeouts - no great reasult...

And hitting the buttons simulatenously - rarely it works...

So I'm up a creek?
 

hippy

Technical Support
Staff member
You're not entirely screwed as long as you have a means of being able to control when the 08M's send, ie a spare I/O line.

What you need to do is treat the 08M input to the 28X1 as a button input, so when the line goes high you know the 08M has something to send. You tell it to send and then enter SerIn until it does. For the 08M's part, it sets the line to say it has something to send, waits to be told to send, then sends it.

This can all be done with two lines, one from the 08M, one back. A more complicated setup could perhaps multiplex multiple 08M's to just two lines.

- Do
--- If ButtonPushed Then
----- HandleButtonPush
--- Else
----- If 08mWantsToSend Then
------- Set08mCanSendLine
------- ReadFrom08m
------- Clear08mCanSendLine
------- ObeyCommandReceived
----- End If
--- End If
- Loop
 

adumas

Member
Hi Hippy - thanks for the responses...

I'm not sure what to do regarding the algorithm you provided...

This is still new to me - so I need a bit more to work from.

Do you have any sample code?

I've been reading like crazy but I'm not sure how to do what you say...
 
Last edited:
Top