找回密码
 立即注册
首页 业界区 安全 记录个IAR程序下载后硬件复位不运行,必须断电复位才运 ...

记录个IAR程序下载后硬件复位不运行,必须断电复位才运行的问题

嫁吱裨 4 小时前
【问题测试】
有个F407的跑马灯的例子,是MDK和IAR两个版本,MDK版本的例子下载并复位后可以正常看到LED闪烁,而IAR的例子下进去后,不会闪烁。
使用TOOL的上位机内核寄存器监测工具测试发现,硬件复位后竟然还在调试状态,邪门了
1.png

2.png


必须断电复位,断电复位后正常了:
4.png

或者LUA命令控制退出调试状态
5.png


【问题解决】

起初以为是启动代码里面封装的函数__iar_program_start造成,将其注释掉,直接跳转到mian也不行
6.png

最后测试发现是半主模式配置问题,之前测试的8.50版本是半主模式配置 + fputc重新写,实际测试不会再执行半主操作了
7.png

进入IAR9,X后,这种配置不行了,必执行半主操作,导致运行起来了,还处于调试模式状态。使用9.X要关闭半主,并且重新定向串口
8.png
  1. /*******************
  2. *
  3. * Copyright 1998-2017 IAR Systems AB.
  4. *
  5. * This is a template implementation of the "__write" function used by
  6. * the standard library.  Replace it with a system-specific
  7. * implementation.
  8. *
  9. * The "__write" function should output "size" number of bytes from
  10. * "buffer" in some application-specific way.  It should return the
  11. * number of characters written, or _LLIO_ERROR on failure.
  12. *
  13. * If "buffer" is zero then __write should perform flushing of
  14. * internal buffers, if any.  In this case "handle" can be -1 to
  15. * indicate that all handles should be flushed.
  16. *
  17. * The template implementation below assumes that the application
  18. * provides the function "MyLowLevelPutchar".  It should return the
  19. * character written, or -1 on failure.
  20. *
  21. ********************/
  22. #include <LowLevelIOInterface.h>
  23. #pragma module_name = "?__write"
  24. int MyLowLevelPutchar(int x)
  25. {
  26.   comSendChar(COM1, x);
  27.    
  28.   return x;
  29.   
  30. }
  31. /*
  32. * If the __write implementation uses internal buffering, uncomment
  33. * the following line to ensure that we are called with "buffer" as 0
  34. * (i.e. flush) when the application terminates.
  35. */
  36. size_t __write(int handle, const unsigned char * buffer, size_t size)
  37. {
  38.   /* Remove the #if #endif pair to enable the implementation */
  39. #if 1
  40.   size_t nChars = 0;
  41.   if (buffer == 0)
  42.   {
  43.     /*
  44.      * This means that we should flush internal buffers.  Since we
  45.      * don't we just return.  (Remember, "handle" == -1 means that all
  46.      * handles should be flushed.)
  47.      */
  48.     return 0;
  49.   }
  50.   /* This template only writes to "standard out" and "standard err",
  51.    * for all other file handles it returns failure. */
  52.   if (handle != _LLIO_STDOUT && handle != _LLIO_STDERR)
  53.   {
  54.     return _LLIO_ERROR;
  55.   }
  56.   for (/* Empty */; size != 0; --size)
  57.   {
  58.     if (MyLowLevelPutchar(*buffer++) < 0)
  59.     {
  60.       return _LLIO_ERROR;
  61.     }
  62.     ++nChars;
  63.   }
  64.   return nChars;
  65. #else
  66.   /* Always return error code when implementation is disabled. */
  67.   return _LLIO_ERROR;
  68. #endif
  69. }
复制代码
 

来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
您需要登录后才可以回帖 登录 | 立即注册