m41t00 I2C clock chip testing
Problem is I'm not there to actually test the chip yet.
I've posted the data sheet. Interesting chip, seems to have an internal osc. Though it has connections for an external osc. An interesting side note, it has a output around 512hz. 512hz is perfect timing, any error of that is an error of timing. That can be corrected using the control bits. Makes me wonder if the SX can measure the difference to calculate the appropriate control bits for correction?
So on to the error. No external osc is used yet, using the sxkey usb. Using the same power supply on both. Doesn't matter if external circuity is used or not. The code seems to program, debug, just fine on the SX48 proto board. However on the SXtech board, it will program, debug up to the point of hitting the run/walk/step key on the debug screen, then unlike the sx48 protoboard, says "sleep".
The only code changes between the two is sx48 vs sx28 plus TURBO, STACKX, OPTIONX. I tried the sx28 without the TURBO, STACKX, OPTIONX and it did the same thing.
I figure pin 1 on the m41t00 is the bottom, left most one, with the pins on the top and bottom, reading the words right side up. Using a cr2032 battery for backup, SDA and SCL are each tied to VDD via 4.69kohm external resistors.
Post Edited (Capdiamont) : 7/19/2008 4:34:37 PM GMT
I've posted the data sheet. Interesting chip, seems to have an internal osc. Though it has connections for an external osc. An interesting side note, it has a output around 512hz. 512hz is perfect timing, any error of that is an error of timing. That can be corrected using the control bits. Makes me wonder if the SX can measure the difference to calculate the appropriate control bits for correction?
So on to the error. No external osc is used yet, using the sxkey usb. Using the same power supply on both. Doesn't matter if external circuity is used or not. The code seems to program, debug, just fine on the SX48 proto board. However on the SXtech board, it will program, debug up to the point of hitting the run/walk/step key on the debug screen, then unlike the sx48 protoboard, says "sleep".
The only code changes between the two is sx48 vs sx28 plus TURBO, STACKX, OPTIONX. I tried the sx28 without the TURBO, STACKX, OPTIONX and it did the same thing.
I figure pin 1 on the m41t00 is the bottom, left most one, with the pins on the top and bottom, reading the words right side up. Using a cr2032 battery for backup, SDA and SCL are each tied to VDD via 4.69kohm external resistors.
' ------------------------------------------------------------------------- ' Program Description ' ------------------------------------------------------------------------- ' tests clock chip m41t00 I2C ' init with most current time ' pauses Maxdelay time, then gets current time ' two subs 1)settime starts comm, sends byte 0, 0, sends info(8 bytes), stops comm ' 2)gettime starts comm, sends byte 0, starts, receieves info(8 bytes), stops comm ' RA.2=SDA ' zero byte, need to send before read or write = slave address bit 7 is read/write ' bit 7=1 is read, 0=write ' 1st byte: seconds register '2nd byte: minutes register '3rd byte: century/hours register '4th byte: day register '5th byte: date register '6th byte: month register '7th byte: years register '8th byte: control register ' ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX IRC_CAL IRC_4MHZ FREQ 4_000_000 ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- ' PORT RA 4 bit reserve for serial on all programs, unused set to outout low ' port rb 8 bit, input ' port rc 8 bit, output ' port rd and re 8 bit, unused set to output, low RAUnused PIN RA OUTPUT 'serial comms RBUnused PIN RB INPUT PULLUP 'buttons RCUnused PIN RC OUTPUT 'motor control SDA PIN RA.2 INPUT 'clock chip SDA SCL PIN RA.3 INPUT 'clock chip SCL ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- 'on delay time, wait period between on/off, word size MaxDelay CON 50 Debounce CON 1 Pressed CON 0 SlaveID CON $D0 ' clock chip m41t00 I2C Ack CON 0 Nak CON 1 ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- 'delaytemp, wait time counter, word size DelayTemp VAR Word TempVAR VAR Byte Time VAR Byte(9) ' zero byte, need to send before read or write = slave address bit 7 is read/write Loc VAR Time(0) 'addres of device RW VAR Loc.7 ' bit 7=1 is read, 0=write ' 1st byte: seconds register Seconds VAR Time(1) '2nd byte: minutes register Minutes VAR Time(2) '3rd byte: century/hours register Chours VAR Time(3) '4th byte: day registerDate Day VAR Time(4) '5th byte: date register Date VAR Time(5) '6th byte: month register Month VAR Time(6) '7th byte: years register Years VAR Time(7) '8th byte: control register Control VAR Time(8) 'mode, auto, unlocked, locked, inonly, outonly 'ModeTemp Var Byte 'SwitchTemp Var Bit watch DelayTemp watch TempVAR 'watch Loc watch Seconds watch Minutes watch Chours watch Day 'watch Date 'watch Month 'watch Years 'watch Control ' ------------------------------------------------------------------------- ' INTERRUPT ' ------------------------------------------------------------------------- 'ISR_Start: ' ISR code here 'ISR_Exit: ' RETURNINT ' {cycles} ' ========================================================================= PROGRAM Start ' ========================================================================= 'Pgm_ID: ' DATA "time", 0 ' ------------------------------------------------------------------------- ' Subroutines / Jump Table ' ------------------------------------------------------------------------- Settime SUB 0 Gettime SUB 0 Inittime SUB 0 Delayloop SUB 0 ' ------------------------------------------------------------------------- ' Program Code ' ------------------------------------------------------------------------- Start: ' initialization code here 'Inittime Main: DO Delayloop Gettime LOOP ' ------------------------------------------------------------------------- ' Subroutine Code ' ------------------------------------------------------------------------- SUB Inittime 'runs for 1st time, sets varables Loc = SlaveID Seconds = 0 Minutes = 4 Chours = 22 Day = 5 Date = 17 Month = 7 Years = 8 Control = 0 Settime ' send the varables to clock chip ENDSUB SUB Settime ' send varables to clock chip 'settime starts comm, sends byte 0, 0, sends info(8 bytes), stops comm RW = 0 I2CSTART SDA 'I2CSEND Pin, ByteVal {, AckVar} I2CSEND SDA, Loc I2CSEND SDA, 0 I2CSEND SDA, Seconds I2CSEND SDA, Minutes I2CSEND SDA, Chours I2CSEND SDA, Day I2CSEND SDA, Date I2CSEND SDA, Month I2CSEND SDA, Years I2CSEND SDA, Control I2CSTOP SDA ENDSUB SUB Gettime ' get time from chip 'gettime starts comm, sends byte 0, starts, receieves info(8 bytes), stops comm I2CSTART SDA 'I2CSEND Pin, ByteVal {, AckVar} RW = 0 'write 1st I2CSEND SDA, Loc I2CSTART SDA RW = 1 I2CSEND SDA, Loc 'now set up to read 'I2CRECV Pin, ByteVar, AckVal I2CRECV SDA, Seconds, Ack I2CRECV SDA, Minutes, Ack I2CRECV SDA, Chours, Ack I2CRECV SDA, Day, Ack I2CRECV SDA, Date, Ack I2CRECV SDA, Month, Ack I2CRECV SDA, Years, Ack I2CRECV SDA, Control, Ack I2CSTOP SDA ENDSUB SUB Delayloop 'pause for a bit or while PAUSE MaxDelay ENDSUB
Post Edited (Capdiamont) : 7/19/2008 4:34:37 PM GMT
Comments
no extra memory in my time chip.
one has bit 7 as CH/clock halt the other ST/Stop.
24hour only, thus hour byte is different, bit 0-3 are the same hours, but bit 4,5 are the 10 hours on mine, bit 4 is 10 hours on 1307. on mine bit 6 is cb/century bit, bit 7 is ceb, century enable bit.
control byte is also different. Other than that they seem to go in the same order.
mine has bits 0-4 as calibration, then bit5=S/sign for negative positive calibration, bit 6=FT/frequency test bit, bit 7=out/output level
still working through your program vs the data sheet. I don't always have time to play, so much going on.
I tried your program, i figured, at least I'd be able to get serial output. It didn't work. Using parallax usb2ser. I know it is working perfectly, I use it almost weekly, sometimes more.
ra.0----pin 2
ra.1----22kOhm---pin3
nothing else connected, had pin 5 connected to VSS, didn't seem to help.
I figured out, that my pins were reversed, and the sx can't transmit through the 22k resistor. I figured that out with txtest.bs2 code. Now the pc doesn't receive what I expect the sx to transmit.