http://mbed.org/users/chris/programs/mbedISP/16mhsw with the pull up set for the reset and ISP pins. This program is meant to program the LCP1768 using the ISP interface. The program was originally developed by Chris Styles <http://mbed.org/users/chris/>

Dependencies:   mbed

main.cpp

Committer:
ethankhall
Date:
2011-11-22
Revision:
0:32b3902b0dca

File content as of revision 0:32b3902b0dca:

#include "mbed.h"

DigitalOut led1(LED1);
DigitalOut led2(LED2);

Serial pc (USBTX,USBRX);
Serial target (p28,p27);

// We'll drive this low, and then set the as inputs
// this mimics an open collector style ouput
DigitalInOut reset (p29);
DigitalInOut isp   (p30);

int main() {

    pc.baud(19200);
    target.baud(19200);
   
    // ISP Input with pullup
    isp.input();
    isp.mode(PullUp);

    // pulse reset low
    reset.output();
    reset = 0;
    wait (0.01);
    
    // reset input, with pullup
    reset.input();
    reset.mode(PullUp);
    
    while (!pc.readable()) {}   
   
    // pull ISP and nReset low
    reset.output();
    isp.output();
    reset = 0;
    isp = 0;
    
    wait (0.1);
    
    // Bring target out of reset
    reset.input();
    reset.mode(PullUp);
    
    wait (0.1);

    while (1) {
    
        if (pc.readable()) {
            target.putc(pc.getc());
            led1 = !led1;
        }
    
        if (target.readable()) {
            pc.putc(target.getc());
            led2 = !led2;
        }
    
    }
}