[chbot] Programming 8-bit microcontrollers
Richard Jones
richard.jones.1952 at gmail.com
Fri Sep 23 09:24:02 BST 2016
Hi Volker,
I will accept your challenge.
My correct solution offered below makes two assumptions:
a) The programming language is c++
b) The program below does what I want it to do, I wonder if that was what
you intended? :-)
Richard Jones
#include <stdint.h>
#include <stdio.h>
static const uint16_t setting = 15*60;
class values {
uint8_t a, b, c;
uint32_t d;
uint8_t e;
uint16_t f;
values();
};
values::values() {
a=50;
b= 1;
c=10;
d=0xFFB070;
e= 5;
f=0x03FF;
};
void func() {
uint32_t ms;
ms = setting * 1000;
// ...
}
On Fri, Sep 23, 2016 at 3:34 PM, Volker Kuhlmann <list0570 at paradise.net.nz>
wrote:
> This is for AVR, but should hold for any 8-bit job. Spot the problems:
>
> static const uint16_t setting = 15*60;
> class values {
> uint8_t a, b, c;
> uint32_t d;
> uint8_t e;
> uint16_t f;
> };
> static const values defaults {
> 50, 1, 10, 0xFFB070, 5, 0x03FF
> };
> void func() {
> unsigned long ms;
> ms = setting * 1000;
> ...
> }
>
> The program doesn't work in 2 places.
>
> First solution wins a free copy of the night light firmware.
>
> First correct solution wins 2 free copies of the night light firmware.
>
> Prize giving on Monday...
>
> Volker
>
> --
> Volker Kuhlmann
> http://volker.top.geek.nz/ Please do not CC list postings to me.
>
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.linuxnut.co.nz
> http://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Meetings usually 3rd Monday each month. See http://kiwibots.org for
> venue, directions and dates.
> When replying, please edit your Subject line to reflect new subjects.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20160923/8f8dc4da/attachment.html>
More information about the Chchrobotics
mailing list