请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:TMDSCNCD28379D 主题中讨论的其他器件:C2000WARE
您好!
在我们的应用程序中、我们大部分时间将从闪存引导。 我们希望能够定期执行固件更新。 在本例中、我们似乎会使用默认 OTP 设置从闪存引导、因为我们希望大部分时间采用这种方式引导。 我不确定是否有方法可以在闪存和 USB 之间切换引导模式?
我猜不会有。
如果正确、我唯一能想到的就是将位于以下位置的引导 ROM 代码合并 到应用程序中:C:\ti\c2000\C2000Ware_4_03_00_00\libraries\boot_rom\f2837xd\revB。 为了对此进行测试、我首先介绍了在闪存外运行的 leed_ex1_blinky 应用程序。 我会执行以下操作:
- 将 USB 引导 ROM 代码整合到 lead_ex1_blinky 应用程序中
- 在进入 while (1)循环之前、检查是否连接了 USB
- 如果不是、我继续执行并开始执行 led_ex1_blinky 应用
- 如果它是我调用 USB_Boot ()
void main(void) { // // Initialize device clock and peripherals // Device_init(); // // Initialize GPIO and configure the GPIO pin as a push-pull output // Device_initGPIO(); GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD); GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT); // // Initialize PIE and clear PIE registers. Disables CPU interrupts. // Interrupt_initModule(); // // Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR). // Interrupt_initVectorTable(); // // Enable Global Interrupt (INTM) and realtime interrupt (DBGM) // EINT; ERTM; uint32_t gpio46_value = GPIO_readPin(46); if(gpio46_value == 1) //Checking whether USB is connected or not. { DevCfgRegs.DC12.bit.USB_A = 1; Uint32 EntryAddr = USB_Boot(USB_BOOT); //Calling USB_Boot function. return EntryAddr; } // // Loop Forever // for(;;) { // // Turn on LED // GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0); // // Delay for a bit. // DEVICE_DELAY_US(500000); // // Turn off LED // GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1); // // Delay for a bit. // DEVICE_DELAY_US(500000); } }
在 USB_Boot ()中,它卡在 USB_Boot_Init ()中,具体来说: while (ClkCfgRegs.SYSPLLSTS.bit.lock!= 1){;} //等待 PLL 锁定
//Initialize the USB module void USB_Boot_Init() { uint32_t EntryAddr = 0xFFFFFFFF; //Soprano //Lock the main PLL< aux PLL and enable the USB module clock // //USBCLK = 120 MHz / 2, sourced from the external oscillator for precision // //SYSCLK must be greater than USBCLK / 2, according to Design. The PLL minimum //Fout is 110 MHz, so let's set the multiplier to give 120 MHz and keep the //output divider at 1. EALLOW; ClkCfgRegs.CLKSRCCTL1.bit.OSCCLKSRCSEL = 0x0; //Use INTOSC2 (~10 MHz) as the main PLL clock source ClkCfgRegs.SYSPLLMULT.all = 12; //Set IMULT to 12, clear FMULT ClkCfgRegs.SYSPLLCTL1.bit.PLLEN = 1; //Enable the main PLL ClkCfgRegs.SYSCLKDIVSEL.bit.PLLSYSCLKDIV = 0; //Set PLLSYSCLKDIV to 1 while (ClkCfgRegs.SYSPLLSTS.bit.LOCKS != 1) {;} //Wait for the PLL to lock ClkCfgRegs.SYSPLLCTL1.bit.PLLCLKEN = 1; //Turn off the main PLL bypass ClkCfgRegs.CLKSRCCTL2.bit.AUXOSCCLKSRCSEL = 0x1; //Use XTAL (20 MHz) as the aux PLL clock source ClkCfgRegs.AUXPLLMULT.all = 6; //Set IMULT to 6, clear FMULT - 120MHz ClkCfgRegs.AUXPLLCTL1.bit.PLLEN = 1; //Enable the aux PLL ClkCfgRegs.AUXCLKDIVSEL.bit.AUXPLLDIV = 2/2; //Set AUXPLLDIV to 2 while (ClkCfgRegs.AUXPLLSTS.bit.LOCKS != 1) {;} //Wait for the PLL to lock ClkCfgRegs.AUXPLLCTL1.bit.PLLCLKEN = 1; //Turn off aux PLL bypass CpuSysRegs.PCLKCR11.bit.USB_A = 1; //Enable the clock to the USB module EntryAddr = TI_OTP_C1BROM_ESCAPE_POINT_13; if((EntryAddr != 0xFFFFFFFF) && (EntryAddr != 0x00000000)) { /*if OTP is programmed, then call OTP function*/ ((void (*)(void))EntryAddr)(); } //Connect the PHY to the GPIO pins by setting the GPBAMSEL //bits for GPIOs 42 and 43. VBUS and ID are now de-spec'd //due to the lack of a 5V fail-safe ESD structure, so //GPIOs 46 and 47 are not muxed out. GpioCtrlRegs.GPBAMSEL.bit.GPIO42 = 1; GpioCtrlRegs.GPBAMSEL.bit.GPIO43 = 1; EDIS; //Register the USB interrupt handler and enable CPU interrupts c1brom_enable_pie_in_boot(0); EALLOW; PieVectTable.USBA_INT = &UsbIntHandler; PieCtrlRegs.PIEIER9.bit.INTx15 = 1; EDIS; IER |= M_INT9; EINT; EntryAddr = TI_OTP_C1BROM_ESCAPE_POINT_13; if((EntryAddr != 0xFFFFFFFF) && (EntryAddr != 0x00000000)) { /*if OTP is programmed, then call OTP function*/ ((void (*)(void))EntryAddr)(); } //Reset the USB driver's global variables ResetUsbDriver(); //Force USB device mode by setting DEVMODOTG and DEVMOD USBREG32(USB_O_GPCS) = 0x3; //Clear active interrupts USBREG16(USB_O_TXIS); USBREG16(USB_O_RXIS); USBREG8(USB_O_IS); //Set up endpoint 1 for bulk transfers with a 64-byte FIFO USBREG8(USB_O_EPIDX) = 1; USBREG8(USB_O_RXFIFOSZ) = 0x03; USBREG16(USB_O_RXFIFOADD) = 0x100; USBREG8(USB_O_RXCSRH1) = 0x40; //Enable USB interrupts for EP0 transmit/receive, EP1 receive, disconnection, and reset USBREG16(USB_O_TXIE) = 0x0001; USBREG16(USB_O_RXIE) = 0x0002; USBREG8(USB_O_IE) = (USB_IE_DISCON | USB_IE_RESET); //Attach the USB PHY to the bus USBREG8(USB_O_POWER) |= USB_POWER_SOFTCONN; }
对我做错了什么有什么想法吗?
为什么它要等待 PLL 锁定?
感谢您的任何帮助!
布伦特