Disconnect Bug

Danderson

New Member
Interesting bug with the DISCONNECT command.
Had me going for awhile...


Code:
'Disconnect bug
'
'Initially tried with a 16mhz resonator on 28x1 firmware version A3
'tried removing resonator
'what appears to happen is an unexpected reset occurs about 10ms
'after the disconnect is issued
'I think I narrowed it down to a relationship with the i2cslave speed
'parameter. I'm using a NANO USB I/F running hyperterms terminal program
'at 9600 baud for an interface.
'what you will see:
'
'Read Parms
'Read Parms
'Main

'as expected, you see it doing the Read Parms routine
'Then, a second Read Parms routine (which shouldn't be here)
'and then the do nothing loop at Main.
'if you comment out the disconnect command, it works with
'either i2cslave speed settings
	setfreq m8	'terminal at 9600
	disconnect
	gosub read_parms
main:
	sertxd ("Main",cr,lf)	'got to here	
do_nothing:	
	pause 1000
	goto do_nothing		
'*********************************************************
Set_24LC_SLAVE:
'*********************************************************
'	i2cslave %10100000, i2cfast, i2cword '24LC256 = 10100000
	i2cslave %10100000, i2cfast_8, i2cword '24LC256 = 10100000
	return
'*********************************************************
Read_Parms:		'loads saved parms from eeprom
'*********************************************************
	sertxd ("Read Parms",cr,lf)	'got to here
	gosub Set_24LC_SLAVE
	w5=$2000	'place to read
	for b6=$50 to $7E	'place to write
	hi2cin [%10100000],w5,(b0)	'read byte from eeprom
	poke b6,b0	'write byte
	inc w5
	next
	return
 

Technical

Technical Support
Staff member
Are you sure it is the disconnect causing issue, this is unlikely considering its function.
Try putting a sertxd("reset") at the top of your program.

The likely cause of the reset is an i2c communication error. If a hardware i2c transaction does not complete correctly within 2.3 seconds the PICAXE will reset. Check your i2c hardware and maybe put a pause in the for...next loop. You can test this by taking the i2c chip out of the circuit completely - do you get similiar behaviour?
 
Top