找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1590|回复: 0
收起左侧

STM32F407ZET6串口调试程序

[复制链接]
ID:721429 发表于 2020-4-3 09:13 | 显示全部楼层 |阅读模式
使用到了串口123,并且可以和HC-05蓝牙模块进行通信,发送/接收数据

单片机源程序如下:
  1. /* Includes ------------------------------------------------------------------*/
  2. #include "main.h"
  3. #include "stm32f4xx.h"
  4. #include "USART.h"
  5. #include "usart3.h"

  6. /** @addtogroup Template_Project
  7.   * @{
  8.   */

  9. /* Private typedef -----------------------------------------------------------*/
  10. /* Private define ------------------------------------------------------------*/
  11. /* Private macro -------------------------------------------------------------*/
  12. /* Private variables ---------------------------------------------------------*/
  13. static __IO uint32_t uwTimingDelay;
  14. RCC_ClocksTypeDef RCC_Clocks;

  15. /* Private function prototypes -----------------------------------------------*/
  16. static void Delay(__IO uint32_t nTime);

  17. /* Private functions ---------------------------------------------------------*/

  18. /**
  19.   * @brief  Main program
  20.   * @param  None
  21.   * @retval None
  22.   */
  23. int main(void)
  24. {
  25.   
  26.   char str3[] = "hahahahaha\r\n";
  27.    /*设置Systick为ms级*/
  28.   SysTick_Config(SystemCoreClock/1000-1);
  29.           
  30.    /*设置中断优先级占比*/
  31.   NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
  32.           


  33.     /*配置调试串口*/
  34.    gec_debug(115200);
  35.    usart3_init(9600);

  36.   while (1)
  37.   {       
  38.     usart3_send_string(str3);
  39.                  
  40.   }
  41.    
  42. }

  43. /**
  44.   * @brief  Inserts a delay time.
  45.   * @param  nTime: specifies the delay time length, in milliseconds.
  46.   * @retval None
  47.   */
  48. void Delay(__IO uint32_t nTime)
  49. {
  50.   uwTimingDelay = nTime;

  51.   while(uwTimingDelay != 0);
  52. }

  53. /**
  54.   * @brief  Decrements the TimingDelay variable.
  55.   * @param  None
  56.   * @retval None
  57.   */
  58. void TimingDelay_Decrement(void)
  59. {
  60.   if (uwTimingDelay != 0x00)
  61.   {
  62.     uwTimingDelay--;
  63.   }
  64. }

  65. #ifdef  USE_FULL_ASSERT

  66. /**
  67.   * @brief  Reports the name of the source file and the source line number
  68.   *         where the assert_param error has occurred.
  69.   * @param  file: pointer to the source file name
  70.   * @param  line: assert_param error line source number
  71.   * @retval None
  72.   */
  73. void assert_failed(uint8_t* file, uint32_t line)
  74. {
  75.   /* User can add his own implementation to report the file name and line number,
  76.      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  77.   /* Infinite loop */
  78.   while (1)
  79.   {
  80.   }
  81. }
  82. #endif

  83. /**
  84.   * @}
  85.   */


  86. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
复制代码

所有资料51hei提供下载:
STM32串口调试.7z (94.41 KB, 下载次数: 38)

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表