一个关于LPC1343快速弹出flash disk的技术问题

2019-03-25 20:43发布

 您好。问题如下。NXP LPC1343使用下面的代码,通过USB线接上设备到电脑,按下SW3按钮(PIO2_11), 电脑马上弹出一个flash disk.可供用户快速更新firmware. 但因为后续开发要求用到USB HID功能,为了使用LPC1343 on chip driver, 需要在Keil开发工具中把Read/write memory areas作如下修改:               Start                       Size IRAM1: 0x10000000          0x2000  改为0x10000180              0x1E80 改完之后,再执行下面的代码,通过USB线接上设备到电脑,按下SW3按钮(PIO2_11), 电脑要过约20~25秒才弹出一个flash disk供用户更新firmware。请问有什么办法可以更改IRAM1为: 0x10000180               0x1E80后,仍能让电脑快速弹出flash disk吗?   /* This data must be global so it is not read from the stack */ typedef void (*IAP)(uint32_t [], uint32_t []); IAP iap_entry = (IAP)0x1fff1ff1; uint32_t command[5], result[4];   (代码补充在楼下,超过字数了) 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
1条回答
klgyandlazy
1楼-- · 2019-03-26 01:23
_NXP LPC1000_ /* This function resets some microcontroller peripherals to reset

   hardware configuration to ensure that the USB In-System Programming module

   will work properly. It is normally called from reset and assumes some reset

   configuration settings for the MCU.

   Some of the peripheral configurations may be redundant in your specific

   project.

*/

void ReinvokeISP(void)

{

      /* make sure USB clock is turned on before calling ISP */

      LPC_SYSCON->SYSAHBCLKCTRL |= 0x04000;

      /* make sure 32-bit Timer 1 is turned on before calling ISP */

      LPC_SYSCON->SYSAHBCLKCTRL |= 0x00400;

      /* make sure GPIO clock is turned on before calling ISP */

      LPC_SYSCON->SYSAHBCLKCTRL |= 0x00040;

      /* make sure IO configuration clock is turned on before calling ISP */

      LPC_SYSCON->SYSAHBCLKCTRL |= 0x10000;

      /* make sure AHB clock divider is 1:1 */

      LPC_SYSCON->SYSAHBCLKDIV = 1;

      

      /* Send Reinvoke ISP command to ISP entry point*/

      command[0] = 57;

      

      /* Set stack pointer to ROM value (reset default) This must be the last

       piece of code executed before calling ISP, because most C expressions

       and function returns will fail after the stack pointer is changed. */

      __set_MSP(*((uint32_t *)0x1FFF0000)); /* inline asm function */

      

      /* Enter ISP. We call "iap_entry" to enter ISP because the ISP entry is done

       through the same command interface as IAP. */

      iap_entry(command, result);

      // Not supposed to come back!

}



/* Bit access of uint32 */

unsigned char GetUInt32BitValue(unsigned int source, unsigned char bitIndex)

{

      unsigned char value;

      //value = (unsigned char)((source >> bitIndex) & 0x00000001); this take more spaces than below

      source = source >> bitIndex;

      value = (unsigned char)(source & 0x00000001);

      return value;

}



/* When connect to a PC, wait until user presses the boot buttons */

void BootloaderRequest(void)

{

      unsigned int key;

      key = GetUInt32BitValue(LPC_GPIO0->DATA, 3);

      // key = 1, then the device connects to PC

      if(key == 1)

      {

            //key = GetUInt32BitValue(LPC_GPIO0->DATA, 1);

            key = GetUInt32BitValue(LPC_GPIO2->DATA, 11);

            // key = 0, then the boot key has been pressed

            if(key == 0)

            {

                  GPIOSetValue( 0, 2, 1); // turn on LED5



                  /* Disable SYSTICK timer and interrupt before calling into ISP */

                  SysTick->CTRL &= ~(SYSTICK_ENABLE | SYSTICK_TICKINT);



                  /* Start ISP */

                  ReinvokeISP();

            }

      }

}



int main (void)

{

      /* for delay loop */

      volatile int n;

      

      SystemInit();



      /* Initialize input port pins */

      LPC_IOCON->;PIO0_2 = 0x10;           //LED5, Pull-up resistor enabled

      GPIOSetDir( 0, 2, 1);

      /* Init */

      LPC_IOCON->;PIO0_1 &= ~0x1F;               //Inactive (no pull-down/pull-up resistor enabled)    PIO0_1 -> DTH0033 boot button

      LPC_IOCON->;PIO0_3 &= ~0x1F;             //Inactive (no pull-down/pull-up resistor enabled)  PIO0_3 -> DTH0033 USB_VBUS

      LPC_IOCON->;PIO2_11 &= ~0x1F;        //Inactive (no pull-down/pull-up resistor enabled)      PIO2_11 -> DTH0033 SW3 button



      GPIOSetValue( 0, 2, 0);         //LED5 is off at the beginning until user press SW3 button (PIO2_11)

      

      while (1)

      {

            /* Check SW3 button has been pressed? */

            BootloaderRequest();

      }

}

一周热门 更多>