J 창고

[ARM] stm32f103c8 KEIL에서 printf 사용하기 본문

컴퓨터/Firmware

[ARM] stm32f103c8 KEIL에서 printf 사용하기

JSFamily 2015. 4. 26. 11:43



USART 를 뚫는 삽질을 시작한 계기도..


Printf 를 사용하려고 했던 것인데...




진작에 좀 제대로 검색을 해 볼걸...





소스에


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#ifdef __GNUC__
  /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
     set to 'Yes') calls __io_putchar() */
  #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
  #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
 
 
 
 
PUTCHAR_PROTOTYPE
{
  /* Place your implementation of fputc here */
  /* e.g. write a character to the USART */
  USART_SendData(USART1, (uint8_t) ch);
 
  /* Loop until the end of transmission */
  while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET)
  {}
 
  return ch;
}
 
 

cs



이렇게 코드를 넣으면 되고...



결정적으로







Use MicroLIB를 체크 해야함......  ㅠㅠ


그러니 바로 되네....... Orz


이 MicroLIB 체크 하나때문에 한참을 헤맸네...





Comments