DX  » Community » Forums
«See all threads (in Product Forum)
Product Forum

Here's some source code

  • DrJones Tuesday, February 21, 2012 1:10 AM Reply
    I made a similar clock program for this module, no date though and a different setting method (button1: adjust forward, button 2: backward; getting faster after a few seconds.), plus some kind of seconds progress bar. Button3 sets brightness.

    clockmtx.c
    Posts(1593) | Reviews | Tip post

  • davyam Saturday, March 03, 2012 3:54 PM Reply
    Hi DrJones.

    How build and upload this code to device.

    I am also want only clock without data display.

    Thanks
    Posts(7) | Reviews | Tip post

  • DrJones Sunday, March 04, 2012 2:51 AM Reply
    That requires some knowledge in and tools for micro-controller programming.
    You'd need a programmer for Atmel µCs (hardware, interface between PC and µC)
    and a cross compiler, in my case avr-gcc.
    (plus the programmer software like avrdude, probably included in one of the above).
    Posts(1593) | Reviews | Tip post

  • damo5 Monday, March 12, 2012 5:20 AM Reply
    Neat! What license do you want to put on this code... can we do what we like with it?
    Posts(5) | Reviews | Tip post

  • DrJones Monday, March 12, 2012 9:44 AM Reply
    Good question... Yes, completely free, no rights reserved.
    No warranty whatsoever either.
    Posts(1593) | Reviews | Tip post

  • Mic159 Wednesday, March 14, 2012 5:22 AM Reply
    Nice, I flashed your version and it works :)
    Thanks.

    I just learnt how to compile and flash AVR for this. I have always used arduino in the past, and its IDE takes care of all the compiling and flashing itself (and uses its bootloader over serial instead of ISP programming).

    I just wanted to document how I flashed your program to help anyone else who is not sure how to do it.

    Basically, first step is to get an ISP programmer.
    I got the "POLOLU USB AVR PROGRAMMER".

    With the programmer unplugged from the computer, and the clock unplugged from external power, plug the programmer into the pins on the side of the clock.

    Just connect the pins labeled the same together. eg: MOSI -> MOSI, VDD/VCC -> VCC, SCK -> SCK, etc...

    Now, connect the external power to the clock. It should start up as normal, and show the clock on the screen. If its not showing, you plugged in the programmer in wrong and might be shorting something. Unplug it and check the pinouts more carefully.

    Now connect the USB into the programmer. The programmer should now light up.

    When you plug it into the computer, use "dmesg | tail" to find the name of the device that the programmer will show up on your machine as. For me it was "/dev/ttyAMC0".
    There was also AMC1, but that is the serial port on my programmer.

    Now to verify that everything is connected and working properly, run avrdude.

    avrdude -c avrisp2 -p m8 -P /dev/ttyACM0

    -c is the programmer protocol you use for your programmer. Again, I am using the Pololu USB AVR Programmer, and it uses avrisp2.
    -p is the chip that you are programming. This clock has an MEGA 8 chip, its code in avrdude is "m8".
    -P is the port of your programmer on your computer. Again, for me this was ttyAMC0.

    When you run this command it should just verify the chip and the connections.
    It should show something like this:

    avrdude: AVR device initialized and ready to accept instructions
    Reading | ################################################## | 100% 0.00s
    avrdude: Device signature = 0x1e9307
    avrdude: safemode: Fuses OK
    avrdude done. Thank you.

    Now that you have a working programmer, we should back up the existing program on the clock.
    For this, we use the -U command.

    avrdude -c avrisp2 -p m8 -P /dev/ttyACM0 -U flash:r:original.hex:i

    its -U type:operation:filename:format
    type: could be flash, eeprom, (h|l|e)fuse. We want to back up the flash.
    operation: r|w|v, read, write, verify. We want read to get the hex off the chip.
    filename: where we want to write it to
    format: we want intel hex. So "i".

    Now we need to compile the program from DrJones.

    To do this, we will use avr-gcc and avr-objcopy.

    avr-gcc -Os -std=c99 -mmcu=atmega8 -o clock.elf clockmtx.c

    -Os: turn on optimisation, and target smallest file size.
    -std: the standard of the C code. In this case he is using c99 (for his for loops).
    -mmcu: the chip to compile for. gcc calls this chip "atmega8".
    -o: Tell GCC to link and write out to the file clock.elf.

    Now, we need to make an intel hex file from this, using avr-objcopy.

    avr-objcopy -O ihex clock.elf clock.hex

    -O: tell it to write in intel hex format "ihex".

    Finally, we want to flash it on the chip :)

    avrdude -c avrisp2 -p m8 -P /dev/ttyACM0 -U flash:w:clock.hex:i

    this time we tell it (with the -U command) to write with the "w" option the .hex file to the flash memory of the chip.

    Now the clock should should be running the new program that DrJones has written :)

    I hope this helps.

    If there is something wrong with what I did, please tell me :)
    Posts(67) | Reviews | Tip post(25)

  • davyam Wednesday, March 14, 2012 1:55 PM Reply
    Hi Mic159,

    Thank you for your post!

    I am beginner in AVR programing so can you find something like "POLOLU USB AVR PROGRAMMER" from DX site please?

    Thanks.
    Posts(7) | Reviews | Tip post(2)

  • Mic159 Thursday, March 15, 2012 5:17 AM Reply
    DX does not sell any ISP programmers. At least not yet.
    They did sell a JTAG programmer/debugger at one stage, but you do not want JTAG.
    You will have to buy from somewhere else.

    They do sell serial adapters for things like the arduino that have a bootloader that can receive flash updates over serial. But this has no such bootloader on it.
    Posts(67) | Reviews | Tip post

  • Texican Saturday, March 17, 2012 4:50 PM Reply
    If you can order from the US, this $13 Arduino shield AVR ISP programmer from Evil Mad Science is great.
    http://evilmadscience.com/productsmenu/tinykitlist/253

    Comes Arduino "shield" comes as a kit you solder together, and requires an Arduino to operate.

    It can write Arduino bootloaders in the attached ZIFF socket or on target boards via the onboard ISP connector. It's not just for Arduino bootloaders, it works as an AVR ISP for programming raw AVR chips, and is supported by AVRDUDE.
    Posts(3) | Reviews | Tip post

  • Texican Saturday, March 17, 2012 5:00 PM Reply
    Dr. Jones -

    Thanks for the code.

    My 104306 does nothing when I apply power. Am wondering if perhaps mine is DOA or if the Mega8 is simply blank. What's your experience of observed behavior of this device if powered on when the Mega8 AVR contains no code?

    Should I expect a blink, flash, or any form of life when it's powered on with a blank AVR?

    I will try Mic159's method of programming my Mega6 with your code, but am still curious if this bugger is DOA or simply has no brain!

    Thanks,

    Matt - Texas, USA
    Posts(3) | Reviews | Tip post

Page 1 of 4
Go to Page:
«Reply to this thread (in Product Forum)
Product Forum

Reply

Subject:

* 50 characters max

Message:

Please note: HTML codes are not allowed anywhere on this page (otherwise you will see an error).

Please note that DealExtreme Forums are not a sales or product support board. While we do constantly participate in this forum, please contact us via support ticket for a guaranteed fast response. We make every effort to make the quickest replies.

DX Everywhere