Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 2 months ago.
LPC11U35 launch AutoISP by a specific USART character
Hello,
I am trying to launch ISP by USART but it does not work. When i send the character 0 to USART then LED is stopped but ISP is not launched. I do not know why. Could you help me ?
#include "mbed.h"
#include "USBSerial.h"
//Virtual serial port omver USB
USBSerial serial;
Serial pc(P0_19, P0_18);
DigitalOut myled(LED1);
#define IAP_ENTRY_LOCATION 0X1FFF1FF1
typedef void (*IAP_ENTRY_T)(unsigned int[5], unsigned int[4]);
void IAP_Entry(unsigned int cmd_param[5], unsigned int status_result[4])
{
((IAP_ENTRY_T) IAP_ENTRY_LOCATION)(cmd_param, status_result);
}
void IAP_ReinvokeISP(){
uint32_t command[5], result[4];
//SCB->VTOR = 0;
//LPC_SYSCON->SYSAHBCLKCTRL |= 0x14440;
LPC_SYSCON->SYSAHBCLKCTRL |= 0x04000;
LPC_SYSCON->SYSAHBCLKCTRL |= 0x00400;
LPC_SYSCON->SYSAHBCLKCTRL |= 0x00040;
LPC_SYSCON->SYSAHBCLKCTRL |= 0x10000;
LPC_SYSCON->SYSAHBCLKDIV = 1;
command[0] = 57;
IAP_Entry(command, result);
}
void callback() {
// Note: you need to actually read from the serial to clear the RX interrupt
char character = serial.getc();
if (character == '0'){
IAP_ReinvokeISP();
}
}
int main(void) {
pc.baud(9600);
serial.attach(&callback);
//uint8_t buf[128];
while(1)
{
wait (0.5);
myled = !myled;
wait(0.5);
}
}