当前位置:网站首页 > 数据科学与大数据 > 正文

msp432p401R单片机用什么型号的数据线(msp430f149单片机)



* MSP432E401Y

* Description:本函数实现定时和测速功能

* 引脚:PD0->编码器输入信号

*

* Author: Robin.J

*/


/* DriverLib Includes */

#include


/* Standard Includes */

#include


uint32_t count = 0;

//uint32_t count1 = 0;

//uint32_t count2 = 0;


uint32_t CNT1 = 0;

uint32_t CNT2 = 0;

int speed = 0;

uint32_t time1 = 0;


void TIMER2A_IRQHandler(void)

{

uint32_t getTimerInterrupt;


count++;//脉冲计数,高电平触发

// count1 = MAP_TimerValueGet(TIMER2_BASE,TIMER_B);

// count2 = MAP_TimerLoadGet(TIMER2_BASE,TIMER_B);   

/* Get timer interrupt status and clear the same */

getTimerInterrupt = MAP_TimerIntStatus(TIMER2_BASE, true);

MAP_TimerIntClear(TIMER2_BASE, getTimerInterrupt);

}


void TIMER1A_IRQHandler(void)

{

uint32_t getTimerInterrupt;


// CNT1 = count;

// CNT2 = CNT1;

// speed = ((CNT1 - CNT2)/506) * 6000;

// count = 0;


time1++;//计时,每10ms增1

if(time1 == 10){

CNT1 = count;

}if(time1 == 20){


CNT2 = count;

//count1 = CNT2 - CNT1;

speed = (int)(((CNT2 - CNT1)/506.0) * 600);

//count = 0;

time1 = 0;

count = 0;

}


// s_r = speed;

// pid_r = IncPIDCalc_r(s_r);

// pid_r *= 0.01;

// pwm_pidr += pid_r;

// if(pwm_pidr > 0.99){

//

// pwm_pidr = 0.99;

//

// }

//

// PWM_init(pwm_pidl,0.8);   

/* Get timer interrupt status and clear the same */

getTimerInterrupt = MAP_TimerIntStatus(TIMER1_BASE, true);

MAP_TimerIntClear(TIMER1_BASE, getTimerInterrupt);


}



void GPT_init(void)

{


MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);


while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOA)))

{

}


MAP_GPIOPinConfigure(GPIO_PA4_T2CCP0);

MAP_GPIOPinTypeTimer(GPIO_PORTA_BASE, GPIO_PIN_4);

MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);

while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_TIMER2)))

{

}


MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);

while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_TIMER1)))

{

}


MAP_TimerConfigure(TIMER2_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME_UP);

MAP_TimerIntEnable(TIMER2_BASE, TIMER_CAPA_EVENT);

MAP_TimerControlEvent(TIMER2_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);



MAP_TimerConfigure(TIMER1_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC);

MAP_TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);


/* Since the 16-bit timer can count only 65536 value, we use the pre

* scaler of 256 to divide down the count rate by 256. Thus the actual

* count load is16e6/256 = 62500. Now when to count at 0.1 sec the

* load value in the timer would be 62500 * 0.1 =6250. */

MAP_TimerPrescaleSet(TIMER1_BASE, TIMER_A, 255);

MAP_TimerLoadSet(TIMER1_BASE, TIMER_A, 625);//10ms

/* Enable Timer Interrupt */

MAP_IntEnable(INT_TIMER2A);


MAP_IntEnable(INT_TIMER1A);


/* Enable the timer count */

MAP_TimerEnable(TIMER2_BASE, TIMER_A);


MAP_TimerEnable(TIMER1_BASE, TIMER_A);



}

/* (C) COPYRIGHT 2018 DY EleTe *END OF FILE/

到此这篇msp432p401R单片机用什么型号的数据线(msp430f149单片机)的文章就 介绍到这了,更多相关内容请继续浏览下面的相关 推荐文章,希望大家都能在 编程的领域有一番成就!

版权声明


相关文章:

  • 自动驾驶数据集如何收集(自动驾驶数据集如何收集到车辆)2025-05-27 19:00:07
  • sql文件如何打开2000万数据(sql2000数据文件在哪)2025-05-27 19:00:07
  • 密码查询数据(查询密码管理是什么)2025-05-27 19:00:07
  • spss数据分析如何做(spss数据分析做曲线分析)2025-05-27 19:00:07
  • 中文期刊类数据库(中文期刊数据库官网)2025-05-27 19:00:07
  • cmip6数据处理教程(cmip6数据介绍)2025-05-27 19:00:07
  • junit5 springboot(junit5 springboot 数据库引入)2025-05-27 19:00:07
  • 小米手机数据迁移到vivo手机(小米手机数据迁移到vivo手机怎么弄)2025-05-27 19:00:07
  • 达梦数据库连接报系统错误(达梦数据库启动报错)2025-05-27 19:00:07
  • pointnet训练自己的数据集(cornernet训练自己的数据集)2025-05-27 19:00:07
  • 全屏图片