STM32VL-Discovery.zip

  • heroistired
    了解作者
  • C/C++
    开发工具
  • 731KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2020-02-26 19:41
    上传日期
STM32VL-Discovery 的LL 和HAL例程
STM32VL-Discovery.zip
内容介绍
/** @page SPI_FullDuplex_ComPolling SPI Full Duplex Polling example @verbatim ******************** (C) COPYRIGHT 2016 STMicroelectronics ******************* * @file SPI/SPI_FullDuplex_ComPolling/readme.txt * @author MCD Application Team * @brief Description of the SPI Full Duplex Polling example. ****************************************************************************** * @attention * * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * All rights reserved.</center></h2> * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** @endverbatim @par Example Description Data buffer transmission/reception between two boards via SPI using Polling mode. _________________________ _________________________ | ______________| |______________ | | |SPI1 | | SPI1| | | | | | | | | | CLK(PA5)|______________________|(PA5)CLK | | | | | | | | | | MISO(PA6)|______________________|(PA6)MISO | | | | | | | | | | MOSI(PA7)|______________________|(PA7)MOSI | | | | | | | | | |______________| |______________| | | __ | | | | |__| | | | | USER | | | | GND|______________________|GND | | | | | |_STM32F1 Master _________| |_STM32F1 Slave __________| HAL architecture allows user to easily change code to move to IT or DMA mode. To see others communication modes please check following examples: SPI\SPI_FullDuplex_ComDMA SPI\SPI_FullDuplex_ComIT 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 24 MHz. The SPI peripheral configuration is ensured by the HAL_SPI_Init() function. This later is calling the HAL_SPI_MspInit()function which core is implementing the configuration of the needed SPI resources according to the used hardware (CLOCK & GPIO). You may update this function to change SPI configuration. The SPI communication is then initiated. The HAL_SPI_TransmitReceive() function allows the reception and the transmission of a predefined data buffer at the same time (Full Duplex Mode) The user can choose between Master and Slave through "#define MASTER_BOARD" in the "main.c" file. If the Master board is used, the "#define MASTER_BOARD" must be uncommented. If the Slave board is used the "#define MASTER_BOARD" must be commented. For this example the aTxBuffer is predefined and the aRxBuffer size is same as aTxBuffer. In a first step after the user press the User push-button, SPI Master starts the communication by sending aTxBuffer and receiving aRxBuffer through HAL_SPI_TransmitReceive(), at the same time SPI Slave transmits aTxBuffer and receives aRxBuffer through HAL_SPI_TransmitReceive(). The end of this step is monitored through the HAL_SPI_GetState() function result. Finally, aRxBuffer and aTxBuffer are compared through Buffercmp() in order to check buffers correctness. STM32 board's LEDs can be used to monitor the transfer status: - LED3 toggles quicly on master board waiting user button to be pressed. - LED3 turns ON if transmission/reception is complete and OK. - LED4 turns ON when there is an error in transmission/reception process. - LED4 toggle when there is a timeout error in transmission/reception process. @note SPIx instance used and associated resources can be updated in "main.h" file depending hardware configuration used. @note Timeout is set to 5 Seconds which means that if no communication occurs during 5 Seconds, a Timeout Error will be generated. @note You need to perform a reset on Master board, then perform it on Slave board, then press the User button on Master board to have the correct behaviour of this example. @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 - SPI/SPI_FullDuplex_ComPolling/Inc/stm32f1xx_hal_conf.h HAL configuration file - SPI/SPI_FullDuplex_ComPolling/Inc/stm32f1xx_it.h SPI interrupt handlers header file - SPI/SPI_FullDuplex_ComPolling/Inc/main.h Header for main.c module - SPI/SPI_FullDuplex_ComPolling/Src/stm32f1xx_it.c SPI interrupt handlers - SPI/SPI_FullDuplex_ComPolling/Src/main.c Main program - SPI/SPI_FullDuplex_ComPolling/Src/system_stm32f1xx.c STM32F1xx system source file - SPI/SPI_FullDuplex_ComPolling/Src/stm32f1xx_hal_msp.c HAL MSP file @par Hardware and Software environment - This example runs on STM32F100xB devices. - This example has been tested with STM32VL-Discovery board and can be easily tailored to any other supported device and development board. - STM32VL-Discovery Set-up - Connect Master board PA5 to Slave Board PA5 - Connect Master board PA6 to Slave Board PA6 - Connect Master board PA7 to Slave Board PA7 - Connect Master board GND to Slave Board GND @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 o Uncomment "#define MASTER_BOARD" and load the project in Master Board o Comment "#define MASTER_BOARD" and load the project in Slave Board - Run the example * <h3><center>&copy; COPYRIGHT STMicroelectronics</center></h3> */
评论
    相关推荐
    • STM32 程序
      STM32一些自己写过的程序并应用过可以使用的,包括直流电机驱动,温度显示,oled显示,adc实验,PWM输出,定时器中断,全部都写在了main函数中,不过写的有一点乱。(pwm实验可以看我的博客)
    • stm32系列资料
      STM32F103ZET6开发板提供了丰富的软件资源,一共有150多个例程,分为初级、 中级和高级三个部分,可以全面满足用户的需求。 ■ 初级部分:提供80个试验例程 ■ 中级部分:提供40个试验例程 涉及到STM32的很多方面,...
    • stm32 定时器
      stm32定时器定时周期采集测距传感器采集的距离的值,并通过显示屏显示
    • stm32codegen
      stm32codegen
    • STM32系列资料
      STM32系列资料(PPT课件):开发板使用入门、STM32学习方法、开发板资源描述-M3、STM32初探-M3、STM32芯片解读-M3、开发环境搭建、ISP串口下载.、JLINK程序下载、新建基于固件库的工程模板-M3、新建基于寄存器的工程...
    • Weatherclock_stm32
      Weatherclock_stm32 项目说明 本项目为智能天气语音闹钟,采用STM32f103硬件平台。 历史 2018.6.14 project工程采用keil,后续将逐步改用sw4stm32进行开发 SW4_project工程目前已完成大部分的移植,已实现keil工程中...
    • STM32CubeMX
      ST(意法半导体)公司为方便STM32的使用和学习,以及HAL库的推广,自行研发的可以通过配置,自动生成初始化代码的工具软件
    • STM32 JoyStickMouse
      今天终于把 STM32 的例程 JoyStickMouse 跑起来了,上传一份备忘。 注意要根据 stm32f10x_conf.h 中的注释去掉一些没用到的文件
    • STM32CubeMX
      STM32CubeMX STM32Cube initialization code generator (UM1718)
    • stm32 demo
      stm32demo 内置adc采集 使用oled及串口显示,可以用于小型项目的demo。 及课程设计。