Shop OBEX P1 Docs P2 Docs Learn Events
I2C Object and the 8583 RTC with ram — Parallax Forums

I2C Object and the 8583 RTC with ram

Kaos KiddKaos Kidd Posts: 614
edited 2006-06-17 12:05 in Propeller 1
When I got my BS2P, I also got the Plus pack, which contained the 8583 Real Time clock.
I went and checked the data sheets, 2.6v ~ 6.0V... So, it will work without level issues to the propeller.
Following the wiring diagram in the plus pack docs, I connected the device to the prop.· I did use the 4.7K pullups as indicated in the docs.
I downloaded the I2CObject, and included it in the project, which also uses the VGA_Text routine.

After about 2 hours I relized the vga_text needs constants in the calling object setting the freq of the propeller so it would output.

Did it's I2C.Init(SDA,SCL) (which returned true... so the object is started and running.)
Now, for the hard part... Making it work.
I can't seem to get a corrolation between the various methods and their prams and the plus pack docs for using the device, including the datasheet.· For example, the data sheet indicates it's address is %101000[noparse][[/noparse]A0]·
So, by grounding A0, the address would be %1010000.· If I run the devicePresent(deviceAddress) with %1010000 I get a false.
If I run the I2C.Test function, I get the error··_i2cSDAFault, which is prolly due to something stupid I did when connecting the device.
Again, I stress, I did follow, to the pin, the Plus Pack's wiring diagram for the 8583, including the 4.7K pullups.
I'm sure I'v got something wrong, maybe it's the·pullup sizes I'm using, I don't know.

Lastly, I could use some indication how to use the Read / write locations with this device.·
The docs in the Plus Pack use the I2CIN / OUT commands, and I can't figure out how to build the prams needed to read / write to the chip.· If I'm understanding the BS2 demo program correctly, it's creating all the prams into one var for the I2CIN and out commands.
The Docs for the chip give registers, and their meanings and sizes...
SO, for reading from the chip, the best I can come up with is:

I2CData = I2C.readLocation(deviceAddress, deviceRegister, addressbits, databits)
Where deviceAddress = %1010000, deviceRegister = %00 , addressbits = ????????, databits = ??? (The number of bits to return???)
(Which, when I tried the above line with addressbits = 0 (the pram is NOT used in the routine!), and databits = 7, I get 0)

One Idea I have is to remove the pullups, and connect the sda/scl to the boot prom's sda/scl, (the boot prom works great!), thus removing any chance of my having it messed up...

