各位大拿,小弟在做stm32F051的bootload。现遇到一个问题,app成功烧写进flash,也已经跳转到app了。但是,app中的定时器中断不能执行,串口中断可以执行。我该从什么方向查找问题呢?通过stlink utility读出的app地址内容与原文件的内容在中断向量表那部分是一致的。把app程序改回从0x08000000开始运行,中断也是能正常进入的。
附app程序主函数:
int main(void)
{
uint32_t i=0;
SystemInit();//系统时钟配置
for(i = 0; i < 48; i++)
{
VectorTable = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));
}
/* Enable the SYSCFG peripheral clock*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
/* Remap SRAM at 0x00000000 */
SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);
Global_HardWare_Init();//使能所有用到的外设时钟
GPIO_Configuraton(); //对所用到的所有管脚配置
USART2_Config();//串口配置
ADC_Config();//
DAC_Config();
TIM3_Config();//tim3决定激光器亮灭时间
TIM1_Config();//tim1产生指示灯的PWM信号
TIM2_Config();
R_Open;
while (1)
{
control();
}
}
附iap函数的跳转部分:
void JumpToApp(void)
{
if (((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0x2FFE0000 ) ==0x20000000)/*-- check whether stack pointer legal --*/
{
JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
JumpToApplication = (pFunction) JumpAddress;
__set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS); /*-- initialize theheap & stack pointer --*/
JumpToApplication();
}
}
void TIM3_IRQHandler(void)
{
static uint8_t i=0;
if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) //检查TIM3更新中断发生与否
{
TIM_ClearITPendingBit(TIM3, TIM_IT_Update); //清除TIMx更新中断标志
if(Ctrl_Data.head_f==0||Ctrl_Data.head_f==2)//判断是否在烧写过程中
{
i++;
if(i==5)
{
i=0;
TIM_ITConfig(TIM3, TIM_IT_Update, DISABLE);
USART_ITConfig(USART2, USART_IT_RXNE, DISABLE);
JumpToApp();
}
}
else
i=0;
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
NVIC_InitTypeDef NVIC_InitStructure;
Ctrl_Data.laser_state = SET;
TIM_TimeBaseStructure.TIM_Period = 200;
TIM_TimeBaseStructure.TIM_Prescaler = 23999;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
/* Enable the TIM3 gloabal Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
TIM_ARRPreloadConfig (TIM3,ENABLE);
TIM_ClearITPendingBit(TIM3, TIM_IT_Update); //清除TIMx更新中断标志
TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE);
TIM_Cmd(TIM3, DISABLE);
}
void TIM2_Config(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
NVIC_InitTypeDef NVIC_InitStructure;
TIM_TimeBaseStructure.TIM_Period = 200;
TIM_TimeBaseStructure.TIM_Prescaler = 23999;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
/* Enable the TIM3 gloabal Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPriority = 3;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
TIM_ARRPreloadConfig (TIM2,ENABLE);
TIM_ClearITPendingBit(TIM2, TIM_IT_Update); //清除TIMx更新中断标志
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
TIM_Cmd(TIM2, DISABLE);
}
这些是app中定时器的初始化函数。
定时器会在收到串口的数据后打开。串口接收是用中断做的。app能接收到数据,但是定时器中断却没有运行。
原子哥,通过bootload下进去的APP工程,我改回不用bootload的版本,通过stlink烧进去没有问题。app就增加了中断向量表重映射的代码,ram映射到0x00000000,改了app的地址。比对hex文件,应该怎么比?
一周热门 更多>