Serial In pin name?

SD70M

Senior Member
Hi all,

I've read, at various places, that I can use the serial in pin as an additional input.

I've also been reading up on chip to chip comms.

I'm trying to get my head around all of this and the end result would be as follows:

1. command from a PC to master chip
2. master chip send the command to all chips with only the identified chip responding.

I have the idea/code for chip to chip comms and I've been able to communicate both PC to master and master to PC, but the master chip hangs waiting for a command. Is there a way to use an interrupt on the serial in pin and if so what is the serial in pin's name?

I'd like to use the serial in pin so I don't need to add a second stereo jack to the finalised board.

Any thoughts, comments, answers or questions gratefully received.

Angie
 

westaust55

Moderator
Yes, you can use the SerialIn pin with all but some early chips.

Have a look at the Serrxd command.
For other commands using this pin you will also need to read up on the Disconnect command.

After using Disconnect you can use the SerIn command with a Timeout parameter on later chips such as X1 and X2 parts so it does not hang indefinitely.
 

SD70M

Senior Member
@westaust55

Thanks for that.

I already read up on those in the manuals and on the web. Nowhere can I find how to refer to the pin or set an interrupt on it. I'm assuming it can have an interrupt on it so will have to use an 08m2 as the master simply to receive the PC data, then send that out for other chips to listen for with an interrupt.

Angie

[edit] meant 'can't have an interrupt'
 

nick12ab

Senior Member
Nowhere can I find how to refer to the pin or set an interrupt on it. I'm assuming it can have an interrupt on it so will have to use an 08m2 as the master simply to receive the PC data, then send that out for other chips to listen for with an interrupt.
I attempted tgo use the setint command on the 08M2 and with the serial in pin set a syntax error message shows saying that only pins C.1 to C.4 can be used for interrupt.

You could create your own polled interrupt in a loop e.g.
Code:
    do
        if pinC.5 = 1 then gosub interrupt
        'other code
    loop

interrupt:
    serin...
    return
You just use a break signal to tell the PICAXE to start receiving. If there is a lot of code to be put into that loop then you might need to re-use the line if pinC.5 = 1 then gosub interrupt multiple times throughout your code.
 

SD70M

Senior Member
I attempted tgo use the setint command on the 08M2 and with the serial in pin set a syntax error message shows saying that only pins C.1 to C.4 can be used for interrupt.

You just use a break signal to tell the PICAXE to start receiving. If there is a lot of code to be put into that loop then you might need to re-use the line if pinC.5 = 1 then gosub interrupt multiple times throughout your code.
Thanks nick12ab

On the 20m2 there's no pin reference so I'm assuming, unlike the 08m/08m2, the 20m2 serial in pin can only be used as serial data input.
 

Technical

Technical Support
Staff member
That is correct, the M2 architecture supports a maximum of two ports, 16 pins, so the serial in pin on the 20M2 is not part of the general port structure for 'normal' commands.
 

westaust55

Moderator
With an 08M2 or 14M2 part this will work (well, passes synatx check):

Code:
#PICAXE 08M2
DISCONNECT
SERIN [1000], C.5, N2400, ("aaa"), b0  ; times out after 1 second = 1000 ms
 

SD70M

Senior Member
With an 08M2 or 14M2 part this will work (well, passes synatx check):

Code:
#PICAXE 08M2
DISCONNECT
SERIN [1000], C.5, N2400, ("aaa"), b0  ; times out after 1 second = 1000 ms
I think I have the master code which, at present , only responds to the terminal. If I alter the sertxd to serout on another pin I can then send that data around the network of chips. All other chips will be listening on one of the C.x pins using an interrupt.

Code:
#com 3
#picaxe 20M2
#no_data


init:
	symbol chipaddr = 1

main:
	sertxd("Online.....",13,10,"Waiting for data.....",13,10)
	high B.0
	do
		serrxd b0,b1,b2,b3
		low B.0
		sertxd (#b0, "...", #b1,"...",#b2,"...",#b3, " - Received",13,10)
		gosub convertToBinary
		sertxd(#b0,".....", #b1, " - converted",13,10)
		high B.0
	loop
convertToBinary:
	b0 = b0-48*100
	b0 = b1-48*10+b0
	b0 = b2-48+b0
	b1 = b3 - 48
	return
 

nick12ab

Senior Member
Thanks nick12ab

On the 20m2 there's no pin reference so I'm assuming, unlike the 08m/08m2, the 20m2 serial in pin can only be used as serial data input.
That is correct, the M2 architecture supports a maximum of two ports, 16 pins, so the serial in pin on the 20M2 is not part of the general port structure for 'normal' commands.
Previously someone posted that using high A.0 made the serial out pin on the 20M2 high - that could mean that you could read the serial in pin using pinA.1.
 

Technical

Technical Support
Staff member
Previously someone posted that using high A.0 made the serial out pin on the 20M2 high - that could mean that you could read the serial in pin using pinA.1.
No you can't, there is no such thing as pinA.1 on 20 pin parts.
 
Top