lpcware

LPC1102 ISP mode failing.

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by victorpau on Fri May 13 06:21:46 MST 2011
Hello,

I'm developing some software for the LPC1102, and I created the code to check if a input pin is activated to enter the ISP mode on startup. I made my code according to the Application note, so it should be fine, but somehow it doesn't work. I got 2 devices bricked that I've no way to program again. The code is:


unsigned long command[5];
unsigned long result[5];

typedef void (*IAP)(uint32_t [], uint32_t []);
IAP iap_entry2 = (IAP)0x1fff1ff1;


void ReinvokeISP(void) {
LPC_SYSCON->SYSAHBCLKCTRL |= 0x04000;
LPC_SYSCON->SYSAHBCLKCTRL |= 0x00400;
LPC_SYSCON->SYSAHBCLKCTRL |= 0x00040;
LPC_SYSCON->SYSAHBCLKCTRL |= 0x10000;
LPC_SYSCON->SYSAHBCLKDIV = 1;
command[0] = 57;
__set_MSP(*((uint32_t *) 0x1FFF0000)); /* inline asm function */
iap_entry2(command, result);
}

int main(void) {

uint32_t temp = 0;

LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 6);

LPC_IOCON->R_PIO0_11 = 0x91;
LPC_IOCON->R_PIO1_0 = 0x81;
LPC_IOCON->R_PIO1_1 = 0x81;
LPC_IOCON->R_PIO1_2 = 0x81;

GPIOSetDir(PORT1, 2, 0);
        /*The while is to check the entrance several times and delay the startup a bit in case the power doesn't get on time to the line*/
while (temp++ < 100000)
if ((GPIOGetValue(PORT1, 2) == 1)) {
ReinvokeISP();
}
//...... Main continues, but it's not supposed to get here if PIO1_2 == 1
//It continues with the normal code independently of PIO1_2 being 0 or 1
}


I would appreciate any info or comments about it. I've tested it with this configuration, and without the while loop (I thought maybe the power lines were longer in the PIO pin and it was getting there later than it checks.

Thank you in advance,

Victor Pau

Outcomes