vargham / stc_diyclock

STC DIY Clock redux (STC15F204EA, STC15W408AS)
MIT License
0 stars 1 forks source link

Could not set / display time with HW_MODEL_D #1

Open vargham opened 6 years ago

vargham commented 6 years ago

Temperature and ligth measurement are working. Display is OK. Button 1 and 2 are working.

Time setting and display is not working. There is a 1F 7F constant display instead of time.

time_display_send

zerog2k commented 6 years ago

Is it working with the changes you made?

vargham commented 6 years ago

Everything is fine, except the clock.

zerog2k commented 6 years ago

I’m wondering if the data and clock lines of ds1302 have external pull-up resistors on them? I recall some issue where we had to play with the pin mode registers to get pull-up (if so might check data sheet on this. )

vargham commented 6 years ago

RTC data IO has 7k6 pull-up.

vargham commented 6 years ago

Changed DS1302's CE to open-drain output

    //M1 M0
    // 0 0 Bidirectional
    // 0 1 Push-Pull
    // 1 0 Input
    // 1 1 Open-drain
    //          IO CE CK
    P1M1 = 0b00000010;
    P1M0 = 0b00000010;

Constant 1F 7F has been changed to constant 00 00, but still could not set time.

zerog2k commented 6 years ago
  1. Did the clock work with the stock firmware before flashing to this custom one?
  2. Datasheet says ds1302 signal pins have internal 40k pulldown, so if there are no pullups on CE & CLK you may want to try setting pinmode to push-pull, and on IO since it has pullup, open-drain (or quasi-bidirectional). Do you have access to a scope or logic analyzer to see what is happening on the ds1302 signal lines?
vargham commented 6 years ago
  1. Yes, the original firmware worked.
  2. Changed pin mode and everything is the same.
  3. I will check it with logic analyzer.
vargham commented 6 years ago

I checked. CE and CLK is always low. Only IO is changing.

vargham commented 6 years ago

OK, I fixed.

  1. All DS1302 pins set to bidirectional.
  2. if defined HW_MODEL_D does not work at the DS section of hwconfig, so the wrong pins have been used. Just commented out to test. I will clean that part.

zerog2k commented 6 years ago

Curious if you had to explicitly set P1M0 and P1M1 registers to 0. I understand from datasheet that this should be the default, and I don't recall where we were setting these otherwise.

Madhava-04 commented 6 years ago

I also get this error 1F 7F. Please help me by sending Hex file because I dont know how to compile. I have YD-020 model kit as per attached file yd-020 clock

pctong commented 4 years ago

Here is a link to the STC15F204EA new firmware for Madhava-04 to try on your new model. the only difference is your light sensor is on P1.3 but my ZM-907AA is on P1.5. If your test is ok, I can recompiled the firmware for P1.3 https://github.com/pctong/STC15F204EA-clock