Close
0%
0%

AVRxDA28 Target

A Dev board for the new AVR DA series (and even DB series) microcontrollers

Similar projects worth following

I decided to make a board for trying out the new AVR DA and DB series chips.  I decided to design it for the though-hole versions as the new chips still have a bit of hardware errata and thus make it easy to swap in newer revisions as they come out with fewer hardware errata.  All one needs from a programmer is a USB to serial adapter. I've used CH340's and FTDI232's.  An important thing to note is that it of this writing, uploading code can be a bit finicky; not all USB to serial adapters work, I had to use a 2K resistor between the RX and TX pins to make the CH340 happy.  For the software to upload code, I"m using pyupdi which can be found here.

avr64da28_ws2812.zip

Rough example driving two ws12812 LEDs in series.

Zip Archive - 38.77 kB - 06/25/2021 at 20:12

Download

x-zip-compressed - 59.81 kB - 02/03/2021 at 20:26

Download

AVR64DA28_TargetR1_1.zip

KiCad and Gerber files

x-zip-compressed - 311.18 kB - 02/03/2021 at 20:26

Download

  • 1 × R1, 10K ohm 0805 resistor Reset pull-up resistor, optional
  • 1 × R2, 330 ohm 0805 resistor part of the reset push button circuit, optional
  • 1 × R3, 2k ohm 0805 resistor value may need to be tweaked depending on model of USB to serial converter used.
  • 1 × R4, 1k ohm 0805 resistor
  • 1 × D1, 0805 LED

View all 13 components

  • Got some WS2812 LEDs working

    mcu_nerd06/25/2021 at 20:03 0 comments

    The nice thing about these chips is that the internal oscillator can run up to 24MHz. I decided to take a crack at making a function to control some WS2812 LEDs with just C code (the the exception of calling _delay_us().)  Most libraries for driving these LEDs with AVR chips make use of assembly because timing tends to be an issue with relatively slow clock speeds. Since there is no separate input clock pin, the pulse lengths determine if a bit is a one or zero. Below is some code I whipped up to just turn on the green LED at full brightness:

    #define F_CPU 24000000UL
    
    #include <avr/io.h>
    #include <util/delay.h>
    
    #define zero_high .338
    #define zero_low .912
    
    #define one_high .68
    #define one_low .57
    
    int main(void){
    
    _PROTECTED_WRITE(CLKCTRL.OSCHFCTRLA, CLKCTRL_FREQSEL_24M_gc);
    
    PORTC.DIR|=PIN3_bm;
    _delay_ms(2000);
    while(1){
    //for 1
    PORTC.OUT|=PIN3_bm;
    _delay_us(one_high);
    PORTC.OUT=0;
    _delay_us(one_low);
    PORTC.OUT|=PIN3_bm;
    _delay_us(one_high);
    PORTC.OUT=0;
    _delay_us(one_low);
    PORTC.OUT|=PIN3_bm;
    _delay_us(one_high);
    PORTC.OUT=0;
    _delay_us(one_low);
    PORTC.OUT|=PIN3_bm;
    _delay_us(one_high);
    PORTC.OUT=0;
    _delay_us(one_low);
    PORTC.OUT|=PIN3_bm;
    _delay_us(one_high);
    PORTC.OUT=0;
    _delay_us(one_low);
    PORTC.OUT|=PIN3_bm;
    _delay_us(one_high);
    PORTC.OUT=0;
    _delay_us(one_low);
    PORTC.OUT|=PIN3_bm;
    _delay_us(one_high);
    PORTC.OUT=0;
    _delay_us(one_low);
    PORTC.OUT|=PIN3_bm;
    _delay_us(one_high);
    PORTC.OUT=0;
    _delay_us(one_low);
    
    //for zero
    PORTC.OUT|=8;
    _delay_us(zero_high);
    PORTC.OUT=0;
    _delay_us(zero_low);
    PORTC.OUT|=8;
    _delay_us(zero_high);
    PORTC.OUT=0;
    _delay_us(zero_low);
    PORTC.OUT|=8;
    _delay_us(zero_high);
    PORTC.OUT=0;
    _delay_us(zero_low);
    PORTC.OUT|=8;
    _delay_us(zero_high);
    PORTC.OUT=0;
    _delay_us(zero_low);
    PORTC.OUT|=8;
    _delay_us(zero_high);
    PORTC.OUT=0;
    _delay_us(zero_low);
    PORTC.OUT|=8;
    _delay_us(zero_high);
    PORTC.OUT=0;
    _delay_us(zero_low);
    PORTC.OUT|=8;
    _delay_us(zero_high);
    PORTC.OUT=0;
    _delay_us(zero_low);
    PORTC.OUT|=8;
    _delay_us(zero_high);
    PORTC.OUT=0;
    _delay_us(zero_low);
    //last color
    PORTC.OUT|=8;
    _delay_us(zero_high);
    PORTC.OUT=0;
    _delay_us(zero_low);
    PORTC.OUT|=8;
    _delay_us(zero_high);
    PORTC.OUT=0;
    _delay_us(zero_low);
    PORTC.OUT|=8;
    _delay_us(zero_high);
    PORTC.OUT=0;
    _delay_us(zero_low);
    PORTC.OUT|=8;
    _delay_us(zero_high);
    PORTC.OUT=0;
    _delay_us(zero_low);
    PORTC.OUT|=8;
    _delay_us(zero_high);
    PORTC.OUT=0;
    _delay_us(zero_low);
    PORTC.OUT|=8;
    _delay_us(zero_high);
    PORTC.OUT=0;
    _delay_us(zero_low);
    PORTC.OUT|=8;
    _delay_us(zero_high);
    PORTC.OUT=0;
    _delay_us(zero_low);
    PORTC.OUT|=8;
    _delay_us(zero_high);
    PORTC.OUT=0;
    _delay_us(zero_low);
    _delay_us(300);
    }
    
    
    return(0);
    }
    

    The code kinda worked. All three LEDs came on at full brightness.  The root problem was that the chip was interpreting every bit as a "1".  I was curious that if doing bit-wise operations (such as PORTC.OUT|=8;)   was taking up too many cycles so I removed the bit-wise operations and tried instead just setting the entire port register to a number (PORTC.OUT=8;). That worked!  I then decided to make the code a bit more usable by creating an actual function to set colors and once again all three LEDs came on at full brightness. 

    I figured I could compensate for the extra cycles used by reducing the delay values.  I stumbled on this article here and used the minimum values listed for the updated simplified timing constraints table and it worked.  I did try adding back in the bit-wise operations but had the same issue again. The solution is likely to reduce delays a bit more to compensate.  I got my function to work with two WS2812 chained together.  The code of this writing uses pin 16, but due to not using bit-wise operations, it interferes with pin 17.  I'll post the fairly rough code on the project page.  It would be nice if these chips had a separate clock pin, but since they're so cheap it makes sense to spend the effort in to putting up with the timing annoyances.

View project log

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates