<div dir="ltr"><div>The correct answer... Just bypass all these hassles and do yourself a favour . Forget about 8-bit micros.<br><br>Switch to Cortex M0s. They're generally cheaper than 8-bitters these days and do pretty much everything better.<br><br></div> <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 23, 2016 at 7:35 PM, Mike Field <span dir="ltr"><<a href="mailto:hamster@snap.net.nz" target="_blank">hamster@snap.net.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Is  'defaults' an array, and what type? Or is that some  ANSI C++ 2022 encapsulated abstracted virtualised templated STL thingy?<br><br>Should not it be "static const u32_t defaults[] = {..."?<div style="line-height:1.5"><span class=""><br><br>-------- Original Message --------<br>Subject: Re: [chbot] Programming 8-bit microcontrollers<br></span><span class="">From: Mark Atherton <u></u><br>To: <a href="mailto:chchrobotics@lists.linuxnut.co.nz" target="_blank">chchrobotics@lists.linuxnut.<wbr>co.nz</a><br>CC: <br><br><br type="attribution"></span><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">would have defines 1000 as 1000L, so similar to synco, maybe cast <br>setting to u32, the multiplied by 1000L<br><br>the layout of the class looks suspicious 3 x u8, 1 x u32, 1 x u8, 1 x <br>u16 - would have tried to lay out on u32 boundaries : 1 x u32, 4 x u8, 1 <br>x u16<br><br>I can smell that Volker has set up some traps, so am looking for signed <br>/ unsigned mixes, and extensions, but I see none ...<br><br>shouldn't this trap be awarded 'un poisson de chocolat'<br><br>-mark<br><br><br><br>On 23/09/2016 5:38 PM, Synco Reynders wrote:<br> > To get a nice value for 'setting' you should cast to be 32 bit before <br>multiplying. Like:<br> > ms = (uint32_t) setting *1000<br> ><br> ><br> > On 23 September 2016 at 15:34, Volker Kuhlmann <br><u></u></span><div><div class="h5"> wrote:<br> ><br> >     This is for AVR, but should hold for any 8-bit job. Spot the <br>problems:<br> ><br> >     static const uint16_t setting = 15*60;<br> >     class values {<br> >       uint8_t a, b, c;<br> >       uint32_t d;<br> >       uint8_t e;<br> >       uint16_t f;<br> >     };<br> >     static const values defaults {<br> >       50, 1, 10, 0xFFB070, 5, 0x03FF<br> >     };<br> >     void func() {<br> >       unsigned long ms;<br> >       ms = setting * 1000;<br> >       ...<br> >     }<br> ><br> >     The program doesn't work in 2 places.<br> ><br> >     First solution wins a free copy of the night light firmware.<br> ><br> >     First correct solution wins 2 free copies of the night light <br>firmware.<br> ><br> >     Prize giving on Monday...<br> ><br> >     Volker<br> ><br> >     --<br> >     Volker Kuhlmann<br> >     <a href="http://volker.top.geek.nz/" target="_blank">http://volker.top.geek.nz/</a>      Please do not CC list postings to me.<br> ><br> >     ______________________________<wbr>_________________<br> >     Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.linuxnut.co.nz" target="_blank">Chchrobotics@lists.linuxnut.<wbr>co.nz</a><br> >     <a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" target="_blank">http://lists.ourshack.com/<wbr>mailman/listinfo/chchrobotics</a><br> >     Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" target="_blank">http://lists.ourshack.com/<wbr>pipermail/chchrobotics/</a><br> >     Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" target="_blank">http://kiwibots.org</a> <br>for venue, directions and dates.<br> >     When replying, please edit your Subject line to reflect new <br>subjects.<br> ><br> ><br> ><br> ><br> > ______________________________<wbr>_________________<br> > Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.linuxnut.co.nz" target="_blank">Chchrobotics@lists.linuxnut.<wbr>co.nz</a><br> > <a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" target="_blank">http://lists.ourshack.com/<wbr>mailman/listinfo/chchrobotics</a><br> > Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" target="_blank">http://lists.ourshack.com/<wbr>pipermail/chchrobotics/</a><br> > Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" target="_blank">http://kiwibots.org</a> for <br>venue, directions and dates.<br> > When replying, please edit your Subject line to reflect new subjects.<br><br><br><br><br>______________________________<wbr>_________________<br>Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.linuxnut.co.nz" target="_blank">Chchrobotics@lists.linuxnut.<wbr>co.nz</a><br><a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" target="_blank">http://lists.ourshack.com/<wbr>mailman/listinfo/chchrobotics</a><br>Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" target="_blank">http://lists.ourshack.com/<wbr>pipermail/chchrobotics/</a><br>Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" target="_blank">http://kiwibots.org</a> for venue, directions and dates.<br>When replying, please edit your Subject line to reflect new subjects.<br></div></div></blockquote></div><br>______________________________<wbr>_________________<br>
Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.linuxnut.co.nz">Chchrobotics@lists.linuxnut.<wbr>co.nz</a><br>
<a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer" target="_blank">http://lists.ourshack.com/<wbr>mailman/listinfo/chchrobotics</a><br>
Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer" target="_blank">http://lists.ourshack.com/<wbr>pipermail/chchrobotics/</a><br>
Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" rel="noreferrer" target="_blank">http://kiwibots.org</a> for venue, directions and dates.<br>
When replying, please edit your Subject line to reflect new subjects.<br></blockquote></div><br></div>