ArduinoISP - this sketch turns the Arduino into a AVRISP...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
// this sketch turns the Arduino into a AVRISP // using the following pins: // 10: slave reset // 11: MOSI // 12: MISO // 13: SCK / // Put an LED (with resistor) on the following pins: // 9: Heartbeat - shows the programmer is running // 8: Error - Lights up if something goes wrong (use red if that makes sense) // 7: Programming - In communication with the slave // // October 2009 by David A. Mellis // - Added support for the read signature command // // February 2009 by Randall Bohn // - Added support for writing to EEPROM (what took so long?) // Windows users should consider WinAVR's avrdude instead of the // avrdude included with Arduino software. // // January 2008 by Randall Bohn // - Thanks to Amplificar for helping me with the STK500 protocol // - The AVRISP/STK500 (mk I) protocol is used in the arduino bootloader // - The SPI functions herein were developed for the AVR910_ARD programmer // - More information at / #include "pins_arduino.h" // defines SS,MOSI,MISO,SCK #define RESET SS # #define LED_HB 9 #define LED_ERR 8 #define LED_PMODE 7 # #define HWVER 2 #define SWMAJ 1 #define SWMIN 18 # // STK Definitions #define STK_OK 0x10 #define STK_FAILED 0x11 #define STK_UNKNOWN 0x12 #define STK_INSYNC 0x14 #define STK_NOSYNC 0x15 #define CRC_EOP 0x20 //ok it is a space. .. # void pulse(int pin, int times); v void setup() { Serial.begin(19200); pinMode(7, OUTPUT); pulse(7, 2); pinMode(8, OUTPUT); pulse(8, 2); pinMode(9, OUTPUT); pulse(9, 2); } int error=0; int pmode=0;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
// address for reading and writing, set by 'U' command int here; uint8_t buff[256]; // global block storage u #define beget16(addr) (*addr * 256 + *(addr+1) ) typedef struct param { uint8_t devicecode; uint8_t revision; uint8_t progtype; uint8_t parmode; uint8_t polling; uint8_t selftimed; uint8_t lockbytes; uint8_t fusebytes; int flashpoll; int eeprompoll; int pagesize; int eepromsize; int flashsize; } parameter; p parameter param; p // this provides a heartbeat on pin 9, so you can tell the software is running. uint8_t hbval=128; int8_t hbdelta=8; void heartbeat() { if (hbval > 192) hbdelta = -hbdelta; if (hbval < 32) hbdelta = -hbdelta; hbval += hbdelta; analogWrite(LED_HB, hbval); delay(40); } void loop(void) { // is pmode active? if (pmode) digitalWrite(LED_PMODE, HIGH);
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/31/2011 for the course CS 302 taught by Professor J.parker during the Spring '08 term at University of Texas.

Page1 / 9

ArduinoISP - this sketch turns the Arduino into a AVRISP...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online