LPC1102 ISP mode failing.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

LPC1102 ISP mode failing.

224 次查看
lpcware
NXP Employee
NXP Employee
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
0 项奖励
2 回复数

215 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by victorpau on Tue May 17 22:20:45 MST 2011
Thanks for your reply, but I don't think that's the problem. I've the same settings in a LPC1114 and it works fine there.

I understand reading the user guide that I should never write a 1 to a reserved bit (IOCON bit 6 is reserved) that's why I write a 0.
0 项奖励

215 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gbm on Fri May 13 06:48:42 MST 2011
The values for IOCON registers are incorrect. Set bit 6 and 7 to 1. Bit 6 basically  disables the pin if set to 0. Also, some pullups/pulldowns are probably needed, aren't they?
0 项奖励