17726|12

6107

帖子

4

TA的资源

版主

楼主
 

Nucleo心得+“测试-使用-若干集之四 STM32CubeMX+MDK串口通信“ [复制链接]

本帖最后由 damiaa 于 2014-10-5 21:27 编辑

先了解资料



主要关心的文件有    stm32l0xx_hal_uart.c            stm32l0xx_hal_uart.h
                              stm32l0xx_hal_uart_ex.c       stm32l0xx_hal_uart_ex.h


几个主要结构:
typedef struct
{
  __IO uint32_t CR1;    /*!< USART Control register 1,                 Address offset: 0x00 */
  __IO uint32_t CR2;    /*!< USART Control register 2,                 Address offset: 0x04 */
  __IO uint32_t CR3;    /*!< USART Control register 3,                 Address offset: 0x08 */
  __IO uint32_t BRR;    /*!< USART Baud rate register,                 Address offset: 0x0C */  
  __IO uint32_t GTPR;   /*!< USART Guard time and prescaler register,  Address offset: 0x10 */
  __IO uint32_t RTOR;   /*!< USART Receiver Time Out register,         Address offset: 0x14 */  
  __IO uint32_t RQR;    /*!< USART Request register,                   Address offset: 0x18 */
  __IO uint32_t ISR;    /*!< USART Interrupt and status register,      Address offset: 0x1C */
  __IO uint32_t ICR;    /*!< USART Interrupt flag Clear register,      Address offset: 0x20 */
  __IO uint32_t RDR;    /*!< USART Receive Data register,              Address offset: 0x24 */
  __IO uint32_t TDR;    /*!< USART Transmit Data register,             Address offset: 0x28 */
} USART_TypeDef;


typedef struct
{
  uint32_t BaudRate;                  /*!< This member configures the UART communication baud rate.
                                           The baud rate register is computed using the following formula:
                                           - If oversampling is 16 or in LIN mode,
                                              Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate)))
                                           - If oversampling is 8,
                                              Baud Rate Register[15:4] = ((2 * PCLKx) / ((huart->Init.BaudRate)))[15:4]  
                                              Baud Rate Register[3] =  0
                                              Baud Rate Register[2:0] =  (((2 * PCLKx) / ((huart->Init.BaudRate)))[3:0]) >> 1      */

  uint32_t WordLength;                /*!< Specifies the number of data bits transmitted or received in a frame.
                                           This parameter can be a value of @ref UARTEx_Word_Length */

  uint32_t StopBits;                  /*!< Specifies the number of stop bits transmitted.
                                           This parameter can be a value of @ref UART_Stop_Bits */

  uint32_t Parity;                    /*!< Specifies the parity mode.
                                           This parameter can be a value of @ref UART_Parity
                                           @note When parity is enabled, the computed parity is inserted
                                                 at the MSB position of the transmitted data (9th bit when
                                                 the word length is set to 9 data bits; 8th bit when the
                                                 word length is set to 8 data bits). */

  uint32_t Mode;                      /*!< Specifies wether the Receive or Transmit mode is enabled or disabled.
                                           This parameter can be a value of @ref UART_Mode */

  uint32_t HwFlowCtl;                 /*!< Specifies wether the hardware flow control mode is enabled
                                           or disabled.
                                           This parameter can be a value of @ref UART_Hardware_Flow_Control */

  uint32_t OverSampling;              /*!< Specifies wether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to fPCLK/8).
                                           This parameter can be a value of @ref UART_Over_Sampling */  

  uint32_t OneBitSampling;            /*!< Specifies wether a single sample or three samples' majority vote is selected.
                                           Selecting the single sample method increases the receiver tolerance to clock
                                           deviations. This parameter can be a value of @ref UART_OneBit_Sampling */                                                
}UART_InitTypeDef;

/**
  * @brief  UART Advanced Features initalization structure definition  
  */
