Giter Club home page Giter Club logo

Comments (12)

zerog2k avatar zerog2k commented on May 29, 2024
  1. did it come with a schematic and/or board diagram which you can attach here?
  2. can you review my board's schematic to see if it has similar hookup:
    https://github.com/zerog2k/stc_diyclock/blob/master/docs/DIY_LED_Clock.png
  3. does this have the STC15F204EA chip?

from stc_diyclock.

zerog2k avatar zerog2k commented on May 29, 2024

Ok, I see that your issue subject indicates the chip is STC15W408AS.

I think this means it has 512k ram, 8k flash, I think W means wide voltage range, i.e. 3.3 or 5v.

Regarding the pullups, if you dont have the strong pullups, then you may need to adjust the pin modes (assuming they are the right pins from mcu to DS1302).
https://github.com/zerog2k/stc_diyclock/blob/master/src/main.c#L187-L188
have a look at section 4 (about gpio pin modes) in stc datasheet (link in reference section of my repo readme). (STC website is super slow... I'm guessing the owner is hosting his site on his cellphone.)

from stc_diyclock.

zerog2k avatar zerog2k commented on May 29, 2024

assuming the pinout for STC15W408AS is same as STC15F204EA (looks like it for 28-pin version from internet schematics i can find), and assuming your DS1302 is hooked up to P1.0, P1.1, P1.2, and assuming that lack of pullups might be causing communication issue with DS1302 (time display is pulled directly from RTC), then you could try to put the pin modes into mode 0 (quasi- bi-directional - some pullup):

i.e., try changing:

   P1M1 |= (1 << 0) | (1 << 1) | (1 << 2) | (1<<6) | (1<<7);
   P1M0 |= (1 << 0) | (1 << 1) | (1 << 2) | (1<<6) | (1<<7);

to

   P1M1 |= (1<<6) | (1<<7);
   P1M0 |= (1<<6) | (1<<7);

from stc_diyclock.

hachi avatar hachi commented on May 29, 2024

I think you're on to something. I didn't pay attention to whether the func and + buttons were doing pull up or down the same as your schematic. The mismatch of modes might explain both the RTC comm problem and the lack of buttons.

from stc_diyclock.

hachi avatar hachi commented on May 29, 2024

You were right regarding the I/O pins for the RTC. The clock portion has started working, but I'm still looking into the broken buttons. They are grounded switches on the same pins as your schematic, so I don't know what's wrong yet.

Thank you for your theory on the 'W' of the part number, the STC web site and Google at large were very unhelpful for finding the data sheet for this chip by the specific part number. After a fair bit of searching I did find that this is the same model of chip with 8k flash. More to come.

from stc_diyclock.

zerog2k avatar zerog2k commented on May 29, 2024

Regarding pin modes, mine works fine with default pin mode 0 on DS1302 , so I'll fix this in the code.

Regarding buttons - I think we might be over-thinking the software debounce on them. At least on mine, I hooked up a scope, and there is very little (if any) bounce on key down. There is sometimes some bounce on key up (but usually less than 1ms). So we can probably simplify debounce a bit. I'm also trying to think of how we can better handle long/short press events.

from stc_diyclock.

hachi avatar hachi commented on May 29, 2024

I think I'm having troubles with timing. The overall speed of the programming is running about double what I would expect after reading the code. The colon flashes about twice per second... maybe 3x.

I raised the delay_ms constant for i to '8' and it looks more correct. However the debounce is also not working and I'm still reading the manual to learn how to adjust the counter constants reasonably.

I've tested with mangled up code and the raw input is working fine, so it's something about the shift algorithm of the debounce keeping the key presses from being detected.

from stc_diyclock.

zerog2k avatar zerog2k commented on May 29, 2024

Are you programming w/ STC-ISP or stcgal? What clock speed are you running, is it (around) 11.059 MHz?

from stc_diyclock.

zerog2k avatar zerog2k commented on May 29, 2024

Also, I'll be on gitter chat for a few if you want to troubleshoot head-to-head there...
https://gitter.im/zerog2k/stc_diyclock

from stc_diyclock.

zerog2k avatar zerog2k commented on May 29, 2024

btw the datasheet for STC15W408AS:
http://www.stcmicro.com/datasheet/STC15F2K60S2-en2.pdf
Better download and save a copy of any STC datasheet - their website can be down or flakey alot.

from stc_diyclock.

hachi avatar hachi commented on May 29, 2024

To fill in anyone on this reading later...

The STC15W408AS is a slightly faster, similar feature, same pinout CPU of the one this project primarily supports.

The display glitch of "1F:7F." was caused by the lack of pull-up resistors on the IO and RST pins of the RTC. This was fixed by applying different pin modes, which @zerog2k applied to master at d5e7f13 because the pin mode will work more universally this way.

The lack of button inputs was debugged down to be a lack of Timer1 operation on this MCU.
I used a frequency counter and oscillated a pin during Timer1 interrupt operation and found no combination of registers to cause Timer1 to start. @zerog2k found there is a confusingly documented lack of Timer1 available on this board and suggested trying to use Timer2 (or try harder to get Timer1 to work via USART options).

After a bit of effort I was unable to use Timer2 for the same purpose. However I've been able to get button inputs working by counting triggers of Timer0 and calling to the button handler directly.

@zerog2k also pointed me in the direction of the official STC-ISP program which documents features of the CPU. It can also generate sample timer and delay loop code with specific timing based on a clock speed. This helped fix the overspeed issue for the colon blink and also adjusted the timings of Timer0.

I've made a rudimentary patch for the timing fixes necessary and my hack to cascade from Timer0 to the button handler at hachi@8bf4374

from stc_diyclock.

zerog2k avatar zerog2k commented on May 29, 2024

Closing out this issue, as a number of things were improved as a result of this discussion. I have received the STC15W408AS's that hachi donated and confirmed they work with latest master. See release 0.5.0 : https://github.com/zerog2k/stc_diyclock/releases/tag/0.5.0

from stc_diyclock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.