{"id":567,"date":"2022-05-24T12:10:03","date_gmt":"2022-05-24T11:10:03","guid":{"rendered":"https:\/\/ceptimus.co.uk\/?p=567"},"modified":"2022-05-24T13:13:11","modified_gmt":"2022-05-24T12:13:11","slug":"sh-e-879-clock-kit-stopwatch","status":"publish","type":"post","link":"https:\/\/ceptimus.co.uk\/index.php\/2022\/05\/24\/sh-e-879-clock-kit-stopwatch\/","title":{"rendered":"SH-E 879 clock kit stopwatch"},"content":{"rendered":"\n<p>I first mentioned these kits about six years ago when I blogged about making this<a href=\"https:\/\/ceptimus.co.uk\/index.php\/2016\/02\/06\/an-arduino-based-programmer-for-the-at89c2051-chip\/\"> Arduino-based programmer for the AT89C2051 chip.<\/a><\/p>\n\n\n\n<p>The kits are still available on eBay, Banggood, AliExpress, &#8230; and there are plenty of variations that still use the AT89C2051 chip, but have more (three) push buttons, a buzzer, or only four digits instead of six, and so on.  The code presented here could easily be modified to run on any of those.  The six-digit clock kit, with three buttons and buzzer, is advertised as having a stopwatch, alarm, etc. built in and less than  \u00a34 including shipping at the time of writing, from AliExpress.<\/p>\n\n\n\n<p>But my SH-E 879 kit was a clock only, as far as I could tell, so I wrote some code to be compiled by the excellent free <a href=\"http:\/\/sdcc.sourceforge.net\/\">SDCC C compiler<\/a> to turn it into a stopwatch.  SDCC is available on Windows, Linux, and Mac.<\/p>\n\n\n\n<p>For Windows, you can also use the Keil uVision compiler, which is fine for small projects like this. The &#8216;free&#8217; version of the Keil compiler has a 2K code size limit, which is no problem for the AT89C2051, because it only has 2K of Flash memory.  But if you intend to write 8051 code for other 8051-based chips, and might eventually exceed 2K of code, it&#8217;s better (in my opinion) to use SDCC from the outset.  The very expensive Keil licence is out of reach for hobby programmers, so starting with SDCC saves you having to migrate your code from Keil to SDCC later (the syntax is slightly different).  The Keil compiler perhaps optimizes your code slightly better, and allows in-line declaration of variables instead of needing to declare them up at the top of each scope block, but the SDCC is not far behind, and given the price difference, the choice is a no-brainer.<\/p>\n\n\n\n<p>Here&#8217;s the <a href=\"https:\/\/ceptimus.co.uk\/AT89C2051\/stopwatch.c\">source code for the stopwatch<\/a>, and in the comments there is the command you need to type into a CMD prompt (or terminal window on Linux) to compile and link it.  If you just want the hex resulting hex file, <a href=\"https:\/\/ceptimus.co.uk\/AT89C2051\/stopwatch.ihx\">it&#8217;s here<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"SH-E 879 clock kit reprogrammed as a stopwatch\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/QaYYkiHG2Io?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>If you want to turn your stopwatch back into being a clock, the 12-hour-clock source code is <a href=\"https:\/\/ceptimus.co.uk\/AT89C2051\/clock12h.c\">here<\/a>, and its hex file is <a href=\"https:\/\/ceptimus.co.uk\/AT89C2051\/clock12h.ihx\">here<\/a>.  Should you prefer a 24-hour clock, here is the <a href=\"https:\/\/ceptimus.co.uk\/AT89C2051\/clock24h.c\">source<\/a>, and <a href=\"https:\/\/ceptimus.co.uk\/AT89C2051\/clock24h.ihx\">hex file<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I first mentioned these kits about six years ago when I blogged about making this Arduino-based programmer for the AT89C2051 chip. The kits are still available on eBay, Banggood, AliExpress, &#8230; and there are plenty of variations that still use the AT89C2051 chip, but have more (three) push buttons, a buzzer, or only four digits [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-567","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/567","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=567"}],"version-history":[{"count":3,"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/567\/revisions"}],"predecessor-version":[{"id":573,"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/567\/revisions\/573"}],"wp:attachment":[{"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/categories?post=567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/tags?post=567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}