• 大小: 122KB
    文件类型: .zip
    金币: 2
    下载: 2 次
    发布日期: 2021-05-07
  • 语言: 其他
  • 标签: MSP430F5529  

资源简介

用与430F5529的程序测试,例程改编,已测试,可放心使用

资源截图

代码片段和文件信息

++/****************************************************************************************
 * @brief: 直流电机驱动Demo
 * @files: main.c
 * @date: 2015-04-24
 * @athour:zhangkai
 * @pin:
 *        LCD:P3.2   <--->  SCK
 *            P3.0   <--->  SDA
 *            P2.6   <--->  CS
 *            P3.7   <--->  CD
 *            P8.2   <--->  RES
 *                    直流电机: P1.2   <--->  PWM
 *             P6.1   <--->  HIGH
 *
 *                   使能: P6.1   <--->  HIGH
 ****************************************************************************************/
#include  
#include 
#include 
#include “sysclk.h“
#include “grlib.h“
#include “Template_Driver.h“
#include “wheel.h“
#include “graph_extend.h“
#include “button.h“

#define CCR_TIMER  10000

extern uint16_t count = 0;

/****************************************************************************
 * @brief: 初始化PWM
 * @param: none
 * @return: none
 ***************************************************************************/
void Init_PWM(){
// PWM波生成
TA0CCR0 = CCR_TIMER - 1;                           // PWM Period
TA0CCTL1 = OUTMOD_7;                       // CCR1 reset/set
TA0CCR1 = CCR_TIMER / 2;                            // CCR1 PWM duty cycle
TA0CTL = TASSEL_2 + MC_1 + TACLR;         // SMCLK up mode clear TAR
}


/****************************************************************************
 * @brief: 初始化P2.0 中断捕获
 * @param: none
 * @return: none
 ***************************************************************************/
void Init_Cap_Int(){
// TimerA 1.1 捕获模式
//IO初始化
P2DIR &= ~BIT0;
P2SEL |= BIT0;   //P2.0设置为捕获输入CCI0A
P2IES |= BIT0;
P2IE |= BIT0;

TA1CCTL1 &= ~(CCIS1 + CCIS0);         //捕获源为P2.0,即CCI0A(也是CCI0B)
TA1CCTL1 |= CM_2 + SCS + CAP;         //下降沿捕获,同步捕获,工作在捕获模式
TA1CCTL1 |= CCIE;                     //允许捕获比较模块提出中断请求
TA1CTL |= ID_3;  /* Timer A input divider: 3 - /8 */
TA1CTL |= TASSEL_2;                   //选择时钟MCLK
TA1CTL |= TACLR;                      //定时器清零,

//定时器开始计数(连续计数模式0~0xFFFF)
TA1CTL |= MC_2;

_EINT(); //  允许P1.3中断
}

/****************************************************************************
 * @brief: 初始化端口
 * @param: none
 * @return: none
 ***************************************************************************/
void Init_Port()
{
P6DIR |= BIT1; //P6.1
P6OUT |= BIT1;

P4DIR |= BIT0; //P4.0
P4OUT |= BIT0;

P1DIR |= BIT2;                      // P1.2 PWM输出
P1SEL |= BIT2;                      // P1.2 options select
}


/****************************************************************************************
 * main.c
 ***************************************************************************************/
int main(void)
{
    WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
SysClk_Init(); //设置时钟为25Mhz

LCD_WheelInit();

LCD_ButtonInit();

Init_Port();

Init_PWM();

Init_Cap_Int();

//-----显示库函数初始化-----
tContext g_sContext;
Template_DriverInit();
GrContextInit(&g_sContext &g_sT

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-04-26 16:19  CH6_DC_Motor\
     文件         545  2015-07-04 14:58  CH6_DC_Motor\.ccsproject
     文件       31040  2015-07-04 14:58  CH6_DC_Motor\.cproject
     目录           0  2016-04-26 16:19  CH6_DC_Motor\.launches\
     文件        4237  2015-07-04 14:58  CH6_DC_Motor\.launches\CH3_LCD.launch
     文件        4318  2015-07-07 10:07  CH6_DC_Motor\.launches\CH6_DC_Motor.launch
     文件        4314  2015-07-04 14:58  CH6_DC_Motor\.launches\DC_Motor_MSEK_5529.launch
     文件         842  2015-07-04 14:58  CH6_DC_Motor\.project
     目录           0  2016-04-26 16:19  CH6_DC_Motor\.settings\
     文件          62  2015-07-04 14:58  CH6_DC_Motor\.settings\org.eclipse.cdt.codan.core.prefs
     文件         123  2015-07-04 14:58  CH6_DC_Motor\.settings\org.eclipse.cdt.debug.core.prefs
     文件         907  2015-07-04 14:58  CH6_DC_Motor\.settings\org.eclipse.core.resources.prefs
     目录           0  2016-04-26 16:24  CH6_DC_Motor\Debug\
     文件       52693  2015-08-05 09:42  CH6_DC_Motor\Debug\CH6_DC_Motor.map
     文件      326909  2015-08-05 09:42  CH6_DC_Motor\Debug\CH6_DC_Motor_linkInfo.xml
     目录           0  2016-04-26 16:19  CH6_DC_Motor\Debug\Graph\
     目录           0  2016-04-26 16:24  CH6_DC_Motor\Debug\Graph\Fonts\
     文件         551  2015-08-05 09:42  CH6_DC_Motor\Debug\Graph\Fonts\fontcm16.pp
     文件         557  2015-08-05 09:42  CH6_DC_Motor\Debug\Graph\Fonts\fontcm16b.pp
     文件         575  2015-08-05 09:42  CH6_DC_Motor\Debug\Graph\Fonts\fontfixed6x8.pp
     文件        4714  2016-04-26 16:24  CH6_DC_Motor\Debug\Graph\Fonts\subdir_rules.mk
     文件         942  2016-04-26 16:24  CH6_DC_Motor\Debug\Graph\Fonts\subdir_vars.mk
     目录           0  2016-04-26 16:24  CH6_DC_Motor\Debug\Graph\LCD_Driver\
     文件        2251  2015-08-05 09:42  CH6_DC_Motor\Debug\Graph\LCD_Driver\Template_Driver.pp
     文件        1800  2016-04-26 16:24  CH6_DC_Motor\Debug\Graph\LCD_Driver\subdir_rules.mk
     文件         640  2016-04-26 16:24  CH6_DC_Motor\Debug\Graph\LCD_Driver\subdir_vars.mk
     目录           0  2016-04-26 16:24  CH6_DC_Motor\Debug\Graph\graph_extend\
     文件        1525  2015-08-05 09:42  CH6_DC_Motor\Debug\Graph\graph_extend\graph_extend.pp
     文件        1799  2016-04-26 16:24  CH6_DC_Motor\Debug\Graph\graph_extend\subdir_rules.mk
     文件         634  2016-04-26 16:24  CH6_DC_Motor\Debug\Graph\graph_extend\subdir_vars.mk
     目录           0  2016-04-26 16:24  CH6_DC_Motor\Debug\Graph\grlib\
............此处省略61个文件信息

评论

共有 条评论