typedef struct                                      
{
  uint32_t AdvFeatureInit;        /*!< Specifies which advanced UART features is initialized. Several
                                       Advanced Features may be initialized at the same time .
                                       This parameter can be a value of @ref UART_Advanced_Features_Initialization_Type */

  uint32_t TxPinLevelInvert;      /*!< Specifies whether the TX pin active level is inverted.
                                       This parameter can be a value of @ref UART_Tx_Inv  */

  uint32_t RxPinLevelInvert;      /*!< Specifies whether the RX pin active level is inverted.
                                       This parameter can be a value of @ref UART_Rx_Inv  */

  uint32_t DataInvert;            /*!< Specifies whether data are inverted (positive/direct logic
                                       vs negative/inverted logic).
                                       This parameter can be a value of @ref UART_Data_Inv */

  uint32_t Swap;                  /*!< Specifies whether TX and RX pins are swapped.   
                                       This parameter can be a value of @ref UART_Rx_Tx_Swap */

  uint32_t OverrunDisable;        /*!< Specifies whether the reception overrun detection is disabled.   
                                       This parameter can be a value of @ref UART_Overrun_Disable */

  uint32_t DMADisableonRxError;   /*!< Specifies whether the DMA is disabled in case of reception error.     
                                       This parameter can be a value of @ref UART_DMA_Disable_on_Rx_Error */

  uint32_t AutoBaudRateEnable;    /*!< Specifies whether auto Baud rate detection is enabled.     
                                       This parameter can be a value of @ref UART_AutoBaudRate_Enable */  

  uint32_t AutoBaudRateMode;      /*!< If auto Baud rate detection is enabled, specifies how the rate
                                       detection is carried out.     
                                       This parameter can be a value of @ref UARTEx_AutoBaud_Rate_Mode */

  uint32_t MSBFirst;              /*!< Specifies whether MSB is sent first on UART line.      
                                       This parameter can be a value of @ref UART_MSB_First */
} UART_AdvFeatureInitTypeDef;

/**
  * @brief HAL UART State structures definition  
  */
typedef enum
{
  HAL_UART_STATE_RESET             = 0x00,    /*!< Peripheral Reset state                             */
  HAL_UART_STATE_READY             = 0x01,    /*!< Peripheral Initialized and ready for use           */
  HAL_UART_STATE_BUSY              = 0x02,    /*!< an internal process is ongoing                     */
  HAL_UART_STATE_BUSY_TX           = 0x12,    /*!< Data Transmission process is ongoing               */
  HAL_UART_STATE_BUSY_RX           = 0x22,    /*!< Data Reception process is ongoing                  */
  HAL_UART_STATE_BUSY_TX_RX        = 0x32,    /*!< Data Transmission and Reception process is ongoing */
  HAL_UART_STATE_TIMEOUT           = 0x03,    /*!< Timeout state                                      */
  HAL_UART_STATE_ERROR             = 0x04     /*!< Error                                              */
}HAL_UART_StateTypeDef;

/**
  * @brief  HAL UART Error Code structure definition  
  */
typedef enum
{
  HAL_UART_ERROR_NONE      = 0x00,    /*!< No error            */
  HAL_UART_ERROR_PE        = 0x01,    /*!< Parity error        */
  HAL_UART_ERROR_NE        = 0x02,    /*!< Noise error         */
  HAL_UART_ERROR_FE        = 0x04,    /*!< frame error         */
  HAL_UART_ERROR_ORE       = 0x08,    /*!< Overrun error       */
  HAL_UART_ERROR_DMA       = 0x10     /*!< DMA transfer error  */
}HAL_UART_ErrorTypeDef;

/**
  * @brief UART clock sources definition
  */
