STM32+Keil 如何使用printf函数?
时间:11-10
来源:互联网
点击:
- ture.GPIO_Speed=GPIO_Speed_40MHz;*/
- GPIOA_InitStructure.GPIO_OType=GPIO_OType_PP;
- GPIOA_InitStructure.GPIO_PuPd=GPIO_PuPd_NOPULL;
- GPIO_Init(GPIOA,&GPIOA_InitStructure);
- while(1)
- {
- }
- }
- #ifdefUSE_FULL_ASSERT
- /**
- *@briefReportsthenameofthesourcefileandthesourcelinenumber
- *wheretheassert_paramerrorhasoccurred.
- *@paramfile:pointertothesourcefilename
- *@paramline:assert_paramerrorlinesourcenumber
- *@retvalNone
- */
- voidassert_failed(uint8_t*file,uint32_tline)
- {
- /*Usercanaddhisownimplementationtoreportthefilenameandlinenumber*/
- printf("\n\rWrongparametervaluedetectedon\r\n");
- printf("file%s\r\n",file);
- printf("line%d\r\n",line);
- /*Infiniteloop*/
- /*while(1)
- {
- }*/
- }
- #endif
- /**
- *@briefRetargetstheClibraryprintffunctiontotheUSART.
- *@paramNone
- *@retvalNone
- */
- PUTCHAR_PROTOTYPE
- {
- /*Placeyourimplementationoffputchere*/
- /*e.g.writeacharactertotheUSART*/
- USART_SendData(EVAL_COM1,(uint8_t)ch);
- /*Loopuntiltheendoftransmission*/
- while(USART_GetFlagStatus(EVAL_COM1,USART_FLAG_TC)==RESET)
- {
- }
- returnch;
- }
- /**
- *@}
- */
- /**
- *@}
- */
- /************************(C)COPYRIGHTSTMicroelectronics*****ENDOFFILE****/
该例子就是把COM1作为输出口,把printf的数据打印到该串口上,因此你需要一个串口线与STM32和电脑相连,这样就可以看到printf了。
STM32Keilprintf函 相关文章:
- STM32+Keil 中使用printf函数(11-17)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)