久芯网

加入printf语句后出现如下错误.求助

avatar 厦门浪子 提问时间: 2023-09-18 15:50:15 / 未解决
加入printf语句后出现如下错误.求教如何解决


Error: L6406E: No space in execution regions with .ANY selector matching ddl.o(i.ddl_memclr)

代码里面已经重定位了。
  1. //取消ARM的半主机工作模式
  2. #pragma import(__use_no_semihosting)                             
  3. struct __FILE {
  4.     int handle;
  5. };

  6. FILE __stdout;         
  7. _sys_exit(int x)
  8. {
  9.     x = x;
  10. }

  11. int fputc(int ch, FILE *f){      
  12.     while((USART1->SR&0X40)==0);
  13.     USART1->DR = (u8) ch;      
  14.     return ch;
  15. }
复制代码


1个回答
  • avatar 小歆-2051663
    回答时间: 2023-09-18 16:21:45

    正常应该用下面的代码实现printf函数功能的 #ifdef __GNUC_ #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) #else #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) #endif PUTCHAR_PROTOTYPE { HAL_UART_Transmit(&huart2, (uint8_t *)&ch, 1, 0xFFFF); return ch; } 复制代码

会员中心 微信客服
客服
回到顶部