[应用相关] 主函数中各函数的排序问题

[复制链接]
919|5
 楼主| 豆腐块 发表于 2016-11-23 21:05 | 显示全部楼层 |阅读模式

int main(void)
{ unsigned int i,j;
  /*!< At this stage the microcontroller clock setting is already configured to
       168 MHz, this is done through SystemInit() function which is called from
       startup file (startup_stm32f4xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */  
  USART_Config();
  DMA_Config();
  NVIC_Config();
  GPIO_SetBits(GPIOF, GPIO_Pin_10); //关闭LED
  //add a long delay wait for DP83848 finish reset  
        
                for(i=0;i<50;i++){
                        for(j=0;j < 65500;j++);
                }
#ifdef SERIAL_DEBUG
  DebugComPort_Init();  
#endif        
           

          ETH_BSP_Config();                                /* Initilaize the LwIP stack */
        LwIP_Init();                                      /* tcp echo server Init */         
          tcp_echoserver_init();                        /* Infinite loop */


while (1)
  {
  if(ETH_CheckFrameReceived()){/* check if any packet received */                  
                              LwIP_Pkt_Handle();/* process received ethernet packet */         
}
LwIP_Periodic_Handle(LocalTime); /* handle periodic timers for LwIP */         
}
以上是我的主函数,在主函数中主要有串口初始化函数和lwip初始化函数,现在是串口函数能用,网络部分没反应;当这两部分函数的位置互换,结果就是网络好用,串口没反应。有明白的帮着解释解释啊。。。。。。
309030106 发表于 2016-11-23 21:16 | 显示全部楼层
建议硬仿真一下,看下初始化程序怎么没有执行下去,这样也能找到问题所在
Ryze 发表于 2016-11-23 21:27 | 显示全部楼层
函数换个位置就有不同的结果?会不会是硬件电路的问题
Garen2 发表于 2016-11-23 21:39 | 显示全部楼层
请问ETH_CheckFrameReceived函数是哪个函数库里的,从哪能下载到这个函数库
Garen2 发表于 2016-11-23 21:47 | 显示全部楼层

应该说函数的位置是没有关系的,程序是一步一步执行的。只要能执行到就可以,可能子函数没有执行。
戈卫东 发表于 2016-11-23 21:50 | 显示全部楼层
你的IO冲突了吧?先做的会被后面的盖掉。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

75

主题

635

帖子

2

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