new serial LCD PCB, DS1307 + I2C code

Discussion in 'The Projects Forum' started by takao21203, Apr 12, 2013.

  1. takao21203

    Thread Starter AAC Fanatic!

    Apr 28, 2012
    PCBs arrived here some days ago.

    Assembled a few, and the prototype code works fully.

    However, in the meanwhile, the serial interface was changed. I am now using RESET each time serial data is sent.

    Based on 16f59.

    Here the new I2C functions I prototyped today. Only using the DS1307 datasheet. I usedd and programmed I2C before...but not using C for really a long while.

    What do you think about this code?

    Code ( (Unknown Language)):
    1. void DS1307_datawrite_start(unsigned char databyte)
    2. {
    4. }
    6. void DS1307_datawrite_more(unsigned char databyte)
    7. {
    9. }
    11. void DS1307_datawrite_stop()
    12. {
    14. }
    16. unsigned char DS1307_dataread_start()
    17. {
    19. }
    21. unsigned char DS1307_dataread_more()
    22. {
    24. }
    26. unsigned char DS1307_dataread_stop()
    27. {
    29. }
    31. unsigned char DS1307_dataread_fraddr_start(unsigned char addrptr)
    32. {
    34. }
    36. unsigned char DS1307_dataread_fraddr_more()
    37. {
    39. }
    41. void DS1307_dataread_fraddr_stop()
    42. {
    44. }
    I don't even know if the DS1307 can work at 3 volts. If not, I need a solution for that. I plan to read from the RTC chip about ten times a second.

    Here for this circuit interestingly, all functionality is programmed into the display PCB itself.

    One controller is a serial slave, the other works one half of the display, the second display as Master, and also it reads from the RTC chip.

    There are 6 IO lines available on each of the two display chips.

    Normally, an external PIC is used, but I want a demo using only the display PCB.
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    I can only guess the functions of prototypes without any comments, but I suspect you are making low level I2C calls. That's fine, but I prefer wrappers to actually accomplish something completely:

    When I wrote code to access a RTC I used these as my prototypes:
    Code ( (Unknown Language)):
    2.   BOOL SetTimeDate(TimeDate* NewTD);
    3.   BOOL GetTimeDate(TimeDate* CurrentTD);
    The DS1307 is a 5 V device.
  3. takao21203

    Thread Starter AAC Fanatic!

    Apr 28, 2012
    1. This PIC only has two stacks.

    2. I only have 3V. Does it just not work at 3v, and do I need a step up converter? Maybe a charge pump since it does not need so much current?
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    Read the data sheet. Supply is spec'ed for 4.5-5.5VDC (as I remember, not looking it up again today). But it's NOT rated for 3.3V operation.

    The NXP PCF2129A device *IS* rated for 3.3V operation, can use a coin cell for backup so the time stays accurate, and has the crystal internal to itself so it can monitor it's temperature for very good long term accuracy.

    Not too shabby for about 3 bucks (USD) in single quantities.
  5. takao21203

    Thread Starter AAC Fanatic!

    Apr 28, 2012
    Yes I do read the datasheet.

    At first I will make the circuit working powering from the PICKIT3, and then test if it still works at 3 volt. If not, I will try a charge pump IC.

    Today I changed the code adding conditional compile statements, since it is used for both the master and the slave MCU. Two MCUs on the PCB.

    Normally both are slaves, but since they have 2K FLASH, it is possible to program small applications directly into one of the controllers.

    Clocking cycle is not high frequency, using a 470uH coil, I hope no delays are required for the I2C.