Hi everyone, I was hoping I could find someone who could tell me what stupid thing I'm doing wrong. I'm a newbie to PICAXE (though I've used straight PICs one or twice.) so I'm probably doing something really stupid.
Here's my issue. I'm trying to interface my 28x1 PICAXE with the DS1307 realtime clock, (Mounted on the sparkfun breakout board) and display some text to a small lcd.
My problem is that every time my program gets to the hi2cin call my program restarts. It does this regardless of whether the clock chip is even connected! The only time the code EVER gets past the hi2cin call is if the clock chip is connected, but its ground isn't. (This strikes me as very telling, but I don't know what it's telling me.)
Here is the code I'm trying to use :
And here is the output I get off of the LCD (Notice how the first five characters are garbage. I don't know if that's a related issue or not.)
It never blinks the LED, or prints the "Seconds" line. (Unless, like I said earlier, I connect the RTC, but disconnect its ground.)
The "FAKE RESET!" line also never prints. (I had the idea that some undefined jump or interrupt might be jumping back to main.)
So... I would greatly appreciate it if someone could point me in the right direction. I have tried this with both the SparkFun breadboard power supply and with a simpler arrangement of a some batteries and a power regulator. I'm sort of operating under the assumption that there's some setting that I've forgotten to set or some switch I've forgotten to throw, but I've got no idea what that would be.
Thank you.
(Here's a photograph here if that's of any help. (2.2mb) )
-Andy
Here's my issue. I'm trying to interface my 28x1 PICAXE with the DS1307 realtime clock, (Mounted on the sparkfun breakout board) and display some text to a small lcd.
My problem is that every time my program gets to the hi2cin call my program restarts. It does this regardless of whether the clock chip is even connected! The only time the code EVER gets past the hi2cin call is if the clock chip is connected, but its ground isn't. (This strikes me as very telling, but I don't know what it's telling me.)
Here is the code I'm trying to use :
Code:
' Set the chip type
#picaxe 28x1
main:
' Set the chip to operate at 8hz
setfreq m8
if b8 = 42 then fakeReset
b8 = 42
wait 1
serout 0, T9600_8, (" Setting up I2C..." )
HI2CSETUP I2CMASTER, %11010000, i2cslow_8, i2cbyte
wait 1
mainloop:
serout 0, T9600_8, (" Getting time ..." )
wait 1
gosub getTime
wait 1
serout 0, T9600_8, ("Seconds ", b2, b3)
'Blink the LED after sucessfully getting and printing the time.
wait 1
pin1 = 1
wait 1
pin1 = 0
wait 3
goto mainloop
getTime:
hi2cin 0, (b1) ' Pull in the seconds from the clock chip.
'b1 = %01000010
bcdtoascii b1,b2,b3 ' Convert the seconds to asci seconds
return
fakeReset:
serout 0, T9600_8, ("FAKE RESET!")
goto mainloop
(That's not actually a square root, but some similar symbol I don't recognize.)#n]vww√ng up I2C... Getting time... #n]vww√ng up I2C... Getting time... #n]vww√ng up I2C... Getting time...
It never blinks the LED, or prints the "Seconds" line. (Unless, like I said earlier, I connect the RTC, but disconnect its ground.)
The "FAKE RESET!" line also never prints. (I had the idea that some undefined jump or interrupt might be jumping back to main.)
So... I would greatly appreciate it if someone could point me in the right direction. I have tried this with both the SparkFun breadboard power supply and with a simpler arrangement of a some batteries and a power regulator. I'm sort of operating under the assumption that there's some setting that I've forgotten to set or some switch I've forgotten to throw, but I've got no idea what that would be.
Thank you.
(Here's a photograph here if that's of any help. (2.2mb) )
-Andy