UART

所属分类:单片机开发
开发工具:WINDOWS
文件大小:18417KB
下载次数:4
上传日期:2017-08-25 11:49:49
上 传 者啦哈拉卅
说明:  基于STM32L452RET6的UART例程函数
(UART routine function based on STM32L452RET6)

文件列表:
UART (0, 2017-07-03)
UART\UART_TwoBoards_ComDMA (0, 2017-07-13)
UART\UART_TwoBoards_ComDMA\EWARM (0, 2017-07-03)
UART\UART_TwoBoards_ComDMA\EWARM\Project.ewd (43407, 2017-04-21)
UART\UART_TwoBoards_ComDMA\EWARM\Project.ewp (29249, 2017-04-21)
UART\UART_TwoBoards_ComDMA\EWARM\Project.eww (161, 2017-04-21)
UART\UART_TwoBoards_ComDMA\EWARM\startup_stm32l452xx.s (21181, 2017-04-21)
UART\UART_TwoBoards_ComDMA\EWARM\stm32l452xx_flash.icf (1646, 2017-04-21)
UART\UART_TwoBoards_ComDMA\Inc (0, 2017-07-03)
UART\UART_TwoBoards_ComDMA\Inc\main.h (4807, 2017-04-21)
UART\UART_TwoBoards_ComDMA\Inc\stm32l4xx_hal_conf.h (13418, 2017-04-21)
UART\UART_TwoBoards_ComDMA\Inc\stm32l4xx_it.h (3286, 2017-04-21)
UART\UART_TwoBoards_ComDMA\MDK-ARM (0, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\Project.uvguix.min (87924, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\Project.uvoptx (13212, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\Project.uvprojx (18587, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\RTE (0, 2017-07-12)
UART\UART_TwoBoards_ComDMA\MDK-ARM\RTE\RTE_Components.h (357, 2017-07-12)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO (0, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\Project_STM32L452RE_NUCLEO.dep (49249, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\STM32L452RE_NUCLEO.axf (803044, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\STM32L452RE_NUCLEO.build_log.htm (2578, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\STM32L452RE_NUCLEO.htm (63765, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\STM32L452RE_NUCLEO.lnp (1013, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\STM32L452RE_NUCLEO.map (101207, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\STM32L452RE_NUCLEO.sct (479, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\main.crf (800685, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\main.d (2891, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\main.o (916820, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\startup_stm32l452xx.d (65, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\startup_stm32l452xx.o (7336, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\stm32l4xx_hal.crf (797109, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\stm32l4xx_hal.d (3069, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\stm32l4xx_hal.o (949044, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\stm32l4xx_hal_cortex.crf (795482, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\stm32l4xx_hal_cortex.d (3279, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\stm32l4xx_hal_cortex.o (928156, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\stm32l4xx_hal_dma.crf (800717, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\stm32l4xx_hal_dma.d (3189, 2017-07-13)
UART\UART_TwoBoards_ComDMA\MDK-ARM\STM32L452RE_NUCLEO\stm32l4xx_hal_dma.o (922852, 2017-07-13)
... ...

/** @page UART_WakeUpFromStop UART Wake up from Stop mode example @verbatim ******************** (C) COPYRIGHT 2016 STMicroelectronics ******************* * @file UART/UART_WakeUpFromStop/readme.txt * @author MCD Application Team * @version V1.8.0 * @date 21-April-2017 * @brief Description of the UART-triggered MCU wake-up from STOP1 mode. ****************************************************************************** * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** @endverbatim @par Example Description This example shows how to configure an UART to wake up the MCU from STOP1 mode when a given stimulus is received. Board: STM32L452RE-Nucleo Rev C (embeds a STM32L452RET6 device) Tx Pin: PC.10 (pin 1 on CN7) Rx Pin: PC.11 (pin 2 on CN7) _________________________ _________________________ | ______________| |______________ | | |USART | | USART| | | | | | | | | | TX |_____________________| RX | | | | | | | | | | | | | | | | | | | | | | RX |_____________________| TX | | | | | | | | | |______________| |______________| | | | | | | | | | | STM32 Board 1 | | STM32 Board 2 | | (follows a sequence of | | (sends stimuli to wake | | RUN/STOP modes) | | up STM32 Board 1) | |_________________________| |_________________________| Board 1 enters STOP1 mode and is awoken by Board 2 which sends the proper data to wake up the board 1 MCU. When the proper wake-up event is recognized, the WUF interrupt is triggered which wakes up board 1. To confirm its wake up, board 1 sends a confirmation message to board 2 which checks it is the expected message. This cycle is repeated 4 times to verify 4 different events 1°) wake-up by RXNE flag rising 2°) wake-up by Start Bit detection 3°) wake-up by 7-bit long address match 4°) wake-up by 4-bit long address match WARNING: as both boards do not behave the same way, "BOARD_IN_STOP1_MODE" compilation switch is defined in UART/UART_WakeUpFromStop/Src/main.c and must be enabled at compilation time before loading the executable in board 1 (that which is set in STOP1 mode). The stimuli-transmitting board (board 2) needs to be loaded with an executable software obtained with BOARD_IN_STOP1_MODE disabled. At the very beginning, board 1 LED2 is ON then is turned off. This means that board 1 has entered STOP1 mode. Parallely, board 2 LED2 is quickly blinking (100 ms period). The user has just to wait for board 1 LED2 to be turned off then to press board 2 User push-button to send the first wake-up stimulus to board 1. This starts the test sequence and no more action is required from the user (a single User push-button press is needed to start the full 4 wake-up events test sequence). Board 1 LED2 behavior as described below allows to follow the test progress: ON ____ _______ _______ _______ ____ | | | | | | | | OFF |________| |________| |________| |________| Enter Exit Enter Exit Enter Exit Enter Exit Stop Stop Stop Stop Stop Stop Stop Stop Mode Mode Mode Mode Mode Mode Mode Mode (RXNE flag) (Start Bit (7-bit add. (4-bit add. Detection) match) match) Simultaneously, board 2 LED2 behavior shown below allows to follow the test progress on the other side: BLINKING ON ****________ _______ _______ _______ ____ | | | | | | | | OFF |________| |________| |________| |________| USER WkUp 2nd stim WkUp 3rd stim WkUp 4th stim WkUp LED ON button conf sent conf sent conf sent conf to mark pushed, rcv'ed rcv'ed rcv'ed rcv'ed passed 1st stimulus test sent (RXNE flag) (Start Bit (7-bit add. (4-bit add. Detection) match) match) - If the test fails or if there is an initialization or transfer error, LED2 transmits a sequence of three dots, three dashes, three dots. At the beginning of the main program the HAL_Init() function is called to reset all the peripherals, initialize the Flash interface and the systick. Then the SystemClock_Config() function is used to configure the system clock (SYSCLK) to run at 80 MHz with MSI as source of main PLL. Additionally the HSI is enabled to demonstrate USART wake-up capabilities. Each time board 1 is awoken, the system clock (SYSCLK) at 80 MHz is restored. The UART is configured as follows: - BaudRate = 9600 baud - Word Length = 8 bits (8 data bits, no parity bit) - One Stop Bit - Parity none - Hardware flow control disabled (RTS and CTS signals) @note USARTx/UARTx instance used and associated resources can be updated in "main.h" file depending hardware configuration used. @note This example can not be used in DEBUG mode due to the fact that the Cortex-M4 core is no longer clocked during low power mode and so debugging features are not available. @note Care must be taken when using HAL_Delay(), this function provides accurate delay (in milliseconds) based on variable incremented in SysTick ISR. This implies that if HAL_Delay() is called from a peripheral ISR process, then the SysTick interrupt must have higher priority (numerically lower) than the peripheral interrupt. Otherwise the caller ISR process will be blocked. To change the SysTick interrupt priority you have to use HAL_NVIC_SetPriority() function. @note The application need to ensure that the SysTick time base is always set to 1 millisecond to have correct HAL operation. @par Directory contents - UART/UART_WakeUpFromStop/Inc/stm32l4xx_hal_conf.h HAL configuration file - UART/UART_WakeUpFromStop/Inc/stm32l4xx_it.h Interrupt handlers header file - UART/UART_WakeUpFromStop/Inc/main.h Header for main.c module - UART/UART_WakeUpFromStop/Src/stm32l4xx_it.c Interrupt handlers - UART/UART_WakeUpFromStop/Src/main.c Main program - UART/UART_WakeUpFromStop/Src/stm32l4xx_hal_msp.c HAL MSP module - UART/UART_WakeUpFromStop/Src/system_stm32l4xx.c STM32L4xx system source file @par Hardware and Software environment - This example runs on STM32L452xx devices. - This example has been tested with a couple of STM32L452RE-Nucleo Rev C boards embedding a STM32L452RET6 device and can be easily tailored to any other supported device and development board. - STM32L452RE-Nucleo Rev C set-up - Connect a wire between 1st board PC.10 (pin 1 on CN7) pin (UART4 Tx) and 2nd board PC.11 (pin 2 on CN7) pin (UART4 Rx) - Connect a wire between 1st board PC.11 (pin 2 on CN7) pin (UART4 Rx) and 2nd board PC.10 (pin 1 on CN7) pin (UART4 Tx) @par How to use it ? In order to make the program work, you must do the following : - Open your preferred toolchain - Rebuild all files and load your image into target memory - Run the example *

© COPYRIGHT STMicroelectronics

*/

近期下载者

相关文件


收藏者