本帖最后由 xiang90721 于 2017-6-17 19:15 编辑 不知道各位有使用过rt-thread系统么,我在调试时出现怪问题!使用STM32F429开发板(官方的那个) 不带操作系统时,移植emWin+tft屏(FSMC),运行正常(emWin的demo程序都是正常); 移植rt-thread系统进来,发现程序一直跑飞,最后发现在配置FSMC函数上,将此函数屏蔽,rt-thread系统能正常,否则程序就跑飞!!很是郁闷!! FSMC配置如下: static void LCD_FMCConfig(void) { FMC_NORSRAMInitTypeDef init; FMC_NORSRAMTimingInitTypeDef timingWrite; FMC_NORSRAMTimingInitTypeDef timingRead; /* ʹÄÜFMCʱÖÓ */ RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FMC, ENABLE); /*-- FMC Configuration ------------------------------------------------------*/ /*----------------------- SRAM Bank 4 ----------------------------------------*/ /* FMC_Bank1_NORSRAM4 configuration */ timingWrite.FMC_AddressSetupTime = 4; //5; timingWrite.FMC_AddressHoldTime = 0; timingWrite.FMC_DataSetupTime = 5; //6; timingWrite.FMC_BusTurnAroundDuration = 1; timingWrite.FMC_CLKDivision = 0; timingWrite.FMC_DataLatency = 0; timingWrite.FMC_AccessMode = FMC_AccessMode_A; timingRead.FMC_AddressSetupTime =4;// 5; timingRead.FMC_AddressHoldTime = 0; timingRead.FMC_DataSetupTime =5;// 6; timingRead.FMC_BusTurnAroundDuration = 1; timingRead.FMC_CLKDivision = 0; timingRead.FMC_DataLatency = 0; timingRead.FMC_AccessMode = FMC_AccessMode_A; init.FMC_Bank = FMC_Bank1_NORSRAM4; init.FMC_DataAddressMux = FMC_DataAddressMux_Disable; init.FMC_MemoryType = FMC_MemoryType_SRAM; init.FMC_MemoryDataWidth = FMC_NORSRAM_MemoryDataWidth_16b; init.FMC_BurstAccessMode = FMC_BurstAccessMode_Disable; init.FMC_AsynchronousWait = FMC_AsynchronousWait_Disable; init.FMC_WaitSignalPolarity = FMC_WaitSignalPolarity_Low; init.FMC_WrapMode = FMC_WrapMode_Disable; init.FMC_WaitSignalActive = FMC_WaitSignalActive_BeforeWaitState; init.FMC_WriteOperation = FMC_WriteOperation_Enable; init.FMC_WaitSignal = FMC_WaitSignal_Disable; init.FMC_ExtendedMode = FMC_ExtendedMode_Enable; init.FMC_WriteBurst = FMC_WriteBurst_Disable; init.FMC_ReadWriteTimingStruct = &timingRead; init.FMC_WriteTimingStruct = &timingWrite; FMC_NORSRAMInit(&init); /* - BANK 1 (of NOR/SRAM Bank 1~4) is enabled */ FMC_NORSRAMCmd(FMC_Bank1_NORSRAM4, ENABLE); } 理论上裸机使用此配置正确,没道理加了rt-thread就不行了,所以很郁闷!! 怀疑是否rt-thread初始化的外设和FSMC相冲突了,但屏蔽了rt-thread初始化配置的唯一外设-----串口(当然系统时钟不能屏蔽),也给屏蔽了,问题还是在!!所以彻底郁闷了 期盼大神给我指点指点!!谢谢!! |
看来在STM32上用rt-thread的有点少啊,帖子热度不够,不过感觉rt-thread的驱动模型写的还是挺有参考价值的,顶一下
今天搞定问题了,不是程序冲突,是断言函数的问题!!配置lcd 的FSMC有些参数没用到,我就没配,断言函数将参数配置有问题的用(void0)来写,在裸机时没问题,但不知道到了rt-thread系统上就跑飞了而且stlink都没法定位,,这个原因我也不清楚为啥!!
参数都有问题了,进入函数后不会引起错误吗
STM32的库函数确实会对参数进行检查,比如FMC_NORSRAMInit函数,会对FMC_AddressHoldTime 做检查,因为配置LCD时这个参数没有用到,说以配置为0,但是FMC_NORSRAMInit内部断言assert_param检查范围应是1~15,我并没开启断言检查,所以根据断言函数执行会成((void)0),在裸机时没有问题,不知道为什么加了rt-thread系统后程序会跑飞,大神你知道不?
是配置的参数不符合范围,但实际中这个参数并没用的
STM32的库函数确实会对参数进行检查,比如FMC_NORSRAMInit函数,会对FMC_AddressHoldTime 做检查,因为配置LCD时这个参数没有用到,说以配置为0,但是FMC_NORSRAMInit内部断言assert_param检查范围应是1~15,我并没开启断言检查,所以根据断言函数执行会成((void)0),在裸机时没有问题,不知道为什么加了rt-thread系统后程序会跑飞,大神你知道不?