stm32分模块编程学习important

上传人:gbs****77 文档编号:10554070 上传时间:2020-04-12 格式:DOC 页数:140 大小:609.50KB
返回 下载 相关 举报
stm32分模块编程学习important_第1页
第1页 / 共140页
stm32分模块编程学习important_第2页
第2页 / 共140页
stm32分模块编程学习important_第3页
第3页 / 共140页
点击查看更多>>
资源描述
启动函数中有各个中 断处理函数名称 startup stm32f40 41xx x s system stm32f4xx c 系统初始化函数 SystemInit 配置系统时钟 系统内核变量 SystemCoreClock variable 改变系统时钟 SystemCoreClockUpdate 配置好的是 168M Sysclock Hclk 168000000 AHB Prescaler 1 APB1 Prescaler 4 APB2 Prescaler 2 if defined STM32F40 41xxx uint32 t SystemCoreClock 168000000 在这里设置系统的时钟 endif STM32F40 41xxx 配置系统时钟 PLL 分频比 AHB APBx 分频比 flash 设置 static void SetSysClock void 每次 hclk 改变后必须调用这个来更新系统时钟 void SystemCoreClockUpdate void typedef enum Bit RESET 0 Bit SET BitAction 枚举类型 为数定义一个别名 这样好区分 引用的时候好引用 枚举型是预处理 指令 define 的替代 一 结束 一般的定义方式如下 enum enum type name ENUM CONST 1 ENUM CONST 2 ENUM CONST n enum variable name 注意 enum type name 是自定义的一种数据数据类型名 而 enum variable name 为 enum type name 类型的一个变量 也就是我们平时常说的枚举变量 实际上 enum type name 类 型是对一个变量取值范围的限定 而花括号内是它的取值范围 即 enum type name 类型的变量 enum variable name 只能取值为花括号内的任何一个值 如果赋给该类型变量的值不在列表中 则 会报错或者警告 ENUM CONST 1 ENUM CONST 2 ENUM CONST n 这些成员都是常量 也就是我们平时所说的枚举常量 常量一般用大写 例如 typedef enum GPIO Mode IN 0 x00 GPIO Input Mode GPIO Mode OUT 0 x01 GPIO Output Mode GPIO Mode AF 0 x02 GPIO Alternate function Mode GPIO Mode AN 0 x03 GPIO Analog Mode GPIOMode TypeDef 这个 GPIOMode TypeDef 是个类似于 int 的枚举类型 定义变量时 GPIOMode TypeDef GPIO MODE 这个 GPIO MODE 只能取上边的那四个值 typedef struct uint32 t GPIO Pin Specifies the GPIO pins to be configured This parameter can be any value of ref GPIO pins define GPIOMode TypeDef GPIO Mode Specifies the operating mode for the selected pins This parameter can be a value of ref GPIOMode TypeDef GPIOSpeed TypeDef GPIO Speed Specifies the speed for the selected pins This parameter can be a value of ref GPIOSpeed TypeDef GPIOOType TypeDef GPIO OType Specifies the operating output type for the selected pins This parameter can be a value of ref GPIOOType TypeDef GPIOPuPd TypeDef GPIO PuPd Specifies the operating Pull up Pull down for the selected pins This parameter can be a value of ref GPIOPuPd TypeDef GPIO InitTypeDef 这是个结构体 只不过这个结构体里面的额成员都是枚举类型的成员 且这个结构体也是 枚举类型的 是为了方便区分和避免出错 使用的时候还是要 GPIO InitTypeDef GPIO InitStruct 来定义一个结构体 Uint8 t Uint16 t 目前还是先使用这个厂家的库函数比较好 因为时间不允许 但是应该效率差不多 因为 可能只是库函数版本不同罢了 目录结构 四个文件夹 用户 MDK ARM 驱动库函数 CMSIS Cmsis 中的 必须的文件是 Stm32f4xx h Ccore cm4 h Stm32f4xx it c Startup stm32f40 41xxx s system stm32f4xx c 库函数驱动中必须的是 Crc c Rcc c Misc c Syscfg c 然后用到什么外设就把外设添加进来 时钟设置 Rcc 复位与实时钟控制 内外部时钟 PLL 系统 总线时钟配置 外设时钟配置 中断和标志位管理 一 复位和时钟控制 1 内外部时钟 pll 锁相环 时钟输出 时钟保护配置 外设默认都用 HIS 16m speed 开始都是关闭的除了 sram 和 flash Io 口都是输入 input floating 状态 Once the device started from reset the user application has to Configure the clock source to be used to drive the System clock if the application needs higher frequency performance Configure the System clock frequency and Flash settings Configure the AHB and APB busses prescalers Enable the clock for the peripheral s to be used Configure the clock source s for peripherals which clocks are not derived from the System clock I2S RTC ADC USB OTG FS SDIO RNG 系统时钟复位函数 void RCC DeInit void The default reset state of the clock configuration is given below HSI ON and used as system clock source HSE PLL and PLLI2S OFF AHB APB1 and APB2 prescaler set to 1 CSS MCO1 and MCO2 OFF All interrupts disabled This function doesn t modify the configuration of the Peripheral clocks LSI LSE and RTC clocks 使用外部时钟函数 void RCC HSEConfig uint8 t RCC HSE arg RCC HSE OFF turn OFF the HSE oscillator HSERDY flag goes low after 6 HSE oscillator clock cycles arg RCC HSE ON turn ON the HSE oscillator arg RCC HSE Bypass HSE oscillator bypassed with external clock 内部高频时钟校准函数 因受温度等的影响 void RCC AdjustHSICalibrationValue uint8 t HSICalibrationValue HSICalibrationValue specifies the calibration trimming value This parameter must be a number between 0 and 0 x1F 使能或关闭内部高频时钟 void RCC HSICmd FunctionalState NewState param NewState new state of the HSI This parameter can be ENABLE or DISABLE 使能或关闭外部低频振荡器 void RCC LSEConfig uint8 t RCC LSE arg RCC LSE OFF turn OFF the LSE oscillator LSERDY flag goes low after 6 LSE oscillator clock cycles arg RCC LSE ON turn ON the LSE oscillator arg RCC LSE Bypass LSE oscillator bypassed with external clock 使能或关闭内部低频振荡器 void RCC LSICmd FunctionalState NewState param NewState new state of the LSI This parameter can be ENABLE or DISABLE 锁相环是一种反馈电路 其作用是使得电路上的时钟和某一外部时钟的相位同步 设置系统时钟等 非常重要 void RCC PLLConfig uint32 t RCC PLLSource uint32 t PLLM uint32 t PLLN uint32 t PLLP uint32 t PLLQ RCC PLLSource specifies the PLL entry clock source arg RCC PLLSource HSI HSI oscillator clock selected as PLL clock entry arg RCC PLLSource HSE HSE oscillator clock selected as PLL clock entry PLLM specifies the division factor for PLL VCO input clock This parameter must be a number between 0 and 63 note You have to set the PLLM parameter correctly to ensure that the VCO input frequency ranges from 1 to 2 MHz It is recommended to select a frequency of 2 MHz to limit PLL jitter param PLLN specifies the multiplication factor for PLL VCO output clock This parameter must be a number between 192 and 432 note You have to set the PLLN parameter correctly to ensure that the VCO output frequency is between 192 and 432 MHz param PLLP specifies the division factor for main system clock SYSCLK This parameter must be a number in the range 2 4 6 or 8 note You have to set the PLLP parameter correctly to not exceed 168 MHz on the System clock frequency param PLLQ specifies the division factor for OTG FS SDIO and RNG clocks This parameter must be a number between 4 and 15 note If the USB OTG FS is used in your application you have to set the PLLQ parameter correctly to have 48 MHz clock for the USB However the SDIO and RNG need a frequency lower than or equal to 48 MHz to work correctly 使能或是关闭锁相环 void RCC PLLCmd FunctionalState NewState param NewState new state of the main PLL This parameter can be ENABLE or DISABLE retval None 使能或关闭时钟安全系统 void RCC ClockSecuritySystemCmd FunctionalState NewState This parameter can be ENABLE or DISABLE 选择一种时钟源输出 PA8 引脚 pa8 需要设置为第二功能引脚 void RCC MCO1Config uint32 t RCC MCO1Source uint32 t RCC MCO1Div arg RCC MCO1Source HSI HSI clock selected as MCO1 source arg RCC MCO1Source LSE LSE clock selected as MCO1 source arg RCC MCO1Source HSE HSE clock selected as MCO1 source arg RCC MCO1Source PLLCLK main PLL clock selected as MCO1 source param RCC MCO1Div specifies the MCO1 prescaler This parameter can be one of the following values arg RCC MCO1Div 1 no division applied to MCO1 clock arg RCC MCO1Div 2 division by 2 applied to MCO1 clock arg RCC MCO1Div 3 division by 3 applied to MCO1 clock arg RCC MCO1Div 4 division by 4 applied to MCO1 clock arg RCC MCO1Div 5 division by 5 applied to MCO1 clock PC9 同上 void RCC MCO2Config uint32 t RCC MCO2Source uint32 t RCC MCO2Div 2Sys clk hclk pclk1 pclk2 系统时钟 高速总线 外设总线 时钟配置 配置系统时钟 void RCC SYSCLKConfig uint32 t RCC SYSCLKSource 默认是 HIS 作为系统时钟的 sys clock 可以使用 RCC GetSYSCLKSource 获得哪个时钟源作为系统时钟 RCC SYSCLKSource specifies the clock source used as system clock This parameter can be one of the following values arg RCC SYSCLKSource HSI HSI selected as system clock source arg RCC SYSCLKSource HSE HSE selected as system clock source arg RCC SYSCLKSource PLLCLK PLL selected as system clock source 获得系统时钟 uint8 t RCC GetSYSCLKSource void 0 x00 HSI used as system clock 0 x04 HSE used as system clock 0 x08 PLL used as system clock 配置高级高性能总线时钟 AHB 之前的 hclk 时钟来源于 sys clock 系统时钟 void RCC HCLKConfig uint32 t RCC SYSCLK param RCC SYSCLK defines the AHB clock divider This clock is derived from the system clock SYSCLK This parameter can be one of the following values arg RCC SYSCLK Div1 AHB clock SYSCLK arg RCC SYSCLK Div2 AHB clock SYSCLK 2 arg RCC SYSCLK Div4 AHB clock SYSCLK 4 arg RCC SYSCLK Div8 AHB clock SYSCLK 8 arg RCC SYSCLK Div16 AHB clock SYSCLK 16 arg RCC SYSCLK Div64 AHB clock SYSCLK 64 arg RCC SYSCLK Div128 AHB clock SYSCLK 128 arg RCC SYSCLK Div256 AHB clock SYSCLK 256 arg RCC SYSCLK Div512 AHB clock SYSCLK 512 范围 最大 168m For STM32F405xx 407xx and STM32F415xx 417xx devices the maximum frequency of the SYSCLK and HCLK is 168 MHz PCLK2 84 MHz and PCLK1 42 MHz Depending on the device voltage range the maximum frequency should be adapted accordingly Latency HCLK clock frequency MHz voltage range voltage range voltage range voltage range 2 7 V 3 6 V 2 4 V 2 7 V 2 1 V 2 4 V 1 8 V 2 1 V 0WS 1CPU cycle 0 HCLK 30 0 HCLK 24 0 HCLK 22 0 HCLK 20 1WS 2CPU cycle 30 HCLK 60 24 HCLK 48 22 HCLK 44 20 HCLK 40 2WS 3CPU cycle 60 HCLK 90 48 HCLK 72 44 HCLK 66 40 HCLK 60 3WS 4CPU cycle 90 HCLK 120 72 HCLK 96 66 HCLK 88 60 HCLK 80 4WS 5CPU cycle 120 HCLK 150 96 HCLK 120 88 HCLK 110 80 HCLK 100 5WS 6CPU cycle 150 HCLK 168 120 HCLK 144 110 HCLK 132 100 HCLK 120 6WS 7CPU cycle NA 144 HCLK 168 132 HCLK 154 120 HCLK 140 7WS 8CPU cycle NA NA 154 HCLK 168 140 HCLK GPIO Pin GPIO Pin All GPIO InitStruct GPIO Mode GPIO Mode IN 输入模式选择 GPIO InitStruct GPIO Speed GPIO Speed 2MHz 速率 GPIO InitStruct GPIO OType GPIO OType PP 输出模式选择输出状态 推挽或开漏 GPIO InitStruct GPIO PuPd GPIO PuPd NOPULL 上拉下拉 输出模式选择 推挽或开漏 typedef enum GPIO OType PP 0 x00 GPIO OType OD 0 x01 GPIOOType TypeDef Gpio 模式选择 typedef enum GPIO Mode IN 0 x00 GPIO Input Mode GPIO Mode OUT 0 x01 GPIO Output Mode GPIO Mode AF 0 x02 GPIO Alternate function Mode GPIO Mode AN 0 x03 GPIO Analog Mode GPIOMode TypeDef 速度选择 typedef enum GPIO Speed 2MHz 0 x00 Low speed GPIO Speed 25MHz 0 x01 Medium speed GPIO Speed 50MHz 0 x02 Fast speed GPIO Speed 100MHz 0 x03 High speed on 30 pF 80 MHz Output max speed on 15 pF GPIOSpeed TypeDef 上拉下拉 typedef enum GPIO PuPd NOPULL 0 x00 GPIO PuPd UP 0 x01 GPIO PuPd DOWN 0 x02 GPIOPuPd TypeDef 置零置一选择 typedef enum Bit RESET 0 Bit SET BitAction 锁定 io 口 不太懂 以后再看 2Gpio 的读和写 读取某一位的输入状态 方便 一个 io 口是 16 位的 uint8 t GPIO ReadInputDataBit GPIO TypeDef GPIOx uint16 t GPIO Pin 读取一个 io 口的整个输入状态 uint16 t GPIO ReadInputData GPIO TypeDef GPIOx 读取 io 口的一位输出状态 uint8 t GPIO ReadOutputDataBit GPIO TypeDef GPIOx uint16 t GPIO Pin 读取一个 io 口的输出状态 uint16 t GPIO ReadOutputData GPIO TypeDef GPIOx 对某一位置 1 void GPIO SetBits GPIO TypeDef GPIOx uint16 t GPIO Pin 对某一位清零 void GPIO ResetBits GPIO TypeDef GPIOx uint16 t GPIO Pin 对某一位置一或是清零 void GPIO WriteBit GPIO TypeDef GPIOx uint16 t GPIO Pin BitAction BitVal 对一个 io 口写数据 void GPIO Write GPIO TypeDef GPIOx uint16 t PortVal 对某一位进行翻转 void GPIO ToggleBits GPIO TypeDef GPIOx uint16 t GPIO Pin Gpio 的第二功能选择 void GPIO PinAFConfig GPIO TypeDef GPIOx uint16 t GPIO PinSource uint8 t GPIO AF GPIO AFSelection selects the pin to used as Alternate function This parameter can be one of the following values arg GPIO AF RTC 50Hz Connect RTC 50Hz pin to AF0 default after reset arg GPIO AF MCO Connect MCO pin MCO1 and MCO2 to AF0 default after reset arg GPIO AF TAMPER Connect TAMPER pins TAMPER 1 and TAMPER 2 to AF0 default after reset arg GPIO AF SWJ Connect SWJ pins SWD and JTAG to AF0 default after reset arg GPIO AF TRACE Connect TRACE pins to AF0 default after reset arg GPIO AF TIM1 Connect TIM1 pins to AF1 arg GPIO AF TIM2 Connect TIM2 pins to AF1 arg GPIO AF TIM3 Connect TIM3 pins to AF2 arg GPIO AF TIM4 Connect TIM4 pins to AF2 arg GPIO AF TIM5 Connect TIM5 pins to AF2 arg GPIO AF TIM8 Connect TIM8 pins to AF3 arg GPIO AF TIM9 Connect TIM9 pins to AF3 arg GPIO AF TIM10 Connect TIM10 pins to AF3 arg GPIO AF TIM11 Connect TIM11 pins to AF3 arg GPIO AF I2C1 Connect I2C1 pins to AF4 arg GPIO AF I2C2 Connect I2C2 pins to AF4 arg GPIO AF I2C3 Connect I2C3 pins to AF4 arg GPIO AF SPI1 Connect SPI1 pins to AF5 arg GPIO AF SPI2 Connect SPI2 I2S2 pins to AF5 arg GPIO AF SPI4 Connect SPI4 pins to AF5 arg GPIO AF SPI5 Connect SPI5 pins to AF5 arg GPIO AF SPI6 Connect SPI6 pins to AF5 arg GPIO AF SAI1 Connect SAI1 pins to AF6 for STM32F42xxx 43xxx devices arg GPIO AF SPI3 Connect SPI3 I2S3 pins to AF6 arg GPIO AF I2S3ext Connect I2S3ext pins to AF7 arg GPIO AF USART1 Connect USART1 pins to AF7 arg GPIO AF USART2 Connect USART2 pins to AF7 arg GPIO AF USART3 Connect USART3 pins to AF7 arg GPIO AF UART4 Connect UART4 pins to AF8 arg GPIO AF UART5 Connect UART5 pins to AF8 arg GPIO AF USART6 Connect USART6 pins to AF8 arg GPIO AF UART7 Connect UART7 pins to AF8 arg GPIO AF UART8 Connect UART8 pins to AF8 arg GPIO AF CAN1 Connect CAN1 pins to AF9 arg GPIO AF CAN2 Connect CAN2 pins to AF9 arg GPIO AF TIM12 Connect TIM12 pins to AF9 arg GPIO AF TIM13 Connect TIM13 pins to AF9 arg GPIO AF TIM14 Connect TIM14 pins to AF9 arg GPIO AF OTG FS Connect OTG FS pins to AF10 arg GPIO AF OTG HS Connect OTG HS pins to AF10 arg GPIO AF ETH Connect ETHERNET pins to AF11 arg GPIO AF FSMC Connect FSMC pins to AF12 arg GPIO AF FMC Connect FMC pins to AF12 for STM32F42xxx 43xxx devices arg GPIO AF OTG HS FS Connect OTG HS configured in FS pins to AF12 arg GPIO AF SDIO Connect SDIO pins to AF12 arg GPIO AF DCMI Connect DCMI pins to AF13 arg GPIO AF LTDC Connect LTDC pins to AF14 for STM32F429xx 439xx devices arg GPIO AF EVENTOUT Connect EVENTOUT pins to AF15 三 系统配置控制器 里面的功能看用户手册 可能用不到 IO 补偿 以太网的模式选择 内存等的映射 四 中断和事件 设置抢占式优先级和响应优先级 当两个中断源的抢占式优先级相同时 这两个中断将没有嵌套关系 当一个中断到来后 如果正在处理另一个中断 这个后到来的中断就要等到前一个中断处理完之后才能被处理 如果这两个中断同时到达 则中断控制器根据他们的响应优先级高低来决定先处理哪一个 如果他们的抢占式优先级和响应优先级都相等 则根据他们在中断表中的排位顺序决定先 处理哪一个 void NVIC PriorityGroupConfig uint32 t NVIC PriorityGroup param NVIC PriorityGroup specifies the priority grouping bits length This parameter can be one of the following values arg NVIC PriorityGroup 0 0 bits for pre emption priority 4 bits for subpriority 0 个抢占 16 个响应 0 15 arg NVIC PriorityGroup 1 1 bits for pre emption priority 3 bits for subpriority arg NVIC PriorityGroup 2 2 bits for pre emption priority 2 bits for subpriority 4 个抢占 4 个响应 0 3 0 3 arg NVIC PriorityGroup 3 3 bits for pre emption priority 1 bits for subpriority arg NVIC PriorityGroup 4 4 bits for pre emption priority 0 bits for subpriority 根据中断枚举结构体初始化中断外设 void NVIC Init NVIC InitTypeDef NVIC InitStruct typedef struct uint8 t NVIC IRQChannel 选择对哪个中断进行操作 uint8 t NVIC IRQChannelPreemptionPriority 设置中断抢占优先级 uint8 t NVIC IRQChannelSubPriority 设置中断响应优先级 FunctionalState NVIC IRQChannelCmd 是否使能中断选择 ENABLE or DISABLE NVIC InitTypeDef typedef enum IRQn Cortex M4 Processor Exceptions Numbers NonMaskableInt IRQn 14 2 Non Maskable Interrupt MemoryManagement IRQn 12 4 Cortex M4 Memory Management Interrupt BusFault IRQn 11 5 Cortex M4 Bus Fault Interrupt UsageFault IRQn 10 6 Cortex M4 Usage Fault Interrupt SVCall IRQn 5 11 Cortex M4 SV Call Interrupt DebugMonitor IRQn 4 12 Cortex M4 Debug Monitor Interrupt PendSV IRQn 2 14 Cortex M4 Pend SV Interrupt SysTick IRQn 1 15 Cortex M4 System Tick Interrupt STM32 specific Interrupt Numbers WWDG IRQn 0 Window WatchDog Interrupt PVD IRQn 1 PVD through EXTI Line detection Interrupt TAMP STAMP IRQn 2 Tamper and TimeStamp interrupts through the EXTI line RTC WKUP IRQn 3 RTC Wakeup interrupt through the EXTI line FLASH IRQn 4 FLASH global Interrupt RCC IRQn 5 RCC global Interrupt EXTI0 IRQn 6 EXTI Line0 Interrupt EXTI1 IRQn 7 EXTI Line1 Interrupt EXTI2 IRQn 8 EXTI Line2 Interrupt EXTI3 IRQn 9 EXTI Line3 Interrupt EXTI4 IRQn 10 EXTI Line4 Interrupt DMA1 Stream0 IRQn 11 DMA1 Stream 0 global Interrupt DMA1 Stream1 IRQn 12 DMA1 Stream 1 global Interrupt DMA1 Stream2 IRQn 13 DMA1 Stream 2 global Interrupt DMA1 Stream3 IRQn 14 DMA1 Stream 3 global Interrupt DMA1 Stream4 IRQn 15 DMA1 Stream 4 global Interrupt DMA1 Stream5 IRQn 16 DMA1 Stream 5 global Interrupt DMA1 Stream6 IRQn 17 DMA1 Stream 6 global Interrupt ADC IRQn 18 ADC1 ADC2 and ADC3 global Interrupts if defined STM32F40 41xxx CAN1 TX IRQn 19 CAN1 TX Interrupt CAN1 RX0 IRQn 20 CAN1 RX0 Interrupt CAN1 RX1 IRQn 21 CAN1 RX1 Interrupt CAN1 SCE IRQn 22 CAN1 SCE Interrupt EXTI9 5 IRQn 23 External Line 9 5 Interrupts TIM1 BRK TIM9 IRQn 24 TIM1 Break interrupt and TIM9 global interrupt TIM1 UP TIM10 IRQn 25 TIM1 Update Interrupt and TIM10 global interrupt TIM1 TRG COM TIM11 IRQn 26 TIM1 Trigger and Commutation Interrupt and TIM11 global interrupt TIM1 CC IRQn 27 TIM1 Capture Compare Interrupt TIM2 IRQn 28 TIM2 global Interrupt TIM3 IRQn 29 TIM3 global Interrupt TIM4 IRQn 30 TIM4 global Interrupt I2C1 EV IRQn 31 I2C1 Event Interrupt I2C1 ER IRQn 32 I2C1 Error Interrupt I2C2 EV IRQn 33 I2C2 Event Interrupt I2C2 ER IRQn 34 I2C2 Error Interrupt SPI1 IRQn 35 SPI1 global Interrupt SPI2 IRQn 36 SPI2 global Interrupt USART1 IRQn 37 USART1 global Interrupt USART2 IRQn 38 USART2 global Interrupt USART3 IRQn 39 USART3 global Interrupt EXTI15 10 IRQn 40 External Line 15 10 Interrupts RTC Alarm IRQn 41 RTC Alarm A and B through EXTI Line Interrupt OTG FS WKUP IRQn 42 USB OTG FS Wakeup through EXTI line interrupt TIM8 BRK TIM12 IRQn 43 TIM8 Break Interrupt and TIM12 global interrupt TIM8 UP TIM13 IRQn 44 TIM8 Update Interrupt and TIM13 global interrupt TIM8 TRG COM TIM14 IRQn 45 TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt TIM8 CC IRQn 46 TIM8 Capture Compare Interrupt DMA1 Stream7 IRQn 47 DMA1 Stream7 Interrupt FSMC IRQn 48 FSMC global Interrupt SDIO IRQn 49 SDIO global Interrupt TIM5 IRQn 50 TIM5 global Interrupt SPI3 IRQn 51 SPI3 global Interrupt UART4 IRQn 52 UART4 global Interrupt UART5 IRQn 53 UART5 global Interrupt TIM6 DAC IRQn 54 TIM6 global and DAC1 通道选择 uint32 t DMA PeripheralBaseAddr 外设基址 uint32 t DMA Memory0BaseAddr 当双向模式没有打开时 默认用内存 0 这个是基本地 uint32 t DMA DIR 方向 m p p m m m uint32 t DMA BufferSize dma 缓存大小设置 uint32 t DMA PeripheralInc DMA 递增设置 uint32 t DMA MemoryInc DMA 内存寄存器递增设置 uint32 t DMA PeripheralDataSize DMA 外设数据宽度 uint32 t DMA MemoryDataSize DMA 内存数据宽度 uint32 t DMA Mode DMA 模式设置 uint32 t DMA Priority Dma 优先权设置 uint32 t DMA FIFOMode 缓冲模式或是直接模式选择设置 uint32 t DMA FIFOThreshold fifo 大小 uint32 t DMA MemoryBurst 内存的地址递增模式使能后才能用这个模式 突发 节拍数 目 不是中断传输而是用于单次传输 uint32 t DMA PeripheralBurst 外设的 DMA InitTypeDef DMA 流选择 define DMA Channel 0 uint32 t 0 x00000000 define DMA Channel 1 uint32 t 0 x02000000 define DMA Channel 2 uint32 t 0 x04000000 define DMA Channel 3 uint32 t 0 x06000000 define DMA Channel 4 uint32 t 0 x08000000 define DMA Channel 5 uint32 t 0 x0A000000 define DMA Channel 6 uint32 t 0 x0C000000 define DMA Channel 7 uint32 t 0 x0E000000 方向选择 define DMA DIR PeripheralToMemory uint32 t 0 x00000000 define DMA DIR MemoryToPeripheral uint32 t 0 x00000040 define DMA DIR MemoryToMemory uint32 t 0 x00000080 Dma 外设寄存器递增设置 define DMA PeripheralInc Enable uint32 t 0 x00000200 define DMA PeripheralInc Disable uint32 t 0 x00000000 Dma 内存寄存器递增设置 define DMA MemoryInc Enable uint32 t 0 x00000400 define DMA MemoryInc Disable uint32 t 0 x00000000 DMA 外设数据宽度 define DMA PeripheralDataSize Byte uint32 t 0 x00000000 define DMA PeripheralDataSize HalfWord uint32 t 0 x00000800 define DMA PeripheralDataSize Word uint32 t 0 x00001000 Dma 模式选择 define DMA Mode Normal uint32 t 0 x00000000 define DMA Mode Circular uint32 t 0 x00000100 Dma 优先权设置 define DMA Priority Low uint32 t 0 x00000000 define DMA Priority Medium uint32 t 0 x00010000 define DMA Priority High uint32 t 0 x00020000 define DMA Priority VeryHigh uint32 t 0 x00030000 缓冲模式或是直接模式选择设置 define DMA FIFOMode Disable uint32 t 0 x00000000 define DMA FIFOMode Enable uint32 t 0 x00000004 缓冲模式的阀值设置 define DMA FIFOThreshold 1QuarterFull uint32 t 0 x00000000 define DMA FIFOThreshold HalfFull uint32 t 0 x00000001 define DMA FIFOThreshold 3QuartersFull uint32 t 0 x00000002 define DMA FIFOThreshold Full uint32 t 0 x00000003 内存突发增量传输的节拍数选择 不是字节数 define DMA MemoryBurst Single uint32 t 0 x00000000 define DMA MemoryBurst INC4 uint32 t 0 x00800000 define DMA MemoryBurst INC8 uint32 t 0 x01000000 define DMA MemoryBurst INC16 uint32 t 0 x01800000 外设突发增量传输的节拍数选择 不是字节数 define DMA PeripheralBurst Single uint32 t 0 x00000000 define DMA PeripheralBurst INC4 uint32 t 0 x00200000 define DMA PeripheralBurst INC8 uint32 t 0 x00400000 define DMA PeripheralBurst INC16 uint32 t 0 x00600000 用默认值填充初始化结构体 void DMA StructInit DMA InitTypeDef DMA InitStruct 默认是 通道 0 外设基址 0 内存基址 0 方向外设到内存 缓存大小是 0 光比递增 外设内存数据大小字节 普通模式 优先权是低 fifo 关闭 fifo 四分之一 突进单次节拍 打开或是关闭 dma 数据流 关闭后应该是和堆栈一样 会保留现场 恢复后继续传输 void DMA Cmd DMA Stream TypeDef DMAy Streamx FunctionalState NewState param DMAy Streamx where y can be 1 or 2 to select the DMA and x can be 0 to 7 to select the DMA Stream param NewState n
展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 解决方案


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!