Week

seven

embeded programming

  • embeded programming 🔦

    highlights

    Attiny44 button blink USBtinyISP as Programmer
    Find some interesting mistake on my homebrew CNC pcb mill Summerized some tips for designer used arduino before to jump on to programming Attiny in C

    Attiny44 echo program
    had some questions about using 8mhz resonator.

    Attiny44 button blink Arduino as Programmer
    easy peasy





    • usbtinyISP







    • as programmer



    push button blink program with USBtiny ISP


    notes for designers used arduino before

    • 1.Read Data sheet to know if the Pin is located on A/B
    •   DDRA/B = 0b00000001 (1st pin set as output)
    •   PORTA/B = 0b00000001(1st pin set as high)
    •   PINA/B & 0b0010000 (to get data from 5 bits from A)
    • 2.Arduino PinMode/Digital Read/Digital Write Replacement in C:
    •   //Preamble
    •   #define bit_get(p,m) ((p) & (m))
    •   #define bit_set(p,m) ((p) |= (m)) //no idea why OR is necessary
    •   #define bit_clear(p,m) ((p) &= ~(m)) //no idea why AND is necessary
    • //main
    •   bit_set(DDRA,BIT(7)); //Enable output on the LED pin
    •   if(bit_get(PINA,BIT(3)))//button is pushed or not
    •   bit_clear(PORTA,BIT(7));//LED is off
    • 3.Bit Shift
    •   #define output_pin (1 << PB2) // output_pin = 0b00000100 ( 1<<2)
    •   //so btw is “PB” ignored?




    The first time I use my home brew PCB mill and I found out I install one motor on the wrong side and the result circuit is mirrored lol




    the setup if using mac 2017 ver. make sure you have usb 2.0 for everything






    code loaded



    The left is button pushed and swing the board. The led is blinking so fast that people hardly recongnized when staring at. Through swinging it, it's revealed as dash line in the air (from Elliot Williams's AVR programming)





    • Attiny 44







    • echo program


    attiny 44 echo program
    why can't be run on 8mhz?



    echoing using arduino serial monitor, works perfectly using the board with 20mhz resonator




    using a board with 8mhz resonator, I changed the make file to 8mhz, but it didn't echo on all BAUD channel. Why changing clock speed influnce the program





    • arduino







    • as ISP



    ARDUINO as ISP

    esay peasy following high-low tech instruction





    Most important tip of all. Make sure you have usb2.0 for everything above. A easy way to convert 3.0 to 2.0 is a usb 2.0 hub





    • why I built







    • a giant cube



    adds up for final proposal (will be moved to the right place)

    snap on connection for vcc ground data in/out