typedef enum
{
  UART_CLOCKSOURCE_PCLK1      = 0x00,    /*!< PCLK1 clock source  */
  UART_CLOCKSOURCE_PCLK2      = 0x01,    /*!< PCLK2 clock source  */
  UART_CLOCKSOURCE_HSI        = 0x02,    /*!< HSI clock source    */
  UART_CLOCKSOURCE_SYSCLK     = 0x04,    /*!< SYSCLK clock source */
  UART_CLOCKSOURCE_LSE        = 0x08     /*!< LSE clock source     */
}UART_ClockSourceTypeDef;

/**
  * @brief  UART handle Structure definition  
  */  
typedef struct
{
  USART_TypeDef            *Instance;        /* UART registers base address        */

  UART_InitTypeDef         Init;             /* UART communication parameters      */

  UART_AdvFeatureInitTypeDef AdvancedInit;   /* UART Advanced Features initialization parameters */

  uint8_t                  *pTxBuffPtr;      /* Pointer to UART Tx transfer Buffer */

  uint16_t                 TxXferSize;       /* UART Tx Transfer size              */

  uint16_t                 TxXferCount;      /* UART Tx Transfer Counter           */

  uint8_t                  *pRxBuffPtr;      /* Pointer to UART Rx transfer Buffer */

  uint16_t                 RxXferSize;       /* UART Rx Transfer size              */

  uint16_t                 RxXferCount;      /* UART Rx Transfer Counter           */

  uint16_t                 Mask;             /* UART Rx RDR register mask          */

  DMA_HandleTypeDef        *hdmatx;          /* UART Tx DMA Handle parameters      */

  DMA_HandleTypeDef        *hdmarx;          /* UART Rx DMA Handle parameters      */

  HAL_LockTypeDef           Lock;            /* Locking object                     */

  __IO HAL_UART_StateTypeDef    State;       /* UART communication state           */

  __IO HAL_UART_ErrorTypeDef    ErrorCode;   /* UART Error code                    */

}UART_HandleTypeDef;

typedef struct
{
  uint32_t WakeUpEvent;        /*!< Specifies which event will activat the Wakeup from Stop mode flag (WUF).
                                    This parameter can be a value of @ref UART_WakeUp_from_Stop_Selection.
                                    If set to UART_WAKEUP_ON_ADDRESS, the two other fields below must
                                    be filled up. */

  uint16_t AddressLength;      /*!< Specifies whether the address is 4 or 7-bit long.
                                    This parameter can be a value of @ref UARTEx_WakeUp_Address_Length  */

  uint8_t Address;             /*!< UART/USART node address (7-bit long max) */
} UART_WakeUpTypeDef;


UART Firmware driver API description
The following section lists the various functions of the UART library.
43.3.1 Initialization and Configuration functions
This subsection provides a set of functions allowing to initialize the USARTx or the UARTy
in asynchronous mode.
 For the asynchronous mode only these parameters can be configured:
 Baud Rate
 Word Length
 Stop Bit
 Parity: If the parity is enabled, then the MSB bit of the data written in the data
register is transmitted but is changed by the parity bit. Depending on the frame
length defined by the M bit (8-bits or 9-bits).
 Hardware flow control
 Receiver/transmitter modes
 Over Sampling Method
 One-Bit Sampling Method
 For the asynchronous mode, the following advanced features can be configured as
well:
 TX and/or RX pin level inversion
 data logical level inversion
 RX and TX pins swap
 RX overrun detection disabling
 DMA disabling on RX error
 MSB first on communication line
 auto Baud rate detection
The HAL_UART_Init(), HAL_HalfDuplex_Init(), HAL_LIN_Init()and
HAL_MultiProcessorEx_Init()API follow respectively the UART asynchronous, UART Half
duplex, UART LIN mode and UART multiprocessor mode configuration procedures (details
for the procedures are available in reference manual).
 HAL_UART_Init()
 HAL_HalfDuplex_Init()
 HAL_LIN_Init()
 HAL_MultiProcessor_Init()
 HAL_UART_DeInit()
 HAL_UART_MspInit()
 HAL_UART_MspDeInit()
