Close
0%
0%

Raspberry Pi AVR ISP hat

A small board to adapt the Pi SPI interface to AVR programming

Similar projects worth following
88 views
0 followers
Starting from
$12.50
nsayer has 2293 orders / 162reviews
Ships from United States of America

In principle, all it takes to use the Pi SPI bus for AVR programming is just hooking it up to the target, but this limits your programmer to 3.3v levels and offers no protection to the Pi. This hat adds level shifting for the target to support just about any reasonable voltage as well as supplying target power at either 5v or 3.3v through an AP2331 hot-pluggable protection chip.

The level shifting is embodied in two tri-state buffer chips. One is a single chip powered by the Pi 3.3 volt bus that shifts the sole incoming signal (MISO). The other chip is a 4 way (of which 3 are used) to level-shift MOSI and SCK. The third section is used to gate the !RESET signal. Since the !RESET signal itself is also used to gate all of the signals, we can just short the input of that gate to ground. The result is a !RESET output that is either high impedance of low, which is exactly what we want.

We take 5 volts and 3.3 volts from the GPIO connector and switch them with a 3 position switch to the input of the AP2331. The output is the target power, which is used to power the output buffer chip and the target itself. If no target power is supplied, then the target will power the output buffer chip.

Depending on software support, it can be desirable to either use the !SPI_CE0 pin or a separate GPIO pin for the !RESET trigger. There's a solder jumper on the back of the board to allow picking either GPIO 25 or 8 (!SPI_CE0). By default, 25 is selected, as the default linuxspi code in avrdude wants a separate pin.

Adobe Portable Document Format - 24.12 kB - 11/02/2020 at 17:52

Preview
Download

- 74.22 kB - 11/02/2020 at 17:52

Download

sch - 243.14 kB - 11/02/2020 at 17:52

Download

  • Software support

    Nick Sayer11/02/2020 at 18:17 0 comments

    avrdude 6.3 comes with a bit-banged GPIO driver that is suitable for use with this hat. All you need to do is add this to your avrdude.conf file:

    programmer
        id = "pihat";
        desc = "Use the Linux sysfs interface to bitbang GPIO lines";
        type = "linuxgpio";
        reset = 25;
        miso = 9;
        mosi = 10;
        sck = 11;
    ;

    This works, but there is a higher performance variant of this that actually uses the Pi SPI bus. To use it, you must first enable SPI in raspi-config. Once this is done, you'll see /dev/spi0.0 show up. Apply the patch (see below) to avrdude and then add this section to your avrdude.conf file:

    programmer 
      id = "pihat"; 
      desc = "Use Linux SPI device in /dev/spidev*"; 
      type = "linuxspi"; 
      reset = 25; 
      baudrate=100000; 
    ; 
    

    The patch to avrdude is here. This patch also adds support for using the TPI adapter for TPI programming. 

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