Update to the JY-MCU 3208 Lattice clock

I had a comment from Håkon Nessjøen stating that he had success in shrinking the code to fit in the standard mega8 onboard.  He stated that he had removed the links to the vprintf and vscanf libraries in the makefile and the code shrunk dramatically.  Thanks Håkon for pointing that out, that was a great catch.

I set out this morning to do this myself and am happy to say I was successful.  There were other changes that had to be made to the code to make it functional on the mega8.  Unfortunately I am pressed for time this morning so I will document those changes in detail later.  However, I have the updated code available for download here ( jy-mcu_mega8.zip ).

Here is a quick rundown of the changes I made:

  • Changed fuse settings in mega8 to turn off div/8 fuse to make it run at 8MHz
  • Changed F_CPU to 8000000 in 8x32matrix.c
  • Changed delay.c for only 2 NOP’s for a 1us delay at 8MHz
  • Changed timer naming for mega8 in 8x32matrix.c
  • Commented out all ADC functions and temperature reading in 8x32matrix.c
  • Re-worded demo text in 8x32matrix.c
  • Added extra delay to ledarray_flash to allow for on/off time setting in 8x32matrix.c
  • Removed linker flags in makefile for vprintf and vscanf
  • Added avr-size to makefile to see size after compile

I’ll cover these in detail at a later time, hope this helps some of you out who didn’t feel comfortable replacing the mcu.

This entry was posted in News. Bookmark the permalink.

12 Responses to Update to the JY-MCU 3208 Lattice clock

  1. Daniel says:

    Hey thanks for the code. I just fixed a small change in 8x32matrix.c in font_display_ud() the buffer has to be 7 chars wide not only 5.

  2. nicgravel says:

    What software do you use to compile your code ? I was able to convert a C file to hex (the clock file found in Dx blog) but I don’t know what is needed for your project.
    I’m using an and it works for the clock file….
    Thanks .

  3. JJ says:

    Thanks for publishing this firmware! I made a few changes to the text:
    http://www.youtube.com/watch?v=-wpq5ONgRg4&list=UURNjL2D5iv3DFDC7luP2xjA&index=1&feature=plcp

    For anyone that is new to programming ATMega chips the fuse settings to run this firmware are LFUSE = A4 and HFUSE = CC. At least that’s what works for me.

    I’m guessing there is no chance of being able to fit the clock software and this scrolling text on the chip at the same time?

    Thanks again for your work and your good documentation of what you’ve done. Much appreciated,

    Jonathan

    • Rick_S says:

      Thanks for posting the youtube link! It’s nice seeing the firmware on someone elses display. As for having a clock on the display as well, it is definately plausable. Especially with the stock crystal in place. I may mess with that at some time, but right now, I have a lot of other projects (non electronics related) that have been eating up most of my time. I will probably start picking this back up in the next couple of months when the weather begins to turn and I have more time.

      Keep up the good work!!

      Rick

      • JJ says:

        I am still getting into this “proper” microcontroller malarky. I have fairly good knowledge of Picaxe chips (which are cheap, easy and surprisinly powerful). However, I can see the power of C programming on microcontrollers so I’m getting into the ATmega stuff.

        I will definitely look at trying to integrate the clock and scrolling text as a project. Like you I too have other stuff to work on so no guarantees on timelines! I will let you know if I get there and likewise I’ll keep an eye on your blog.

        Thanks again for all the posts and detail you’ve done. It’s so easy to just not bother!

        Jonathan

  4. Michael says:

    Can who lay out a code for MEGA8. That the display showed not only time but also temperature.
    Thanks
    flufarafa@mail.ru

  5. Const says:

    Hi. Great Job. I’m just got from DX JY-mcu 3208 and begin to learn how-to be an programmer for avr. For that I download your programm and try it. Nice. But I’am aware some time when text scrolling some time chars a bit broken by 1 line. I start to check what happen and got idea.
    Some times when screen scroll interrupt happen. So we can see screen , what not ready yet to be shown. Next i trying to add new variable VRAM_busy and check it on . Like this:
    void ht1632c_send_page ()
    {
    uint8_t addr;
    if (VRAM_busy == 0)
    {
    ht1632c_chipselect();
    ht1632c_send_to_display(0b101,1<<2);
    ht1632c_send_to_display(0,1<<6);
    for(addr=0;addr<64;addr++)
    {
    ht1632c_send_to_display(ht1632_shadowram[addr],1<<3);
    }
    ht1632c_chipfree();
    }
    }
    So i add some strings changing variable when video ram changed. Like this :
    void ledarray_left_shift() {
    // shift everything one position left
    uint8_t y, x;
    VRAM_busy=1;
    for(y=0; y<ROWS; y++)
    {
    for(x=0; x<COLS-1; x++)
    {
    ht1632c_set(x,y, ht1632c_get(x+1,y));
    }
    ht1632c_set((COLS-1),y,0);
    }
    VRAM_busy=0;
    }
    So problem of broken lines was solved. But i got new one. It appear what an stuck happen when we not shown our screen on interrupt. So I decide to change init section with additional frequency to interrupt.

    void ledarray_init() {
    // Setup the timer
    // Timer0 CK/1024
    VRAM_busy=0;
    TCCR0 = (1<<CS02) ;// | (1<<CS00);
    TIMSK = (1<<TOIE0);

    // Initialize the HT1632C Driver chip
    ht1632c_init();
    }
    Now scrolling work fine. Hope it help somehow. Thanks one more time for great source code.
    WBR , Konstantin

    • Rick_S says:

      Good idea’s and thank you for sharing your solution. I am also a novice at programming. That is why my code may not always be the most efficient or clean. But I’m having fun and learning as I go.

      Rick

    • Michael says:

      Константин,если у Вас получилось нормально запустить драйвер-не поделитесь новой прошивкой и скрин установки фьюзов.Я любитель и сам исправить прошивку не могу.
      С уважением Михаил.
      Если можно пошлите на почту: flufarafa@mail.ru

      • Rick_S says:

        Welcome Michael,

        Please when responding or creating comments, use English. Most readers of this board will be English speaking, so comments can be more universally understood if in English.

        Thanks,

        Rick

Leave a Reply

Your email address will not be published. Required fields are marked *