43.3.2 IO operation functions
 HAL_UART_Transmit()
 HAL_UART_Receive()
 HAL_UART_Transmit_IT()
 HAL_UART_Receive_IT()
 HAL_UART_Transmit_DMA()
 HAL_UART_Receive_DMA()
 HAL_UART_DMAPause()
 HAL_UART_DMAResume()
UM1749
DocID026232 Rev 1 633/692
 HAL_UART_DMAStop()
 HAL_UART_IRQHandler()
 HAL_UART_TxCpltCallback()
 HAL_UART_TxHalfCpltCallback()
 HAL_UART_RxCpltCallback()
 HAL_UART_RxHalfCpltCallback()
 HAL_UART_ErrorCallback()
 HAL_UART_WakeupCallback()
43.3.3 Peripheral Control functions
This subsection provides a set of functions allowing to control the UART.
 HAL_MultiProcessor_EnableMuteMode() API enables mute mode
 HAL_MultiProcessor_DisableMuteMode() API disables mute mode
 HAL_MultiProcessor_EnterMuteMode() API enters mute mode
 HAL_HalfDuplex_EnableTransmitter() API enables the transmitter
 HAL_HalfDuplex_EnableReceiver() API enables the receiver
 HAL_UART_GetState() API is helpful to check in run-time the state of the UART
peripheral
 HAL_UART_GetError()API is helpful to check in run-time the error state of the UART
peripheral
 HAL_MultiProcessor_EnableMuteMode()
 HAL_MultiProcessor_DisableMuteMode()
 HAL_MultiProcessor_EnterMuteMode()
 HAL_HalfDuplex_EnableTransmitter()
 HAL_HalfDuplex_EnableReceiver()
 HAL_LIN_SendBreak()
 HAL_UART_GetState()
 HAL_UART_GetError()

UARTEx Firmware driver API description
The following section lists the various functions of the UARTEx library.
44.3.1 Initialization and Configuration functions
The HAL_RS485Ex_Init() API follows respectively the UART RS485 mode configuration
procedures (details for the procedures are available in reference manual).
 HAL_RS485Ex_Init()
44.3.2 Peripheral Control funtions
This section provides functions allowing to:
 UART_AdvFeatureConfig() API optionally configures the UART advanced features
UM1749  658/692 DocID026232 Rev 1
 HAL_MultiProcessorEx_AddressLength_Set() API optionally sets the UART node address detection length to more than 4 bits for multiprocessor                                                                                                       address mark wake up.
 HAL_UARTEx_EnableStopMode() API enables the UART to wake up the MCU from stop mode
 HAL_UARTEx_DisableStopMode() API disables the above functionality
 HAL_UARTEx_EnableClockStopMode() API enables the UART HSI clock during stop mode
 HAL_UARTEx_DisableClockStopMode() API disables the above functionality
 UART_Wakeup_AddressConfig() API configures the wake-up from stop mode parameters
 HAL_UARTEx_EnableStopMode()
 HAL_UARTEx_EnableClockStopMode()
 HAL_UARTEx_DisableStopMode()
 HAL_UARTEx_DisableClockStopMode()
 HAL_UARTEx_StopModeWakeUpSourceConfig()
 HAL_MultiProcessorEx_AddressLength_Set()








此帖出自单片机论坛

最新回复

终于知道原因了,在系统时钟配置好的前提下,当采用轮询方式9600测试串口时候,收到正常,发出丢失;采用轮询2400波特率好了。  详情 回复 发表于 2017-2-15 10:07
点赞 关注
 

回复
举报

51

帖子

0

TA的资源

一粒金砂(中级)

推荐
 
damiaa 发表于 2015-9-12 15:58
当时低速9600以下可以。后来没继续测试。资料也说速率要低。

找到原因了,不是波特率问题,RCC没设置好。谢了
此帖出自单片机论坛

点评

哦 ,那分享分享啊。哈哈。  详情 回复 发表于 2015-9-13 22:07
 
 

回复

6107

帖子

4

TA的资源

