1、使用TIM3_CC1,相关联引脚P1_7

#define GPIOPWM() do{P1SEL |= 0x80;}while(0);
#define GPIOCLOSEPWM() do{P1SEL  &= ~0x80; P1_7 = 0;}while(0);

void GPIOInit(void)

{

  P1SEL  &= ~0x80;
   P1DIR  |= 0x80;
   P1_7 = 0;

}

void timer3Init(void)//产生PWM
{
    PERCFG |= 0x20;//选择定时器3的备用位置2
    P2SEL  |= 0x20;//设置定时器3优先

  T3CCTL1 = 0;
 
    T3CCTL0 = 0x10|0x04;
    T3CC0 = 254;//实际的定时器值,用于产生周期的设置
    T3CCTL1 = 0x18|0x04; // Compare mode 3
    T3CC1 = 1;
    T3CTL = 0xA0|0x10|0x02; // Div, Start, modulo

}

void GPIOCarrConfig(unsigned char carr1)//占空比配置

{

  unsigned char carr;
    carr = ~carr1;
    GPIOCLOSEPWM();
    if( carr > 0 )
    {
     T3CC1 = carr;
    }
    else
    {
       T3CC1 = 1;
    }
    GPIOPWM();

}

2.使用TIM1的不同通道产生不同的PWM信号,例如:配置P0_2、P0_3、P0_4、P0_5、P0_6分别配置不同的PWM信号等。

可参考TI官网工程师给顾客的答疑部分,网址如下:http://e2e.ti.com/support/low_power_rf/f/156/t/118346.aspx?pi36597=2

部分相关配置如下:

PERCFG &= ~0x40; // Select Timer 1 Alternative 0 location
PERCFG |= 0x03; // Move USART0 and USART1 to Alternative 2 location to allow all Timer 1 channels on P0
P2DIR = (P2DIR & ~0xC0) | 0x80; // Give priority to Timer 1
P0SEL |= 0x3C;  // Set P0_2-P0_5 to peripheral

T1CC0L = 0xff;   // PWM signal period
T1CC0H = 0x7f;

T1CCTL0 = 0x1c; // Channel 0 in compare mode, Set output on compare-up, clear on 0 (50% duty cycle)

T1CC1L = 0x78;  // PWM duty cycle, Channel 1 (P0_3)
T1CC1H = 0x10;

T1CCTL1 = 0x1c; // Channel 1 in compare mode, Set output on compare-up, clear on compare-down

T1CC2L = 0x78;  // PWM duty cycle, Channel 2 (P0_4)
T1CC2H = 0x10;

T1CCTL2 = 0x1c; // Channel 2 in compare mode, Set output on compare-up, clear on compare-down

T1CC3L = 0x78;  // PWM duty cycle, Channel 3 (P0_4)
T1CC3H = 0x10;

T1CCTL3 = 0x1c; // Channel 3 in compare mode, Set output on compare-up, clear on compare-down

T1CC4L = 0x78;  // PWM duty cycle, Channel 4 (P0_5)
T1CC4H = 0x10;

T1CCTL4 = 0x1c; // Channel 4 in compare mode, Set output on compare-up, clear on compare-down

T1CTL |= 0x0f; // divide with 128 and to do i up-down mode

注意:

on P0_2 you can only get 50% duty cycle unless you can use free-running mode, which will limit the available settings for the period. The period you are using now is 131 ms, provided that you use the maximum tick speed (32 MHz). If you change to free running mode, you have to choose between a period of 65.5 ms and 262 ms using the maximum tick speed. But if you use a tick speed of 16 MHz, you can get a period of 131 ms in free-running mode using a presacler of 32. See the CLKCONCMD register on how to change the tick speed.

If you want more concrete advice on this, please let me know what your requirements are for the period and the duty cycle.

A program can look something like this. Here, I have set up the same duty cycle on all channels except channel 0. To use different duty cycle for some of the channels, just change the value of T1CCnL/T1CCnH for those channels.

