我用MDK在STM32调试中断时出现了一个问题,当程序下载到Flash调试时运行正常,
但当想在SRAM中调试时程序根本进入不了Main函数里面。请给位大侠帮忙啊~
SRAM调试设置没有问题~我试过在SRAM中调试流水灯~
Jlink会提示一个警告:T-bit of XPSR is 0 but shuld be 1.chang to 1
定时中断设置如下设置如下:
//系统中断管理
void NVIC_Config(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_SetVectorTable(NVIC_VectTab_RAM,0X0);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn; //通道
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;//占先优先级
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //从优先级
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void Timer_Config(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_DeInit(TIM2);
TIM_TimeBaseStructure.TIM_Period=2000; //自动重装载寄存器的值
TIM_TimeBaseStructure.TIM_Prescaler= (36000 - 1); //时钟预分频数
TIM_TimeBaseStructure.TIM_ClockDivision=TIM_CKD_DIV1; //采样分频
TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
TIM_ClearFlag(TIM2, TIM_FLAG_Update); //清除溢出中断标志
TIM_ITConfig(TIM2,TIM_IT_Update,ENABLE);
TIM_Cmd(TIM2, ENABLE); //开启时钟
}
此帖出自
小平头技术问答
但加入中断以后程序就不对了~无论是外部中断还是定时中断
一周热门 更多>