版主

沙发
 
本帖最后由 damiaa 于 2014-10-8 17:44 编辑

用STM32CubeMX生成的代码发数据有些数据错误,收收据有时候收不到。不知道为什么。把代码先搞上来。难道说晶体设置的原因?时钟设置选的是MSI RC。确实资料说MSI只能在9600以下 nucleo_uart_mdk512.rar (3.37 MB, 下载次数: 72)

stm32cubel0包里面很多(基本包括了。哈哈)例子:
里面关于串口中断的例子:


修改:main.h里面:
/* User can use this section to tailor USARTx/UARTx instance used and associated
   resources */
/* Definition for USARTx clock resources */
#define USARTx                           USART1
#define USARTx_CLK_ENABLE()              __USART1_CLK_ENABLE();
#define USARTx_RX_GPIO_CLK_ENABLE()      __GPIOA_CLK_ENABLE()
#define USARTx_TX_GPIO_CLK_ENABLE()      __GPIOA_CLK_ENABLE()

#define USARTx_FORCE_RESET()             __USART1_FORCE_RESET()
#define USARTx_RELEASE_RESET()           __USART1_RELEASE_RESET()

/* Definition for USARTx Pins */
#define USARTx_TX_PIN                    GPIO_PIN_9
#define USARTx_TX_GPIO_PORT              GPIOA  
#define USARTx_TX_AF                     GPIO_AF4_USART1
#define USARTx_RX_PIN                    GPIO_PIN_10
#define USARTx_RX_GPIO_PORT              GPIOA
#define USARTx_RX_AF                     GPIO_AF4_USART1


把上面红字的1改为2,把GPIO_PIN_9 改为GPIO_PIN_2          GPIO_PIN_10改为GPIO_PIN_3


注意MAIN.C里面TRANSMITTER_BOARD定义 是定义调试串口输出还是输入的。

stm32cubel0\STM32Cube_FW_L0_V1.1.0\Projects\STM32L053R8-Nucleo\Examples\UART\UART_TwoBoards_ComIT 这个例子改动了下,改为串口2,直接用板上的虚拟串口就可以调试。
stm32cubel0.rar (18.66 MB, 下载次数: 520)












此帖出自单片机论坛

点评

请问乱码问题找到了吗?我试试cubemx导出的uart,测试也乱码  详情 回复 发表于 2015-9-11 22:17
 
 
 

回复

6107

帖子

4

TA的资源

版主

板凳
 
本帖最后由 damiaa 于 2014-10-7 10:29 编辑

上面包的例子中还有UART_TwoBoards_ComPolling例子,在不产生中断的时候收发串口数据,串口的改动和上面一样。
发送直接从串口调试助手看到,如果看接受数据可以在159行 BSP_LED_On(LED2);那里设置断点看。也可以自己改改看。

如果想串口中用DMA传输就用UART_TwoBoards_ComDMA这个例子。串口的改动和上面一样。

此帖出自单片机论坛
 
 
 

回复

6107

帖子

4

TA的资源

版主

4
 
看看例子中这一段,主要概要的说明了使用方法。
==============================
=================================================
                        ##### How to use this driver #####
