{"id":203,"date":"2020-12-05T17:21:28","date_gmt":"2020-12-05T17:21:28","guid":{"rendered":"http:\/\/gurunoia.lochan.org\/blog\/?p=203"},"modified":"2020-12-05T17:21:28","modified_gmt":"2020-12-05T17:21:28","slug":"fixing-the-flicker-on-the-adafruit-feather-m4-express","status":"publish","type":"post","link":"https:\/\/gurunoia.lochan.org\/blog\/2020\/12\/fixing-the-flicker-on-the-adafruit-feather-m4-express\/","title":{"rendered":"Fixing the flicker on the Adafruit Feather M4 Express"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"755\" src=\"https:\/\/gurunoia.lochan.org\/blog\/wp-content\/uploads\/2020\/12\/adafruit-chg-led-20201205_171132-1024x755.jpg\" alt=\"Picture of Adafruit Feather M4, plugged into a USB cable, showing the &quot;Charge&quot; LED illuminated.\" class=\"wp-image-204\" srcset=\"https:\/\/gurunoia.lochan.org\/blog\/wp-content\/uploads\/2020\/12\/adafruit-chg-led-20201205_171132-1024x755.jpg 1024w, https:\/\/gurunoia.lochan.org\/blog\/wp-content\/uploads\/2020\/12\/adafruit-chg-led-20201205_171132-300x221.jpg 300w, https:\/\/gurunoia.lochan.org\/blog\/wp-content\/uploads\/2020\/12\/adafruit-chg-led-20201205_171132-768x566.jpg 768w, https:\/\/gurunoia.lochan.org\/blog\/wp-content\/uploads\/2020\/12\/adafruit-chg-led-20201205_171132-407x300.jpg 407w, https:\/\/gurunoia.lochan.org\/blog\/wp-content\/uploads\/2020\/12\/adafruit-chg-led-20201205_171132.jpg 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The <a href=\"https:\/\/learn.adafruit.com\/adafruit-feather-m4-express-atsamd51\">Adafruit Feather M4 Express<\/a> is a lovely piece of kit. It has just one flaw &#8211; the yellow &#8220;charging&#8221; LED flickers constantly whenever the Feather is powered by USB. This is because of the Li\/poly charger on board &#8211; if you have no battery, the charger attempts to charge the stray capacitance of the board, turning on the &#8220;charging LED&#8221;; when it reaches the critical voltage (4.2V) it turns off, turning off the LED; once the charge leaks away the charger starts charging again, turning on the LED and restarting the cycle. This is all very sad, and very annoying. Especially since <a href=\"https:\/\/learn.adafruit.com\/adafruit-feather-m4-express-atsamd51\/power-management\">you cannot disable the on-board charger<\/a>.<\/p>\n\n\n\n<p>I got frustrated by this, and looked up the <a href=\"https:\/\/learn.adafruit.com\/assets\/57242\">Feather&#8217;s schematic<\/a> and then the <a href=\"https:\/\/docs.rs-online.com\/1e46\/0900766b81381742.pdf\">datasheet for the MCP73831\/2 charger controller<\/a>.<\/p>\n\n\n\n<p>The datasheet makes clear that the charger <em>does<\/em> have battery detection &#8211; so why is it attempting to charge even when there is no battery connected to the Feather?<\/p>\n\n\n\n<p>The answer is in section 4.2. The chip sources 6\u00b5A on the Vbat pin; if the voltage of that pin goes over the target voltage Vreg (4.2V, see section 1) plus 100mV, the device assumes a battery is not present; if below, a battery is present. But why is this not working?<\/p>\n\n\n\n<p>The schematic shows that the Feather connects the Vbat pin to more than just the battery: in order to monitor the charge of the battery, it connects Vbat to ground via 2 \u00d7 100k\u03a9 resistors forming a voltage divider (the midpoint is taken to Ain13 (=A6) on the SAMD51 chip &#8211; we assume the sink current here is negligible).  That means that at 4.2V we expect a current of 21\u00b5A &#8211; more than enough to trigger battery detection! Oh dear.<\/p>\n\n\n\n<p>Drastic solutions are possible &#8211; e.g., cutting the charge LED resistor R2, or the voltage divider R96. But I&#8217;d rather not cut my board.<\/p>\n\n\n\n<p>All we need to ensure is that Vbat is over 4.3V. We can do this with a pull-up resistor from Vbat to Vbus (USB). With Vbus at a nominal 5V, and a current of 21\u00b5A, we need a resistor of less than 33k\u03a9. Since Vbus is likely lower (I measured 4.85V with my setup), we&#8217;ll give it a 3\u00d7 safety margin and use a 10k\u03a9 resistor. At the cost of a leakage current (Vbus to ground) of just 24\u00b5A (1\/40th of a milliamp), this should disable the charger correctly <em>when no battery is fitted!<\/em><\/p>\n\n\n\n<p><strong>DO NOT USE THIS IF A BATTERY IS CONNECTED!<\/strong><br><strong>DO NOT USE ANY PULL-UP RESISTOR IF A BATTERY IS CONNECTED!<\/strong><\/p>\n\n\n\n<p>What will happen if a battery is fitted?<\/p>\n\n\n\n<p>The minimum value of the lowest permitted battery voltage (UVlo) is 3.2V (section 1); with a 10k\u03a9 resistor to 5V we will charge this at a rate of 0.2mA. Even at full charge (4.2V), we will continue to charge at around 0.1mA. Even though this seems like a tiny current, lithium batteries do not saturate and have no safe trickle current &#8211; even at 0.1mA, your battery will eventually catch fire and explode. You do not want this to happen. In any case, you don&#8217;t need the resistor &#8211; if you have a battery fitted, the charge LED will not flicker.<\/p>\n\n\n\n<p><strong>Summary: to stop the flicker when no battery is connected, connect a 10k\u03a9 resistor between the BAT and USB pins. REMOVE THE RESISTOR IF A BATTERY IS CONNECTED, OR YOUR BATTERY WILL EVENTUALLY EXPLODE.<\/strong><\/p>\n\n\n\n<p>I hope this has been useful! I&#8217;d love to hear about your experiences &#8211; please comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Adafruit Feather M4 Express is a lovely piece of kit. It has just one flaw &#8211; the yellow &#8220;charging&#8221; LED flickers constantly whenever the Feather is powered by USB. This is because of the Li\/poly charger on board &#8211; &hellip; <a href=\"https:\/\/gurunoia.lochan.org\/blog\/2020\/12\/fixing-the-flicker-on-the-adafruit-feather-m4-express\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[24],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/gurunoia.lochan.org\/blog\/wp-json\/wp\/v2\/posts\/203"}],"collection":[{"href":"https:\/\/gurunoia.lochan.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gurunoia.lochan.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gurunoia.lochan.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gurunoia.lochan.org\/blog\/wp-json\/wp\/v2\/comments?post=203"}],"version-history":[{"count":1,"href":"https:\/\/gurunoia.lochan.org\/blog\/wp-json\/wp\/v2\/posts\/203\/revisions"}],"predecessor-version":[{"id":205,"href":"https:\/\/gurunoia.lochan.org\/blog\/wp-json\/wp\/v2\/posts\/203\/revisions\/205"}],"wp:attachment":[{"href":"https:\/\/gurunoia.lochan.org\/blog\/wp-json\/wp\/v2\/media?parent=203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gurunoia.lochan.org\/blog\/wp-json\/wp\/v2\/categories?post=203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gurunoia.lochan.org\/blog\/wp-json\/wp\/v2\/tags?post=203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}