打印
[STM32L1]

STM32L152RD芯片调试出现问题,可以有偿解决。谢谢

[复制链接]
3557|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
jusai|  楼主 | 2013-7-12 19:21 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
STM32L152RD芯片调试出现问题
芯片标示“STM32L152RDT6 GH21G VG CHN ES 136”(先期购买)的芯片使用正常。
芯片标示“STM32L152RDT6 GH23X VG CHN GH 246”(近期购买)的芯片出现以下问题:
1.
外部中断EXTI15_10_IRQn在无外部中断发生的情况下不断产生中断。
程序如下:
管脚定义:
#define Power_Insert_PIN GPIO_Pin_15
#define Power_Insert_GPIO_PORT GPIOB
#define Power_Insert_GPIO_CLK RCC_AHBPeriph_GPIOB
#define Power_Insert_EXTI_LINE EXTI_Line15
#define Power_Insert_EXTI_PORT_SOURCE EXTI_PortSourceGPIOB
#define Power_Insert_EXTI_PIN_SOURCE EXTI_PinSource15
#define Power_Insert_EXTI_IRQn EXTI15_10_IRQn
#define Power_Insert_IRQHANDLER EXTI15_10_IRQHandler
#define Power_Insert_IN_Bit() GPIO_ReadInputDataBit(Power_Insert_GPIO_PORT, Power_Insert_PIN)
#define STMPE811_INT_PIN GPIO_Pin_14
#define STMPE811_INT_GPIO_PORT GPIOB
#define STMPE811_INT_GPIO_CLK RCC_AHBPeriph_GPIOB
#define STMPE811_INT_EXTI_LINE EXTI_Line14
#define STMPE811_INT_EXTI_PORT_SOURCE EXTI_PortSourceGPIOB
#define STMPE811_INT_EXTI_PIN_SOURCE EXTI_PinSource14
#define STMPE811_INT_EXTI_IRQn EXTI15_10_IRQn
#define STMPE811_INT_IN_Bit() GPIO_ReadInputDataBit(STMPE811_INT_GPIO_PORT, STMPE811_INT_PIN)
中断配置:
SYSCFG_EXTILineConfig(Power_Insert_EXTI_PORT_SOURCE, Power_Insert_EXTI_PIN_SOURCE); //Power_Insert IRQ
EXTI_InitStructure.EXTI_Line = Power_Insert_EXTI_LINE; //Power_Insert IRQ PB15
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; //EXTI中断
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; //下降沿和上升沿触发
EXTI_InitStructure.EXTI_LineCmd = ENABLE; //使能
EXTI_Init(&EXTI_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = Power_Insert_EXTI_IRQn;
//Power_Insert 中断响应
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 4; //抢占优先级 0
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 4; //子优先级为1
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //使能
NVIC_Init(&NVIC_InitStructure);
SYSCFG_EXTILineConfig(STMPE811_INT_EXTI_PORT_SOURCE, STMPE811_INT_EXTI_PIN_SOURCE); //Power_Insert IRQ
EXTI_InitStructure.EXTI_Line = STMPE811_INT_EXTI_LINE; //触摸屏中断 IRQ PB14
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; //EXTI中断
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //下降沿和上升沿触发
EXTI_InitStructure.EXTI_LineCmd = ENABLE; //使能
EXTI_Init(&EXTI_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = STMPE811_INT_EXTI_IRQn; //触摸屏中断响应
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 5; //抢占优先级 0
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 5; //子优先级为1
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //使能
NVIC_Init(&NVIC_InitStructure);
中断处理:
void Power_Insert_IRQHANDLER(void)
{
MSG msg;
if(EXTI_GetITStatus(Power_Insert_EXTI_LINE) != RESET) //判断是否产生了EXTI15中断
{
if(Power_Insert_IN_Bit()==0)//判断是否是Power_Insert线变低
{
msg.type = Power_Insert_Message;
msg.bPara = Power_In;
Message_To_Center(&msg);
}
else if(Power_Insert_IN_Bit()==1)//判断是否是Power_Insert线变高
{
msg.type = Power_Insert_Message;
msg.bPara = Power_Out;
Message_To_Center(&msg);
}
EXTI_ClearITPendingBit(Power_Insert_EXTI_LINE); //清中断标志
}
/************************触摸屏中断处理*****************/
if(EXTI_GetITStatus(STMPE811_INT_EXTI_LINE) != RESET) //判断是否产生了EXTI14中断
{
if(STMPE811_INT_IN_Bit()==0)//判断是否是Power_Insert线变低
{
TouchOn=SET;
}
EXTI_ClearITPendingBit(STMPE811_INT_EXTI_LINE); //清中断标志
}
}
上述EXTI14和EXTI15交替产生,屏蔽EXTI15-10中断程序运行正常。
2.
单独烧写DFU引导程序或应用程序时能正常运行(上述EXTI15-10中断现象不变)。
当烧写了DFU引导程序和应用程序后,第一次复位运行能正常进入应用程序,再次复位后进入SystemInit函数,执行第一句
“/*!< Set MSION bit */
RCC->CR |= (uint32_t)0x00000100;”
即产生Hard Fault exception 进入HardFault_Handler(),无法运行。
DFU引导程序和应用程序均采用内部HIS时钟。
DFU bootleader 主程序如下:
#define ApplicationAddress 0x0800C000
int main(void)
{
#if defined (USE_STM32L152D_EVAL)
FLASH_Unlock();
FLASH_ClearFlag(FLASH_FLAG_OPTVERRUSR);
#endif
DFU_Button_Config();
/* Check if the Key push-button on STM3210x-EVAL Board is pressed */
//if (DFU_Button_Read() != 0x00)
if (DFU_Button_Read() == 0x00)
{ /* Test if user code is programmed starting from address 0x800C000 */
if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000)
{ /* Jump to user application */
JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);
Jump_To_Application = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) ApplicationAddress);
Jump_To_Application();
}
} /* Otherwise enters DFU mode to allow user to program his application */
NVIC_Configuration();
LCD_Low_Level_Init();
Delay_Timer4_Init();
Power_Ctrl_Init();
Power_Ctrl_On();
LCD_TFT_Init();
LCD_BACKLIGHT_HIGH();
LCD_Display_Image((uint8_t*)gImage_Icon_DFU);
LCD_SetTextColor(0xFFFF);
LCD_Display_StringForPixel(104, " DFU mode ");
/* Enter DFU mode */
DeviceState = STATE_dfuERROR;
DeviceStatus[0] = STATUS_ERRFIRMWARE;
DeviceStatus[4] = DeviceState;
Set_System();
Set_USBClock();
USB_Init();
/* Main loop */
while (1)
{}
}
应用程序中定义:
#define NVIC_VectTab_FLASH ((uint32_t)0x0800C000)
#ifdef VECT_TAB_RAM
/* Set the Vector Table base location at 0x20000000 */
NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
#else /* VECT_TAB_FLASH */
/* Set the Vector Table base location at 0x0800C000 */
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0xC000);
#endif
编译器:
DFU程序仿真复位后寄存器情况:
刚进入SystemInit函数是寄存器情况:
执行RCC->CR |= (uint32_t)0x00000100;进入异常情况:
硬件原理图:
两种芯片在两批PCB板上交替更换焊接,出现现象完全一致,排除了外围硬件故障原因。
求解!!!!!!!!!!!!!!!!!!!!
沙发
jusai|  楼主 | 2013-7-12 19:28 | 只看该作者
有偿不是炫富啊。。是想真正解决问题。

如解决方案正确。可以赠送QQ年会员等其他东西。主要能交个朋友。。谢谢大家了。。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

2

帖子

0

粉丝