===============================================================================
  [..]
    The UART HAL driver can be used as follows:
   
    (#) Declare a UART_HandleTypeDef handle structure.
  
    (#) Initialize the UART low level resources by implementing the HAL_UART_MspInit() API:
        (##) Enable the USARTx interface clock.
        (##) UART pins configuration:
            (+++) Enable the clock for the UART GPIOs.
            (+++) Configure these UART pins as alternate function pull-up.
        (##) NVIC configuration if you need to use interrupt process (HAL_UART_Transmit_IT()
             and HAL_UART_Receive_IT() APIs):
            (+++) Configure the USARTx interrupt priority.
            (+++) Enable the NVIC USART IRQ handle.

        (##) DMA Configuration if you need to use DMA process (HAL_UART_Transmit_DMA()
             and HAL_UART_Receive_DMA() APIs):
            (+++) Declare a DMA handle structure for the Tx/Rx stream.
            (+++) Enable the DMAx interface clock.
            (+++) Configure the declared DMA handle structure with the required
                  Tx/Rx parameters.               
            (+++) Configure the DMA Tx/Rx Stream.
            (+++) Associate the initialized DMA handle to the UART DMA Tx/Rx handle.
            (+++) Configure the priority and enable the NVIC for the transfer complete
                  interrupt on the DMA Tx/Rx Stream.

    (#) Program the Baud Rate, Word Length, Stop Bit, Parity, Hardware
        flow control and Mode(Receiver/Transmitter) in the Init structure.

    (#) For the UART asynchronous mode, initialize the UART registers by calling
        the HAL_UART_Init() API.

    (#) For the UART Half duplex mode, initialize the UART registers by calling
        the HAL_HalfDuplex_Init() API.

    (#) For the LIN mode, initialize the UART registers by calling the HAL_LIN_Init() API.

    (#) For the Multi-Processor mode, initialize the UART registers by calling
        the HAL_MultiProcessor_Init() API.

     [..]
       (@) The specific UART interrupts (Transmission complete interrupt,
            RXNE interrupt and Error Interrupts) will be managed using the macros
            __HAL_UART_ENABLE_IT() and __HAL_UART_DISABLE_IT() inside the transmit
            and receive process.

     [..]
       (@) These APIs (HAL_UART_Init() and HAL_HalfDuplex_Init()) configure also the
            low level Hardware GPIO, CLOCK, CORTEX...etc) by calling the customed
            HAL_UART_MspInit() API.

     [..]
        Three operation modes are available within this driver :

     *** Polling mode IO operation ***
     =================================
     [..]   
       (+) Send an amount of data in blocking mode using HAL_UART_Transmit()
       (+) Receive an amount of data in blocking mode using HAL_UART_Receive()
      
     *** Interrupt mode IO operation ***
     ===================================
     [..]
       (+) Send an amount of data in non blocking mode using HAL_UART_Transmit_IT()
       (+) At transmission end of half transfer HAL_UART_TxHalfCpltCallback is executed and user can
            add his own code by customization of function pointer HAL_UART_TxHalfCpltCallback
       (+) At transmission end of transfer HAL_UART_TxCpltCallback is executed and user can
            add his own code by customization of function pointer HAL_UART_TxCpltCallback
       (+) Receive an amount of data in non blocking mode using HAL_UART_Receive_IT()
       (+) At reception end of half transfer HAL_UART_RxHalfCpltCallback is executed and user can
            add his own code by customization of function pointer HAL_UART_RxHalfCpltCallback
       (+) At reception end of transfer HAL_UART_RxCpltCallback is executed and user can
            add his own code by customization of function pointer HAL_UART_RxCpltCallback
       (+) In case of transfer Error, HAL_UART_ErrorCallback() function is executed and user can
            add his own code by customization of function pointer HAL_UART_ErrorCallback

     *** DMA mode IO operation ***
     ==============================
     [..]
       (+) Send an amount of data in non blocking mode (DMA) using HAL_UART_Transmit_DMA()
       (+) At transmission end of half transfer HAL_UART_TxHalfCpltCallback is executed and user can
            add his own code by customization of function pointer HAL_UART_TxHalfCpltCallback
       (+) At transmission end of transfer HAL_UART_TxCpltCallback is executed and user can
            add his own code by customization of function pointer HAL_UART_TxCpltCallback
       (+) Receive an amount of data in non blocking mode (DMA) using HAL_UART_Receive_DMA()
       (+) At reception end of half transfer HAL_UART_RxHalfCpltCallback is executed and user can
            add his own code by customization of function pointer HAL_UART_RxHalfCpltCallback
       (+) At reception end of transfer HAL_UART_RxCpltCallback is executed and user can
            add his own code by customization of function pointer HAL_UART_RxCpltCallback
       (+) In case of transfer Error, HAL_UART_ErrorCallback() function is executed and user can
            add his own code by customization of function pointer HAL_UART_ErrorCallback
       (+) Pause the DMA Transfer using HAL_UART_DMAPause()
       (+) Resume the DMA Transfer using HAL_UART_DMAResume()
       (+) Stop the DMA Transfer using HAL_UART_DMAStop()

     *** UART HAL driver macros list ***
     =============================================
     [..]
       Below the list of most used macros in UART HAL driver.

      (+) __HAL_UART_ENABLE: Enable the UART peripheral
      (+) __HAL_UART_DISABLE: Disable the UART peripheral
      (+) __HAL_UART_GET_FLAG : Check whether the specified UART flag is set or not
      (+) __HAL_UART_CLEAR_FLAG : Clear the specified UART pending flag
      (+) __HAL_UART_ENABLE_IT: Enable the specified UART interrupt
      (+) __HAL_UART_DISABLE_IT: Disable the specified UART interrupt

     [..]
       (@) You can refer to the UART HAL driver header file for more useful macros
此帖出自单片机论坛
 
 
 

回复

6107

帖子

4

TA的资源

版主

5
 
在看看上面文件包里面的这个链接file:///E:/stm32Nucle/stm32cubel0/STM32Cube_FW_L0_V1.1.0/Release_Notes.html 感觉有些帮助。
此帖出自单片机论坛
 
 
 

回复

57

帖子

0

TA的资源

一粒金砂(中级)

6
 
久旱逢甘霖呀,谢谢O(∩_∩)O~~
此帖出自单片机论坛
 
 
 

回复

51

帖子

0

TA的资源

一粒金砂(中级)

7
 
damiaa 发表于 2014-10-7 09:43
用STM32CubeMX生成的代码发数据有些数据错误,收收据有时候收不到。不知道为什么。把代码先搞上来。难道说 ...

请问乱码问题找到了吗?我试试cubemx导出的uart,测试也乱码
此帖出自单片机论坛

点评

当时低速9600以下可以。后来没继续测试。资料也说速率要低。  详情 回复 发表于 2015-9-12 15:58
 
 
 

回复

6107

帖子

4

TA的资源

版主

8
 
arthasarthas 发表于 2015-9-11 22:17
请问乱码问题找到了吗?我试试cubemx导出的uart,测试也乱码

当时低速9600以下可以。后来没继续测试。资料也说速率要低。
此帖出自单片机论坛

点评

找到原因了,不是波特率问题,RCC没设置好。谢了  详情 回复 发表于 2015-9-12 17:45
 
 
 

回复

6107

帖子

4

TA的资源

版主

10
 
arthasarthas 发表于 2015-9-12 17:45
找到原因了,不是波特率问题,RCC没设置好。谢了

哦 ,那分享分享啊。哈哈。
此帖出自单片机论坛

点评

应该用至少HSI16晶振我用的MSI的,速度太慢,波特率误码率太高。  详情 回复 发表于 2015-9-16 11:58
 
 
 

回复

14

帖子

0

TA的资源

一粒金砂(初级)

11
 
哇哦,好多资料哦
此帖出自单片机论坛
 
 
 

回复

51

帖子

0

TA的资源

一粒金砂(中级)

12
 
damiaa 发表于 2015-9-13 22:07
哦 ,那分享分享啊。哈哈。

应该用至少HSI16晶振我用的MSI的,速度太慢,波特率误码率太高。
此帖出自单片机论坛

赞赏

1

查看全部赞赏

 
 
 

回复

5

帖子

0

TA的资源

一粒金砂(初级)

13
 
终于知道原因了,在系统时钟配置好的前提下,当采用轮询方式9600测试串口时候,收到正常,发出丢失;采用轮询2400波特率好了。
此帖出自单片机论坛
 
 
 

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

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/6 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表