I'm also wondering if I'm going to run into this type of issue when I add the second 32K eeprom.
All three chips·(the boot prom, my prom and the RTC) will be on the 29/28 wires to reduce pin counts
Lastly, (I'm sorry for the runon here...)...
How would I go about putting a led on either the SDA or SCL lines, so I can visually see that the circuit is running?

Again, sorry for the runon, but, on the bright side, my questions have decreased... I am learning...

Thanks..





▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Just tossing my two bits worth into the bit bucket


KK
·

Comments

  • JavalinJavalin Posts: 892
    edited 2006-06-08 16:36
    Hi KK

    >> Following the wiring diagram in the plus pack docs, I connected the device to the prop. I did use the 4.7K pullups as indicated in the docs.
    - good - this is required from the i2c spec. Even if you are using pins 28/29 which are used by the propeller at boot time

    >> If I run the devicePresent(deviceAddress) with %1010000 I get a false.
    - this indicates that the device has not ack'd after its address has been put on the bus. Have you tried the example code for the i2c bus scan. This will scan all address's on the bus from 0-127 and show what acks.

    >> If I run the I2C.Test function, I get the error _i2cSDAFault,
    This is because your SDA line is not being pulled high. If you have a pull up on it, try running the bus with just the lines pulled high - i.e. no devices and try again. This will prove if your device is holding the line low.

    >> I2CData = I2C.readLocation(deviceAddress, deviceRegister, addressbits, databits)
    The parameters for this are:
    deviceAddress = the address of the device - as you have
    deviceRegister = the location within the device (i.e. 0) to ask for
    addressbits = the number of bits to output for deviceRegister. This allows you to read from EEPROMs which require a 16bit register (location)
    databits = the number of bits to read from the register. should be 8

    >>One Idea I have is to remove the pullups, and connect the sda/scl to the boot prom's sda/scl, (the boot prom works great!), thus removing any chance of my having it messed up...
    - yes you could do this - it makes no odds. I've run the code either on its own two pins and also on 28/29 pins

    The datasheet for the RTC shows this to be a 5 volt device so you should also be using 1k resistors on the SDA/SCL lines between the Propeller and the RTC.

    The·application note·(http://www.standardics.philips.com/support/documents/i2c/pdf/an.real.time.clocks.pdf) also shows the slave address to be %1010_0010 so i'd expect a i2cObject.devicePresent($1010_0010) to return true.

    Register $02·might be a better one to read as it should be reading seconds - look at the init proceedure in the above referenced app note.

    Try getting this to work in its own application - to simply the problem and avoid issues.

    Can you post your code?

    Cheers

    james

    Post Edited (Javalin) : 6/8/2006 4:45:10 PM GMT
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-06-08 16:47
    Javalin;
    Thanks for the reply and the advice.
    When I get home I'll post my code, and see if I am infact pulling the lines high...
    Where can I find the spin example code for the i2c bus scan?
    And I'm missing something, is AddressBits is how wide in bits the register is on the device?

    Thanks again for the ideas and help... thanks alot!

    Fred

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • JavalinJavalin Posts: 892
    edited 2006-06-08 16:51
    Hello Fred,

    The i2cbus scan is basically a loop checking devicePresent for 1-127. Look in the zipfile at the PRI i2cScan (at the bottom).

    AddressBits should be 8 on this device - its' only 16 when your sending a deviceRegister of above 255 (%1111_1111).

    (i've updated the post above a bit)

    Cheers,

    James
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-06-09 13:19
    Javalin:
    My sorries, I ran into "issues" last night and didn't get a chance to test or use the information you outlined. I'll do it tonight and get back to you.
    The program is stand alone (the only things in it are vga_text and the i2cobject).
    I'm somewhat confused: The data sheet you pointed to as well as the one I saw say the clock and interface will run on 2.6V ~ 6V, so I should be ok running on 3.3V, right?
    The edits you did on your previous post cleared things up for me, thanks a lot.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • JavalinJavalin Posts: 892
    edited 2006-06-09 13:25
    Hi Fred,

    No worries. If it says 2.6-6v it should be OK on 3.3v.

    James
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-06-12 14:13
    Javalin..
    Well, the bottom line is no luck. I tried everything as outlined above, and in the reading...
    Some extra things I did were:
    From a untitled new spin fine...
    Used the VGA_text and i2c objects..
    (Which, BTW: If your Main code doesn't set the clock freq, vga_text just does not start... no error either... just no output...)
    Inserted some screen formatting commands...
    Copied your scan code from the example app into my app.
    Ran your port scan on 28~29, and it reported a single device, address 160, as I expected, it was the eeprom.
    Powered off, removed the eeprom, reset and run the app agian... didn't find the eeprom...
    Verified your code with my mods work... (Mods made to use the VGA_TEXT, and to display the bin address of any devices found...)
    Next: Wiring, as per the app mod docs for the pcf 8583... with the following exception:
    From the SDA to gnd, and SCL to gnd a single led each.
    It provided positive indication the lines were high, and were momentarly being pulled low as the address scan progressed, as expected.
    Wired the board so 9~8 were the SDA/SCL lines (to remove my prop's eeprom from the testing circuit...)
    Using 4.7K pullups (the same as in 28~29), put an eeprom on this...
    Ran the scan using 9~8... it found the eeprom at 160, as expected ...
    Uplug eeprom, insert the 8583, adjusted wiring as per the app mod docs...
    Ran the scan using the 9~8... nothing...
    At this point, my conclusions are:
    #1: Either the 4.7K's are too much (but I can't think how)..
    #2: the PCF8583 may run internally on 3.3v, it may require a full 5.v to run (this is against the docs..)
    #3: I have let the magic smoke out of both of my 8583's (there's a slight chance of that... very slight)...

    But, I did prove your i2c object does work with the eeprom! [noparse]:)[/noparse]
    I still need to get a RTC into the project board...
    I'll see if there's a valid 3.3v I2C RTC and move from there...

    I'm believing at this point it's either my wiring or the chips that are at fault...

    Thanks for the Help!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • JavalinJavalin Posts: 892
    edited 2006-06-12 17:08
    KK,

    What voltage did you pull the i2c lines up to.· If you are running the device at 3.3v then the lines should be at +3.3V

    It sounds like the device is not powered, or its osc is not running or something similar.· I found this online http://www.grifo.com/MANUAL/uk_K51AVR.PDF

    and the attached diagram is the diagram for the 8583 RTC.· It shows the wiring as they have used - obviously the SDA and SCL would go to Propeller pins 9 and 8 as you have above.· They have used +5V which might be worth trying - but remember to put 1k resistors between the RTC and the propeller!!

    Is this the same as you have used?

    Cheers,

    James

    (another diagram is http://www.frontline-electronics.com/Downloads/eBook.pdf·- page 41.· I assume their micro-processor pulls those i2c lines high as no pull-ups are in the diagram)

    Post Edited (Javalin) : 6/12/2006 5:15:06 PM GMT
    453 x 320 - 25K
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-06-12 17:33
    The entire system is 3.3V, the pullups were to 3.3v as well (This voltage is measured and accurate).
    I had this issue about getting the osc to run when I was working on the BS2 with this chip...
    I have no idea how, but eventually it started running (Hmm, can thoes xtals be inserted backwards??)
    As for the attached circuit... Hmmm, interesting...
    I don't have the C21 inplace, and nothing for the int (pin 7) is connected.
    I'll try again tonight with C21 in place... recomendations for it's value?
    VCC is 3.3V (measured and verified)...
    If the C1 doesn't make it go at the 3.3V, then I'll try the 5.0V setup (with the 1k's on both SDA and SCL), and see if I can get it to fire then...
    Thanks!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • JavalinJavalin Posts: 892
    edited 2006-06-12 17:39
    Hi,

    have a look at the second link (the PS) - its much clearer (and it gives values!!)

    james
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-06-12 17:47
    That it does...
    (I read it after I posted a reply... duhhh, I need to slow down some...)...
    Well, I'v thoes values, so I'll give it a shot... with some hope, I'll have RTC on a PROP tonight... [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-06-14 20:51
    Well, after breaking my arm... removing 2 stumps, 2 big shrubs and 2 big trees, whil in a haze of pain killers, I finally and actually got the chip to respond to the device present (i2cscan) routine!
    Yes, it's there, and verifyied.. (I changed the address pin and it showed up at the anticapated assignment)... YES>..
    Next... strangness... the base address of the 8583 is the same as the eeprom's... thats right... Now, I thought that the types would make then be different, ie, the upper 4 bits would be different, but ther arent...
    Now, the clock still doesn't run... All the registers still return 0... but I'm not done yet! (this is the issue I had before, the darn ocs wouldnt run...
    The error I found was stupid, the power jumper wire had a break in it... and I found it by accident...
    Needless to say, thats been replaced..
    Any ideas abut why the thing wont run now?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • JavalinJavalin Posts: 892
    edited 2006-06-14 20:56
    COOL!

    Good news!

    I should of seen that - the %1010_0000 indeed the EEPROM address!

    I think you'll find you have to initialize (program) the clock before it will start running. For example look at the links i've posted - one of them tells you the way to intialize the device. Also if you look at my DS1307 RTC example it reads $80 for the seconds until you start it!

    Try not to break you're other arm or you'll not be able to play with the propeller!!

    James
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-06-15 13:31
    LOL... Thank You Javalin... LOL...
    I'm sure theres something to init...
    BTW: Do you think the BCD->DEC conversion routine from the BS2 Demo will work in the prop? I've got an idea or two about coding it, but havent gotten there...
    Your code for BCD->DEC and DEC->BCD is self explaining...· Rather simple in fact...


    this one finger typing rots!

    To RTC or not To RTC, that is the quest!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK


    Post Edited (Kaos Kidd) : 6/15/2006 2:01:01 PM GMT
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-06-16 02:19
    FAR OUT!!!
    RTC is finally running... but...
    It only runs when I touch the xtal... (or I get my hand next to it)... ??? any hints on this one?
    I'm so close to taking a single pin from the propeller and trying to make my own 32.678 khz clock

    Now to get it to format the numbers and I'm moving fowards...
    THanks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • JavalinJavalin Posts: 892
    edited 2006-06-16 10:21
    Sounds like a bad connection on the xtal.

    good news.
  • ForrestForrest Posts: 1,341
    edited 2006-06-16 10:49
    Sounds like you need a little more capacitance at C21 - try adding another 1 or 2 pF.
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-06-16 13:47
    I went as far as to remove the chip from the breadboard, insert the xtal leads into the same holes as the chip, and put the chip back in...
    It's sorta funny.. After it stops... As my hand gets closer to it, it starts running... slowly at first, and as my hand gets closer, faster. WHen my hand / finger actually touches it, it runs at the correct speed.
    I need to get some pF cap's, but I'll try that next...
    THanks guys for all the help...
    Next... getting the MAX6599 on line and running...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-06-16 23:56
    Well, my most humble thanks to all for all the suggestions...
    The addition of 1 .10pF cap from XTL1 to VCC made it work...
    It counts time... and does it very well...
    Again, thank you one and all...!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • JavalinJavalin Posts: 892
    edited 2006-06-17 12:05
    Interesting! Good news!
Sign In or Register to comment.