Transmission

所属分类:其他
开发工具:C/C++
文件大小:63KB
下载次数:9
上传日期:2017-09-17 09:12:23
上 传 者Jasonsang0
说明:  stm32F429XX 利用dma模块发送数据到gpio,稍加改动可以实现dma采集gpio程序。
(Stm32F429XX use DMA module to send data to GPIO, a little change, you can achieve DMA acquisition GPIO program)

文件列表:
Transmission\EWARM\Project.ewd (37552, 2016-01-06)
Transmission\EWARM\Project.ewp (30533, 2016-01-06)
Transmission\EWARM\Project.eww (504, 2016-01-06)
Transmission\EWARM\startup_stm32f429xx.s (27766, 2016-01-06)
Transmission\EWARM\stm32f429xx_flash.icf (1592, 2016-01-06)
Transmission\Inc\main.h (8791, 2016-01-06)
Transmission\Inc\stlogo.h (60411, 2016-01-06)
Transmission\Inc\stm32f4xx_hal_conf.h (16158, 2016-01-06)
Transmission\Inc\stm32f4xx_it.h (3258, 2016-01-06)
Transmission\MDK-ARM\Project.uvoptx (21461, 2016-01-06)
Transmission\MDK-ARM\Project.uvprojx (23541, 2016-01-06)
Transmission\MDK-ARM\startup_stm32f429xx.s (31224, 2016-01-06)
Transmission\Src\main.c (26136, 2016-01-06)
Transmission\Src\stm32f4xx_hal_msp.c (8034, 2016-01-06)
Transmission\Src\stm32f4xx_it.c (6510, 2016-01-06)
Transmission\Src\system_stm32f4xx.c (18937, 2016-01-06)
Transmission\SW4STM32\startup_stm32f429xx.s (26298, 2016-01-06)
Transmission\SW4STM32\STM32F429I_DISCO\.cproject (11551, 2016-01-06)
Transmission\SW4STM32\STM32F429I_DISCO\.project (6632, 2016-01-06)
Transmission\SW4STM32\STM32F429I_DISCO\STM32F429ZITx_FLASH.ld (4943, 2016-01-06)
Transmission\SW4STM32\STM32F429I_DISCO (0, 2017-08-13)
Transmission\EWARM (0, 2017-08-13)
Transmission\Inc (0, 2017-08-13)
Transmission\MDK-ARM (0, 2017-08-13)
Transmission\Src (0, 2017-08-13)
Transmission\SW4STM32 (0, 2017-08-13)
Transmission (0, 2017-08-13)

/** @page AN4666 DMA GPIO Parallel Interface Example @verbatim ******************** (C) COPYRIGHT 2015 STMicroelectronics ******************* * @file Transmission/readme.txt * @author MCD Application Team * @version V1.0.0 * @date 06-January-2016 * @brief Description of the Transmission (SDRAM memory to GPIO using DMA) example. ****************************************************************************** * * 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 provides a description of how to generate a parallel data transmission on GPIO with a synchronous clock using a DMA channel to transfer a data buffer from SDRAM external memory connected to STM32F4xx FSMC interface to GPIO and using a Timer to generate a synchronous clock output through the STM32F4xx HAL API. This example can be used together with STM32F429I-Discovery/Reception example on another board to emulate a synchronous parallel transmission through GPIO. A detailed description of the use case can be found in the AN4666 document and should be read before implementing this use case This example is configured to work on STM32F429I-Discovery board, but can be adapted to fit other configurations. All setting parameters are defined as variables in the main.h file and can be tuned in case of porting this code to another device or board. 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 180 MHz. The data to be sent is generated by the random generator IP in the STM32F4xx (RNG) The data is converted to 16bit (because the GPIO is only 16bit wide). - on the STM32F429I-Discovery board example, only PB[11:8] 4 bits will be used for the data transmission, because other PB bits are not available (used for other purposes on the board)so non transmitted bits are set to 0 (on reception side example the received bits will be completed with 0 as well) - also we cannot write on GPIO PB[7:0] because those GPIO are used in parallel to access the SDRAM through FSMC interface... so we have to write on GPIO only with 8bits data transfer So the DMA transfer must be done on 8bits on GPIO side (periph) We can access the SDRAM on 32bits data size, and we shall store 4 data on each SDRAM adress. Handling 8bits data means the frame length must be a multiple of 4 data (because we shall store 4 data at a time in the SDRAM). Then a signature is computed to check correct transmission using the Cyclic Redundancy Check caluculation unit (CRC) embedded in the STM32F4xx. This signature is transmitted as the end of the frame (we send 4 times 8bits) - as for the data the non transmitted bit are set to 0 (on reception side only the transmitted bit GPIO PB[11:8] will be compared) The program then waits for user to press the USER BUTTON. The Timer TIM1 is configured to generate PWM clock pulse at a frequency which is configured in the main.h file. This clock is connected to PA9 (TIM1_CH2). DMA is configured: DMA2/Stream2/Channe6 is linked to TIM1_CH2 output compare (each falling edge of clock) transfer the contents of buffered stored in SDRAM memory to GPIOB. The dma is configured in double buffer mode so that it is possible to read the whole data frame in the SDRAM by increasing the memory address after each dma buffer size is reached. The buffer size (DMA_MEM_BUFF_SIZE) has been set to 100 (so 100x8bit GPIO data sent = 25x32bit SDRAM data read) Timer is started which enables the start of clock generation on PA9 and data transmission on PB[11:8]. The TIM2 (32bits counter) is used to count nb of data transmitted and stop the TIM1 PWN generation once the predefined number of data is reached. To do so the TIM2 is configured as Slave of TIM1. TIM1 TRGO being connected internally to TIM2 input trigger. At the end of the transfer a TIM2 OC interrupt is generated - the TIM1 is stopped AS SOON AS possible to avoid additional clock cycles this is done as the 1st instruction of the TIM2_IRQHandler() depending on the clock output frequency, some additional clock pulse are generated - the nb of data sent and the CRC are showed on the LCD Board's LEDs can be used to monitor the transfer status: - GREEN LED is ON when the transfer is complete (into the Transfer Complete interrupt routine). - RED LED is ON when there is a transfer error (into the Transfer Error interrupt routine). - RED LED is Toggled with a period of 1000 ms when when Error_Handler is called It is possible to adapt to different board by modifying defined values in the file main.h. @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 - Transmission/Src/system_stm32f4xx.c STM32F4xx system clock configuration file - Transmission/Src/stm32f4xx_it.c Interrupt handlers - Transmission/Src/stm32f4xx_hal_msp HAL MSP module - Transmission/Src/main.c Main program - Transmission/Inc/stm32f4xx_hal_conf.h HAL Configuration file - Transmission/Inc/stm32f4xx_it.h Interrupt handlers header file - Transmission/Inc/main.h Main program header file @par Hardware and Software environment - This example runs on STM32F429xx Devices. - This example has been tested with STMicroelectronics STM32F429I-Discovery board and can be easily tailored to any other supported device and development board. @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

*/

近期下载者

相关文件


收藏者