[51单片机] C8051F120中断服务程序忽然全部失灵,请高手帮助分析原因

[复制链接]
2395|10
 楼主| humaga 发表于 2016-5-19 15:30 | 显示全部楼层 |阅读模式
本人最近使用C8051F120做一个电动机控制电路,编程时遇到了问题,请高手帮助分析。程序共用了4个定时器、外部硬件中断(PCA)4路,程序启动时很正常,但运行10几秒到几分钟后(时间不固定),会出现所用中断程序全面进不去的情况,不知道啥原因,请高手帮助分析。硬件原因?软件原因?还是?头疼死了。
 楼主| humaga 发表于 2016-5-19 15:34 | 显示全部楼层
中断服务程序进不去的时候,主程序还在正常运行,手动调试程序还能单步调试控制LED,证明程序并没有跑飞或死机,但所有的中断服务程序都进不去了。不知道什么原因。
ningling_21 发表于 2016-5-19 16:47 | 显示全部楼层
humaga 发表于 2016-5-19 15:34
中断服务程序进不去的时候,主程序还在正常运行,手动调试程序还能单步调试控制LED,证明程序并没有跑飞或 ...

这几个中断有没有在程序中被关闭?
yhn1973 发表于 2016-5-19 17:03 | 显示全部楼层
这问题只有贴程序才知道,否则就是猜哑谜
bkn1860 发表于 2016-5-19 17:24 | 显示全部楼层
要猜出结果来还真不容易
ayb_ice 发表于 2016-5-19 18:31 来自手机 | 显示全部楼层
应该是EA被改写了
mohanwei 发表于 2016-5-20 10:18 | 显示全部楼层
我知道,是某种原因
1113240207 发表于 2016-5-20 12:03 | 显示全部楼层
  1. int application_start(void)
  2. {
  3.   app_log_trace();
  4.   OSStatus err = kNoErr;
  5.   app_context_t* app_context;
  6.   mico_Context_t* mico_context;
  7.   LinkStatusTypeDef wifi_link_status;

  8.   /* Create application context */
  9.   app_context = ( app_context_t *)calloc(1, sizeof(app_context_t) );
  10.   require_action( app_context, exit, err = kNoMemoryErr );

  11.   /* Create mico system context and read application's config data from flash */
  12.   mico_context = mico_system_context_init( sizeof( application_config_t) );
  13.   require_action(mico_context, exit, err = kNoResourcesErr);
  14.   app_context->appConfig = mico_system_context_get_user_data( mico_context );
  15.   app_context->mico_context = mico_context;
  16.   app_context_global = app_context;

  17.   /* user params restore check */
  18.   if(app_context->appConfig->configDataVer != CONFIGURATION_VERSION){
  19.     err = mico_system_context_restore(mico_context);
  20.     require_noerr( err, exit );
  21.   }

  22.   /* mico system initialize */
  23.   err = mico_system_init( mico_context );
  24.   require_noerr( err, exit );
  25.   MicoSysLed(true);

  26.   // fix for AP down problem
  27.   err = mico_system_notify_register( mico_notify_WIFI_CONNECT_FAILED, (void *)appNotify_ConnectFailedHandler, app_context->mico_context );
  28.   require_noerr_action(err, exit, app_log("ERROR: MICOAddNotification (mico_notify_WIFI_CONNECT_FAILED) failed!") );

  29.   // block here if no wifi configuration.
  30.   while(1){
  31.     if( mico_context->flashContentInRam.micoSystemConfig.configured == wLanUnConfigured ||
  32.        mico_context->flashContentInRam.micoSystemConfig.configured == unConfigured){
  33.          mico_thread_msleep(100);
  34.        }
  35.     else{
  36.       break;
  37.     }
  38.   }

  39.   /* Bonjour for service searching */
  40.   MICOStartBonjourService( Station, app_context );

  41.   /* check wifi link status */
  42.   do{
  43.     err = micoWlanGetLinkStatus(&wifi_link_status);
  44.     if(kNoErr != err){
  45.       mico_thread_sleep(1);
  46.     }
  47.   }while(kNoErr != err);

  48.   if(1 ==  wifi_link_status.is_connected){
  49.     app_context->appStatus.isWifiConnected = true;
  50.     MicoRfLed(true);
  51.   }
  52.   else{
  53.     app_context->appStatus.isWifiConnected = false;
  54.     MicoRfLed(false);
  55.   }

  56.   /* start cloud service */
  57. #if (MICO_CLOUD_TYPE == CLOUD_FOGCLOUD)
  58.   app_log("MICO CloudService: FogCloud.");
  59.   err = MiCOStartFogCloudService( app_context );
  60.   require_noerr_action( err, exit, app_log("ERROR: Unable to start FogCloud service.") );
  61. #elif (MICO_CLOUD_TYPE == CLOUD_ALINK)
  62.   app_log("MICO CloudService: Alink.");
  63. #elif (MICO_CLOUD_TYPE == CLOUD_DISABLED)
  64.   app_log("MICO CloudService: disabled.");
  65. #else
  66.   #error "MICO cloud service type is not defined"
  67. #endif

  68.   /* start user thread */
  69.   err = startUserMainThread( app_context );
  70.   require_noerr_action( err, exit, app_log("ERROR: start user_main thread failed!") );

  71. exit:
  72.   mico_rtos_delete_thread(NULL);
  73.   return err;
  74. }
ayb_ice 发表于 2016-5-20 12:14 来自手机 | 显示全部楼层
用了rtos,估计移植有BUG吧
killerblood 发表于 2017-2-26 22:45 | 显示全部楼层
楼主你的问题解决了么???,我遇到的问题和你一样,目前也还没解决
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

2

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部