Inter PICAXE serial communications advice? -SOLVED-

Main code summary: The 28X2 raises a pin high, triggering the interrupt on the 08M2. The 28X2 then sends a number (1 to 5) via serial connection to the waiting 08M2. The 08M2 then I2Cs the correct bits to an I/O expander to turn on an LED pattern:

28X2:

main:{
for b28 = 1 to 5
 LED_code = b28
 'debug
 call I2C_LED_code
 pause 1000
next b28
goto main
}
I2C_LED_code:{
high serint
pause 2
low serint
pause 2
serout ser_pin,N2400_8,(LED_code) 'set for triggering the interrupt with 08M2
return
}

08M2:

HI2CSETUP I2CMASTER, PCF_byte, i2cfast, i2cbyte 'set for I/O expander I2C
setfreq m8
setint %00010000,%00010000 'reset interrupt; rising edge,serint pin
}
main:{
serin ser_pin,N2400_8,LED_byte
if LED_byte <> LED_byte_hist then
 select case LED_byte
  case 0
   goto main
  case 1 'looking
   call looking
  case 2 'locked
   call locked
  case 3 'alert
   call alert
  case 4 'startup on
   call startup_on
  case 5
   call startup_off
 end select
endif
goto main
}
looking:{
hi2cout latch_register, (blue)
return
}
locked:{
hi2cout latch_register, (green)
return
}
alert:{
hi2cout latch_register, (red)
return
}
startup_on:{
hi2cout latch_register, (white)
return
}
startup_off:{
hi2cout latch_register, (none)
return
}
interrupt:{
serin ser_pin,N2400_8,LED_byte
setint %00010000,%00010000 'reset interrupt; state,pin
return
}

Believe me when I tell you the pins are connected correctly like the interrupt going to C.4, etc etc etc. No special resistors involved either. I tried pullups/downs out of frustration and they didn't result in anything different. I can get a non-interrupt version of the program to work fine but the above gets me nothing. I've spent several days on this and I'm having varing degrees of non-success. I'm getting ready to cry blue smoke here.

FWIW I'm trying to get the serial communications done on the C.3 pin of the 08M2 and the C.3 pin of the 28X2. I know the C.3 pin needs an external diode on th 08M2 for serin commands but it doesn't make a difference if it's there or not. I even had the serial byte get picked up on C.4 when it should have been on C.3. I'm chalking that up to a low battery but this is the kind of thing that's making me nuts-o-bonkers-crazy. I even moved the serial in line to C.4 on the 08M2 but the results were the same.

Ok, time for some thumb sucking and then some sleep. Four days wasted on this bug. Thanks for lookin.

PFR

Hey Jax as per our conversation in shoutbox you really need some feedback on what is going wrong. Like with an led on a spare pin.  If you can get a non-interrupt version of the program working then I would immediately put a line in the interrupt routine to light your test LED on generation of the interrupt.

If the led fails to light then look before this point for why the interupt routine is not being entered. If it does light then the interrupt works and most likely it’s an I2C issue. Have you got the pullups on the I2C bus?

Have you written the schematic down on paper to follow and check against as you wired it up? Making notes as you go helps often. There’s nothing worse than de javu with a problem.

 

 

Maybe I2C

I suggest the problem is that you don’t define i2cfast_8 in the i2c initialixation sequence but run at 8mhz.

Yeah, damn. The interrupt is

Yeah, damn. The interrupt is on the right pin. The bits read backward (MSB…LSB??) so it reads “%76543210.” Good eyes though. My heart got all rabbity for a second lol

I had problems figuring out what you were talking about…

… because I didn’t know I had to do that lol I rarely change frequencies. Should have read the manual better :slight_smile: What’s strange is it works ok without the interrupt in the mix but I will sure as hell plug this in when I get home, thx m8!

Excellent advice

Didn’t even consider an LED test. I forget the easy methods sometimes, good suggestion.

I have my schematic on eaglecad and have pored over it with the breadboard extensively. Extensively lol

Yes to the pullups as well. Standard 4.7K units.

 

I gave it a go but no change.

I used the “_8” I2C setup switch for both the 08 and 28 but nothing worked right. If I just sit there and stare at it (which I did a lot of) the LEDs will change every minute or so. Besides that I can tell there is definitely something wrong. There are two ports on the IO expander which aren’t coded to be active. I have a yellow LED hooked up one of them and on occasion something happens that turns that yellow LED on. The mystery continues.

Next steps

I’ve got to go fix a TV for a friend tonight but afterwards I’m going to dig into this badboy. I’ll do the LED testing like merser suggested and then if there is nothing gained, the physical teardown and rebuild of the circuit and start from v.0.1

Hate is a very stong word. That being said, I hate the teardown/rebuild thing.

Hardware issue

The PICAXEs didn’t seem to like the breadboard config I had. The 08M2 was plugged into the breadboard directly, no programming jack, with bypass caps. I yanked it out of the breadboard and installed it in an old PICAXE 08 Protoboard I have. Then I plugged the protoboard into the circuit and everything started working. For giggles I plugged things back together the way they were and I started getting garbled transmissions again.

Thanks for everyone’s input. The help was A+.

The code that worked: 


28X2:

setfreq m16
pause 5000
main:{
for b28 = 1 to 5
 LED_code = b28
 debug
 call I2C_LED_code
 pause 2000
next b28
goto main
}
I2C_LED_code:{
high ser_pin 'serial pin now doubles as interrupt trigger
pause 1
low ser_pin
serout ser_pin,N2400_16,(LED_code) 'set for triggering the interrupt with 08M2
return
}

 

08M2:

HI2CSETUP I2CMASTER, PCF_byte, i2cfast_16, i2cbyte 'set for I/O expander I2C
setfreq m16
setint %00001000,%00001000 'serial pin doubles as the interrupt
}
main:{
if LED_byte <> LED_byte_hist then
 LED_byte_hist = LED_byte
 select case LED_byte
  case 0
   goto main
  case 1
   call looking
  case 2
   call locked
  case 3
   call alert
  case 4
   call startup_on
  case 5
   call startup_off
 end select
endif
goto main
}
looking:{
hi2cout latch_register, (blue)
return
}
locked:{
hi2cout latch_register, (green)
return
}
alert:{
hi2cout latch_register, (red)
return
}
startup_on:{
hi2cout latch_register, (white)
return
}
startup_off:{
hi2cout latch_register, (none)
return
}
interrupt:{
serin ser_pin,N2400_16,LED_byte
debug
setint %00001000,%00001000 'reset interrupt; state,pin
return
}

Yay \o/

Good news Jax. Yes breadboards can cause problems. I think I told you I had a similar problem when I had a 433 mhz transmitter and receiver plugged into breadboards and I couldn’t get them to work. My hallelujah moment came when I  unplugged them and just connected individual wires to them.

Can’t wait to see what your working on.