CC2530 PWM波形产生。的更多相关文章

  1. STM32之PWM波形输出配置总结

    一.   TIMER分类: STM32中一共有11个定时器,其中TIM6.TIM7是基本定时器:TIM2.TIM3.TIM4.TIM5是通用定时器:TIM1和TIM8是高级定时器,以及2个看门狗定时器 ...

  2. STM32F4_TIM输出PWM波形(可调频率、占空比)

    Ⅰ.概述 上一篇文章关于STM32基本的计数原理明白之后,该文章是在其基础上进行拓展,讲述关于STM32比较输出的功能,以输出PWM波形为实例来讲述. 提供实例工程中比较实用的函数:只需要调用该函数, ...

  3. 基于STM32F429和Cube的主从定时器多通道输出固定个数的PWM波形

    主从定时器的原理已在上篇博文: 基于STM32F429+HAL库编写的定时器主从门控模式级联输出固定个数PWM脉冲的程序 讲解了,这篇重点就讲如何实现多通道的PWM级联输出. 1.软件环境 Keil5 ...

  4. 基于STM32F030F4P9和STM32 CUBEMX 输出PWM波形

    STM32F030F4P9定时器功能比较丰富,在此记录项目中使用其自动输出PWM波形(频率:50HZ).CubeMX配置定时器如下图说明. 在此定时器基础时钟为48MHZ,配置中不做分频处理,预分频系 ...

  5. STM32 TIM 多通道互补PWM波形输出配置快速入门

    platform:stm32f10xxx lib:STM32F10x_StdPeriph_Lib_V3.5.0 前言 在做三相逆变的时候,需要软件生成SVPWM波形,具体的算法需要产生三对互补的PWM ...

  6. cc2530 timer 1 PWM 输出

    需要在ZStack 协议栈里使用PWM,于是使用其16bit的timer 1来实现之.使用 P1_0口输出,使用的是正计数/倒计数模式,占空比为50%.代码如下: #include <ioCC2 ...

  7. PWM波控制舵机总结

    文章转自:http://www.geek-workshop.com/thread-70-1-1.html 一.关于舵机: 舵机(英文叫Servo):它由直流电机.减速齿轮组.传感器和控制电路组成的一套 ...

  8. 关于普通定时器与高级定时器的 PWM输出的初始化的区别

    不管是普通定时器还是高级定时器,你用哪个通道,就在程序里用OC多少.比如CH3对应OC3 TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;  TIM_ ...

  9. (原创)基于MCU的频率可调,占空比可调的PWM实现(MCU,MCS-51/MSP430)

    1.Abstract     做这个是受朋友之邀,用在控制电机转动的方面.他刚好在一家好的单位实习,手头工作比较多,无暇分身,所以找我帮忙做个模型.要求很明晰,PWM的频率在0~1KHz范围内,占空比 ...

随机推荐

  1. DataTables语言国际化

    $('#example').DataTable({     language: {         "sProcessing": "处理中...",       ...

  2. ScrollView嵌套listview 时根据内容动态设置listview高度

    public static void setListViewHeightBasedOnChilds(ListView listView){ ListAdapter listAdapter = list ...

  3. GO的数组及切片

    感觉在向PYTHON学一些数组方面的功能. package main import "fmt" func main() { ]], , , , , , , , , } ] fmt. ...

  4. IIC总线协议---以存储芯片at24c64为例

    IIC总线协议 前言:年前给老师做个红外抄表系统,,现在对当中用到的一些模块总结一下. 1.只有在总线空闲时才允许启动数据传送. 2.在数据传送过程中,当时钟线为高电平时,数据线必须保持稳定状态,不允 ...

  5. Qt 的信号与槽机制介绍(10个要注意的问题)

    QT 是一个跨平台的 C++ GUI 应用构架,它提供了丰富的窗口部件集,具有面向对象.易于扩展.真正的组件编程等特点,更为引人注目的是目前 Linux 上最为流行的 KDE 桌面环境就是建立在 QT ...

  6. ImageMagick提取图像原始数据(ImageData/RawData)

    我用的是ImageMagickWand的接口,因为这接口比Core接口更上层,所以官方文档推荐用. 抽取整个图像文件字节数据: http://www.imagemagick.org/discourse ...

  7. Teach Yourself Scheme in Fixnum Days 13 Jump跳转

    Jumps One of the signal features of Scheme is its support for jumps or nonlocal control. Specificall ...

  8. 微软 Dynamics AX 学习步骤

    第一步:了解到AX的架构,AOT结构,了解AOT中表,窗体,类,job,菜单,菜单项的基础开发.知道代码可以写在那里,每个对象以及对象内部的具体设置.如果你不了解类,继承,这些,那么就需要找一下讲述类 ...

  9. bzoj3039 玉蟾宫

    Description 有一天,小猫rainbow和freda来到了湘西张家界的天门山玉蟾宫,玉蟾宫宫主蓝兔盛情地款待了它们,并赐予它们一片土地.这片土地被分成N*M个格子,每个格子里写着'R'或者' ...

  10. easyui获取日期datebox中的值

    <input type="text" class="easyui-datebox" id="CTIME" style="wi ...