资源简介
使用STM32的内部定时器和DMA来产生一路或两路互补的SPWM波
代码片段和文件信息
#include “stm32f10x.h“
#define TIM1_CCR3_Address 0x40012C3C
#define MAX_TABLE 180
TIM_TimebaseInitTypeDef TIM_TimebaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
uint16_t SRC_Buffer[MAX_TABLE] = {
1000103310661099113211651198123012621294132513561386141614461475
1503153115581585161116361660168317061728174917691788180618231839
1854186818811893190419131922192919361941194519481949195019491948
1945194119361929192219131904189318811868185418391823180617881769
1749172817061683166016361611158515581531150314751446141613861356
13251294126212301198116511321099106610331000 967 934 901 868 835
802 770 738 706 675 644 614 584 554 525 497 469 442 415 389 364
340 317 294 272 251 231 212 194 177 161 146 132 119 107 96 87
78 71 64 59 55 52 51 50 51 52 55 59 64 71 78 87
96 107 119 132 146 161 177 194 212 231 251 272 294 317 340 364
389 415 442 469 497 525 554 584 614 644 675 706 738 770 802 835
868 901 934 967
};
ErrorStatus HSEStartUpStatus;
/* Private function prototypes -----------------------------------------------*/
void RCC_Configuration(void);
void GPIO_Configuration(void);
void DMA_Configuration(void);
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
DMA_Configuration();
/* TIM1 Peripheral Configuration --------------------------------------------*/
/* Time base configuration */
TIM_TimebaseStructure.TIM_Prescaler = 0;
TIM_TimebaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimebaseStructure.TIM_Period = 2000-1;//72M/x=frq R*C=0.025 R=100Kc=100000p=0.1uf=0.0000001f
TIM_TimebaseStructure.TIM_ClockDivision = 0;
TIM_TimebaseStructure.TIM_RepetitionCounter = 2;
TIM_TimebaseInit(TIM1 &TIM_TimebaseStructure);
/* Channel 3 Configuration in PWM mode */
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable;
TIM_OCInitStructure.TIM_Pulse = 50;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_Low;
TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;
TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset;
TIM_OC3Init(TIM1 &TIM_OCInitStructure);
/* TIM1 Update DMA Request enable */
TIM_DMACmd(TIM1 TIM_DMA_Update ENABLE);
/* TIM1 counter enable */
TIM_Cmd(TIM1 ENABLE);
/* Main Output Enable */
TIM_CtrlPWMOutputs(TIM1 ENABLE);
while (1)
{}
}
void RCC_Configuration(void)
{
SystemInit();
/* TIM1 GPIOA and GPIOB clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1 | RCC_APB2Periph_GPIOA |
RCC_APB2Periph_GPIOB ENABLE);
/* DMA clock enable */
RCC_AHBPeriphClock
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4478 2013-07-22 18:58 User\main.c
文件 3259 2011-04-04 19:03 User\stm32f10x_conf.h
文件 4405 2011-04-04 19:03 User\stm32f10x_it.c
文件 2086 2011-04-04 19:03 User\stm32f10x_it.h
文件 36557 2011-04-04 19:03 User\system_stm32f10x.c
目录 0 2013-07-06 16:05 User\MyCHFile
目录 0 2013-07-22 18:58 User
----------- --------- ---------- ----- ----
50785 7
- 上一篇:STM32F103测频率
- 下一篇:robotfr
amework 汉化报告结果文件
相关资源
- STM32F103测频率
- STM32F103+DAC8552
- 基于DSP的单相SPWM逆变器数字化控制技
- STM32F103C8T6 LCD12864 串行通信
- cubeMX视频教程stm32hal库函数cubemx实战讲
- SPWM逆变器stm32例程及电路图仿真.zip
- STM32 STM32F103C8T6 读取DS18B20温度数据例
- STM32 STM32F103C8T6 CAN从机+4DI2DO 硬件设计
- msp430G2553测各种波形的频率和幅度并显
- 基于STM32cubeMX,STM32F103C8T6的PWM输出实
- LabVIEW创建波形,回放波形,TDMS存储
- STM32F103RCT6使用DS1302时钟模块
- stm32f103zet6最小系统原理图
- STM32F103单片机输出SPWM波
- STM32F103 ADC 中断模式 连续转换
- stm32f103引脚详图
- VC程序实现了波形显示与FFT算法
- STM32F103C8T6+1.44寸ST7735TFT LCD彩屏驱动程
- stm32cubemx软件iic读取mpu6050dmp通过串口
- 基于verilog的DDS任意波形发生器
- 基于FPGA的任意波形发生器
- STM32F103ZET6 AD10封装库
- 基于12864LCD的波形显示系统的研制
- STM32F10x标准固件函数库V3.6.1
- DSP中用查表法通过拨码开关实现不同
- spwm波正弦波表生成小工具(3款)
- stm32f103的AD7091驱动程序
- 异步清零、技术使能、数据加载等不
- 基于fpga的DDS信号发生器四种波形
- stm32f103系列spi连接rc522的rfid读卡程序
评论
共有 条评论