今天看代码的时候发现了新大陆,他的printf不是用串口发的,搞得我还在研究串口是怎么弄的
#define ITM_STIM_U32 (*(volatile unsigned int*)0xE0000000) // Stimulus Port Register word acces
#define ITM_STIM_U8 (*(volatile char*)0xE0000000) // Stimulus Port Register byte acces
#define ITM_ENA (*(volatile unsigned int*)0xE0000E00) // Trace Enable Ports Register
#define ITM_TCR (*(volatile unsigned int*)0xE0000E80) // Trace control register
uint8_t SwoPt_EnCheck(void)
{
if ((ITM_TCR & 1) == 0) {
return 0;
}
if ((ITM_ENA & 1) == 0) {
return 0;
}
return 1;
}
void SwoPt_sendByte(uint8_t SwoPt_c)
{
if(SwoPt_EnCheck())
{
if(ITM_STIM_U8 & 1)
{
ITM_STIM_U8 = SwoPt_c;
}
}
}
#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(EVAL_COM1, (uint8_t) ch);
SwoPt_sendByte((uint8_t) ch);
/* Loop until the end of transmission */
//while (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET)
//{}
return ch;
}
这个是stm32f407LGT6的代码,贴上就能用
选择调试模式
打开窗口
如果出问题
在下面设置成你当前的主频频率