Other Parts Discussed in Thread: TMS320F2800157
器件型号: TMS320F2800157
您好、
我开发了一个引导加载程序、并在以下主题中获得了帮助、以克服引导模式和 BOOTPIN 问题。 我遇到了引导加载程序无法跳转/返回闪存基地址 0x80000 的问题。 我在其他问题中得到了总结、但从未解决过我的问题。
我在下面附上了我的代码。 我将使用 TMS320F2800157 LaunchPad 并使用 GPIO32 作为引导模式引脚。 我设置了 Z1-GPREG1-4、可以将 LaunchPad 上的 GPIO32 切换为引导至 I2C 或闪存。
当引导至闪存时、我的应用程序会按预期运行。 设置 I2C 后、我会看到 TMS320 将数据拉过 I2C 线路、使 LED 闪烁(在代码中)、然后重新启动。 已验证代码中的 bootflag 不等于 1。 这大约是一个 1 秒的间隔、对应于我在示波器上观察 I2C 流量的时间(还与计算出的使用我给定的时钟设置加载引导代码的时间一致)。
我已经将引导加载程序构建为 RAM 编译版本、我想知道跳转/返回到闪存 (0x80000) 是否被捕获并导致重新启动。 我可能还需要一个额外的项目限定符、但我也错过了。
如有任何建议、将不胜感激。
John
//#############################################################################
// BOOTmain.c
// Hex2000 params as follows to provide a 500 khz clock at boot:
// Specify initial value for I2CCLKH register (--i2cclkh, -i2cclkh) 10
// Specify initial value for I2CCLKL register (--i2cclkl, -i2cclkl) 10
// Specify initial value for I2CPSC register (--i2cpsc, -i2cpsc) 0
#include "driverlib.h"
#include "device.h"
#include "board.h"
#include "c2000ware_libraries.h"
#include "i2ca.h"
#include "const.h"
#include "Boot.h"
//###########################################################################
// Local functions declaration
void AppReload(void);
// Main
uint32_t main(void)
{
uint16_t BFlag; // BootFlag - set to reload Application Software
// Step 1. Initialize System Control:
// Enable Peripheral Clocks
Device_init();
// Step 2. Initialize GPIO:
Device_initGPIO();
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
DINT;
// 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();
// PinMux and Peripheral Initialization
Board_init();
GPIO_writePin(LED_BUSY, 1);
// Read the BootFlag status
I2CA_Read(I2C_EEPROM2_ADDR, ADR_FLAG_BOOT, (uint16_t *)&BFlag, 2, WORD);
// Test BootFlag status
if(BFlag == 0x01)
{
GPIO_writePin(LED_BUSY, 0); // LED on
AppReload(); // Will never come back from this call - infinite loop.
}
else
{
GPIO_writePin(LED_BUSY, 1); //GpioDataRegs.GPACLEAR.bit.GPIO30 = 1; // LED off
uint16_t Version = VERSION;
// Read the BootLoader Version and update if needed
I2CA_Read(I2C_EEPROM2_ADDR, ADR_VER_BOOTLOADER, &Version, 2, WORD);
if (Version != VERSION)
{
Version = VERSION;
I2CA_Write(I2C_EEPROM2_ADDR, ADR_VER_BOOTLOADER, &Version, 2, WORD);
}
}
SysCtl_enableWatchdog(); // Enable watchdog module
SysCtl_serviceWatchdog(); // Clear the WD counter
// Use the 4 NOPs and LB 0x80000 in place of return(0x80000) as the return goes off in the weeds.
/* asm(" NOP");
asm(" NOP");
asm(" NOP");
asm(" NOP");
// Jump to flash
asm(" LB 0x80000"); */
return(0x80000);
}
// End of File