aFewBits / stc-led-clock

Replacement firmware for STC 8051 based DIY LED clock kits
MIT License
55 stars 20 forks source link

Strange S2 behavior #10

Closed flohwie closed 5 years ago

flohwie commented 5 years ago

Thanks for sharing your clever code. I used it on a "KKmoon Compact 4 Digit DIY Digital LED Clock Kit", which is based on the STC15W404AS MCU and has 4 transistors to drive the single segments (and thermistor and LDR as well). Your code works but when trying to set the time, I see Set after S1 press and then after pressing S2 the display goes weird (I see CL for a shirt time then the hours increment as if the button was held; however it won't stop and the clock remains unresponsive until a power off/on cycle). Resetting works and sets the time to 20:00, LDR is working, other functions could not be tested. I think it might be some code in the "timer" library. Could you please help?

aFewBits commented 5 years ago

Can you post a schematic of the unit? Without knowing what's inside, I have no idea of what the problem could be.

flohwie commented 5 years ago

circuit

flohwie commented 5 years ago

seems to be pretty close to the bangood model, however without a transistor for the buzzer and without relais.

aFewBits commented 5 years ago

I have an identical unit that I can use for test but will not be unable to do any work on it until at least the weekend, 13 October. I'll post a header file when I can. The only pointers I can give you at this time is to define "BOARD_BLUE_6" and "PROC_IS_15W404AS" as TRUE and all others in those groups as FALSE. Insure your final code is 4k or less and the basic functions should work.

flohwie commented 5 years ago

... thanks a lot in advance for looking into it! BOARD_BLUE_6 and PROC_IS_15W404AS is exactly what I have selected. Disabling CHIME and DAY keeps final code below 4k (STCCODESIZE has been also set in the Makefile to make sure it does not exceed this limit).

flohwie commented 5 years ago

I think I located the problem: it is NOT your code, it is somehow related to SDCC. After downgrading to SDCC version 3.5.0 (instead of 3.8.0) the compiled hex file works like a charm. Nothing else changed, just used an older version of the compiler (see also my comment to issue #32 of zerog2k's library, which also only compiles correctly with SDCC 3.5.0).

aFewBits commented 5 years ago

Thank you for the information, I've been using 3.6.0 without issue. I will investigate 3.8.0 and compare the output binaries.

aFewBits commented 5 years ago

If you want to use the alarm and chime, you can fit the image into a 4k device by setting the define OPT_UNITS_GROUP to TRUE. This groups the selection of temp/date/day selections into a simple US or EU selection rather than individual selections of [F/C] [MM/DD or DD//MM] and [Sunday or Monday = 1]

flohwie commented 5 years ago

Thanks, I tried it to compile this way with 3.5.0 and it's perfect.

FlorentFlament commented 3 years ago

Same bug here on the "KKmoon 4-Digit Digital Clock Kits LED Talking Clock" with sdcc 3.8.0. Works perfectly fine with sdcc 3.5.0.

My guess is that some compiler optimization may break the code. Thanks !