Picaxe 08M2 and 28X2 doesn't talk to each other.

Lobobo

Member
Hi.
I have a problem to make communicating two chips. I have to send temperatures, but I stuck on first step just testing to send some byte. I'm trying to send one byte from chip 08M2 to chip 28X2. I have connected some capacitors (u1K63) next to both chips between positive and ground and grounded both communication lines (RX and TX) thorough resistor 4K7 ohm. Programs of both chips atached. Unfortunately debuger of 28X2 shows various accidental values, but not what I'd expect. Any suggestions?
Thanks
Code:
#Picaxe 08M2
setfreq M16
SYMBOL TX   	= C.0 	'serial transmit pin connected to 28X2 pin C.0
SYMBOL index	= b0
'-----------------------------------------------------------------------------------------------
main: 
	pause 3000
	inc index
	debug
	serout TX, N2400_16, (index)
goto main
'-----------------------------------------------------------------------------------------------
Code:
#picaxe 28x2
Setfreq M16 			'Run at overclocked speed of 16 Mhz
Symbol RX   	= C.0 	'serial receive pin connected to 08M2 pin C.0
Symbol TX   	= A.3 	'serial transmit pin connected to 08M2 pin C.1
symbol index	= b0

'----------------------------------------------------------------------------------------------------
main:
	serin [2000], RX, N2400_16, index
	debug
goto main
'----------------------------------------------------------------------------------------------------
 

Goeytex

Senior Member
I have connected some capacitors (u1K63) next to both chips between positive and ground and grounded both communication lines (RX and TX) thorough resistor 4K7 ohm.
What communications lines? Please give pin numbers or Provide a schematic. Why have you tied these lines to ground through a resistor?
----------------------------------------------------------------------------------------------------------


On the 08M2, you are using the same Pin (C.0) for serout that Debug uses. Change the serout pin on the 08M2 to C.1 and serin to C.2.

Instead of using Debug, try using sertxd to display data in the terminal. Try to code below and see what happens

And as advised above both Picaxe chips must share a common ground.

Code:
#Picaxe 08M2
setfreq M16
SYMBOL TX   	= C.1 	'serial transmit pin connected to 28X2 pin C.1  ( Changed by Goeytex)
SYMBOL index	= b0
'-----------------------------------------------------------------------------------------------
main: 
	pause 3000
	inc index
	rem debug                                 '//Disable debug for serial testing 
	serout TX, N2400_16, (index)
goto main
'------------------


Code:
#picaxe 28x2
#terminal 19200
Setfreq M16 			'Run at overclocked speed of 16 Mhz
Symbol RX   	= C.0 	'serial receive pin connected to 08M2 pin C.1
Symbol TX   	= A.3 	'serial transmit pin connected to 08M2 pin C.2
symbol index	= b0
pause 4000    ;Give Terminal time to open
'----------------------------------------------------------------------------------------------------
main:
	serin [2000,timeout], RX, N2400_16, index    '// Added timeout label for diagnostics 
	sertxd (#index,cr,lf)                                   ;//Instead of debug
goto main

timeout:
sertxd ("Serin Timeout",cr,lf)
goto main

'----------------------------------------------------------------------------------------------------
 
Last edited:

Technical

Technical Support
Staff member
In the original received program you have a timeout of 2 (/2 = 1) seconds, but the transmitter only sends a byte every 3 (/4 = 0.75) seconds (excluding debug processing time, which needs to be included in the total loop time).

Therefore the receiver can regularly timeout and start the (long processing time) debug command. Hence when the transmitter sends whilst the receiver is already busy 'debugging' then you will get missed/corrupt data.

Take the timeout out completely and try again.
 

Lobobo

Member
Thank you guys. Sorry for not responding instantly (Had to complete another project). You guys opened my eyes on debug pin. Fixed that and great success! Also thank you "Goeytex" for advice how to change debug command with other way of displaying data.
I love this game (Picaxe)!
 
Top