久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 5469|回復(fù): 4
打印 上一主題 下一主題
收起左側(cè)

基于STM32f103C8T6的485通訊參考源碼有問題 求幫助

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:398895 發(fā)表于 2018-9-17 10:17 | 只看該作者 回帖獎勵 |倒序?yàn)g覽 |閱讀模式
1、該例程為RS485例程。

2、使用說明
   (1)工程文件路徑:例程目錄\RS485\MDK-ARM\Project.uvproj。
   (2)請使用MDK 4.0以上版本打開,MDK版本過低會導(dǎo)致無法識別工程。
   (3)下載調(diào)試工具為ULINK。
   (4)請將RS485A、RS485B連接RS485轉(zhuǎn)RS232,并打開超級終端或串口助手,配置波特率115200,8位,一個停止位,無校驗(yàn)位。
   (5)HEX文件下載到板子后,使用超級終端或串口調(diào)試助手可以看到調(diào)試信息,表明例程運(yùn)行正確。

3、注意事項(xiàng)
   請務(wù)必在下載、調(diào)試、運(yùn)行過程中,保持板子上電、ULINK連接并插在電腦上。

單片機(jī)源程序如下:
  1. /****************************************Copyright (c)****************************************************
  2. **--------------File Info---------------------------------------------------------------------------------
  3. ** File name:               main.c
  4. ** Descriptions:            The RS485 application function
  5. **
  6. **--------------------------------------------------------------------------------------------------------
  7. ** Created by:              AVRman
  8. ** Created date:            2010-10-30
  9. ** Version:                 v1.0
  10. ** Descriptions:            The original version
  11. **
  12. **--------------------------------------------------------------------------------------------------------
  13. ** Modified by:            
  14. ** Modified date:           
  15. ** Version:                 
  16. ** Descriptions:            
  17. **
  18. *********************************************************************************************************/

  19. /* Includes ------------------------------------------------------------------*/
  20. #include "stm32f10x.h"
  21. #include <stdio.h>

  22. #ifdef __GNUC__
  23.   /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
  24.      set to 'Yes') calls __io_putchar() */
  25.   #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
  26. #else
  27.   #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
  28. #endif /* __GNUC__ */

  29. #define DIR485_Receive()    GPIO_ResetBits(GPIOB,GPIO_Pin_2)
  30. #define DIR485_Send()       GPIO_SetBits(GPIOB,GPIO_Pin_2)

  31. /* Private function prototypes -----------------------------------------------*/
  32. void USART_Configuration(void);


  33. /*******************************************************************************
  34. * Function Name  : Delay
  35. * Description    : Delay Time
  36. * Input          : - nCount: Delay Time
  37. * Output         : None
  38. * Return         : None
  39. * Attention                 : None
  40. *******************************************************************************/
  41. void  Delay (uint32_t nCount)
  42. {
  43.   for(; nCount != 0; nCount--);
  44. }

  45. /*******************************************************************************
  46. * Function Name  : main
  47. * Description    : Main program
  48. * Input          : None
  49. * Output         : None
  50. * Return         : None
  51. * Attention                 : None
  52. *******************************************************************************/
  53. int main(void)
  54. {
  55.     uint8_t ch;
  56.         USART_Configuration();
  57.     printf("*****************************************************************\r\n");
  58.     printf("*                                                               *\r\n");
  59.     printf("*  Thank you for using HY-RedBull V3.0 Development Board ! ^_^  *\r\n");
  60.     printf("*                                                               *\r\n");
  61.     printf("*****************************************************************\r\n");
  62.            printf("\r\nPlease input any word :\r\n");
  63.     /* Infinite loop */
  64.     while (1){
  65.                 /* Loop until RXNE = 1 */
  66.         while (USART_GetFlagStatus(USART3, USART_FLAG_RXNE) == RESET);
  67.                 ch = USART_ReceiveData(USART3);
  68.                 Delay(10000);
  69.                 printf("%c",ch);  
  70.     }
  71. }

  72. /*******************************************************************************
  73. * Function Name  : USART_Configuration
  74. * Description    : Configure USART3
  75. * Input          : None
  76. * Output         : None
  77. * Return         : None
  78. * Attention                 : None
  79. *******************************************************************************/
  80. void USART_Configuration(void)
  81. {
  82.   GPIO_InitTypeDef GPIO_InitStructure;
  83.   USART_InitTypeDef USART_InitStructure;

  84.   RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB , ENABLE);
  85.   RCC_APB1PeriphClockCmd( RCC_APB1Periph_USART3 , ENABLE);
  86.         
  87.   /*
  88.   *  USART3_TX -> PB10 , USART3_RX -> PB11 , 485_DIR -> PB2
  89.   */                                
  90.   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;                 
  91.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  92.   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  93.   GPIO_Init(GPIOB, &GPIO_InitStructure);        
  94.             
  95.   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;                 
  96.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  97.   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  98.   GPIO_Init(GPIOB, &GPIO_InitStructure);                  

  99.   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;               
  100.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;  
  101.   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  102.   GPIO_Init(GPIOB, &GPIO_InitStructure);

  103.   USART_InitStructure.USART_BaudRate = 115200;
  104.   USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  105.   USART_InitStructure.USART_StopBits = USART_StopBits_1;
  106.   USART_InitStructure.USART_Parity = USART_Parity_No;
  107.   USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  108.   USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

  109.   USART_Init(USART3, &USART_InitStructure);
  110.   USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
  111.   USART_ClearFlag(USART3,USART_FLAG_TC);
  112.   USART_Cmd(USART3, ENABLE);
  113. }

  114. /**
  115.   * @brief  Retargets the C library printf function to the USART.
  116.   * @param  None
  117.   * @retval None
  118.   */
  119. PUTCHAR_PROTOTYPE
  120. {
  121.   DIR485_Send();

  122.   /* Place your implementation of fputc here */
  123.   /* e.g. write a character to the USART */
  124.   USART_SendData(USART3, (uint8_t) ch);

  125.   /* Loop until the end of transmission */
  126.   while (USART_GetFlagStatus(USART3, USART_FLAG_TC) == RESET)
  127.   {}

  128.   DIR485_Receive();

  129.   return ch;
  130. }

  131. #ifdef  USE_FULL_ASSERT

  132. /**
  133.   * @brief  Reports the name of the source file and the source line number
  134. ……………………

  135. …………限于本文篇幅 余下代碼請從51黑下載附件…………
復(fù)制代碼

所有資料51hei提供下載:
RS485.rar (336.45 KB, 下載次數(shù): 141)




分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏3 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

沙發(fā)
ID:578440 發(fā)表于 2019-7-5 13:54 | 只看該作者
程序不能用
回復(fù)

使用道具 舉報

板凳
ID:427398 發(fā)表于 2019-10-19 17:53 | 只看該作者
有原理圖 嗎?
回復(fù)

使用道具 舉報

地板
ID:668292 發(fā)表于 2019-12-19 13:56 | 只看該作者
不知道行不行  先看看
回復(fù)

使用道具 舉報

5#
ID:592010 發(fā)表于 2021-6-6 17:10 | 只看該作者
不能用,已驗(yàn)證!
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 亚洲综合在线视频 | 视频一区二区三区中文字幕 | 欧美寡妇偷汉性猛交 | 亚洲精品中文字幕 | av黄色国产| 精品视频在线一区 | www.色婷婷 | 浴室洗澡偷拍一区二区 | 日韩精品一区二区三区免费视频 | 在线一区二区三区 | 亚洲精品中文字幕中文字幕 | 一区二区伦理电影 | 亚洲国产精品久久久 | 精久久久| 亚洲成人毛片 | 91 在线| 日韩欧美一区二区三区四区 | av在线播放免费 | 国产免费一区二区三区免费视频 | 91观看| 手机av免费在线 | 欧洲尺码日本国产精品 | 欧美精品一二三区 | 欧美性tv | 国产女人精品视频 | 日韩久久综合网 | 亚洲国产精品久久久久久 | 91高清在线观看 | 日本三级电影在线看 | 精品婷婷 | a毛片| 免费国产一区二区 | 久久久青草婷婷精品综合日韩 | 日本天天操 | 亚洲一区二区在线视频 | 免费国产一区二区视频 | 国产精品一区一区 | 欧美aⅴ | 欧美国产精品一区二区三区 | 国产激情91久久精品导航 | 久草热8精品视频在线观看 午夜伦4480yy私人影院 |