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

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

大家好,我是讯享网,很高兴认识大家。




讯享网

 <tr> <td width="50%" style="vertical-align:top;padding:10px 10px 10px 0;"> </td> <td width="50%" style="vertical-align:top;padding:10px;"> </td> </tr> <tr> <td width="50%" style="vertical-align:top;padding:10px 10px 10px 0;"> </td> <td width="50%" style="vertical-align:top;padding:10px;"> </td> </tr> <tr> <td width="50%" style="vertical-align:top;padding:10px 10px 10px 0;"> </td> <td width="50%" style="vertical-align:top;padding:10px;"> </td> </tr> <tr> <td width="50%" style="vertical-align:top;padding:10px 10px 10px 0;"> </td> <td width="50%" style="vertical-align:top;padding:10px;"> </td> </tr> <tr> <td width="50%" style="vertical-align:top;padding:10px 10px 10px 0;"> </td> <td width="50%" style="vertical-align:top;padding:10px;"> </td> </tr> <p>&nbsp;* MSP432E401Y<p>&nbsp;* Description:本函数实现定时和测速功能 &nbsp;<p>&nbsp;* 引脚:PD0->编码器输入信号<p>&nbsp;* &nbsp; &nbsp; &nbsp; &nbsp;<p>&nbsp;* Author: Robin.J<p>*/<p><br/><p>/* DriverLib Includes */<p>#include <ti/devices/msp432e4/driverlib/driverlib.h><p><br/><p>/* Standard Includes */<p>#include <common.h><p><br/><p>uint32_t count = 0;<p>//uint32_t count1 = 0;<p>//uint32_t count2 = 0;<p><br/><p>uint32_t CNT1 = 0;<p>uint32_t CNT2 = 0;<p>int speed = 0;<p>uint32_t time1 = 0;<p><br/><p>void TIMER2A_IRQHandler(void)<p>{<p>&nbsp; &nbsp; uint32_t getTimerInterrupt;<p><br/><p>&nbsp; &nbsp; count++;//脉冲计数,高电平触发<p>// &nbsp; &nbsp;count1 = MAP_TimerValueGet(TIMER2_BASE,TIMER_B);<p>// &nbsp; &nbsp;count2 = MAP_TimerLoadGet(TIMER2_BASE,TIMER_B); &nbsp;&nbsp;<p>&nbsp; &nbsp; /* Get timer interrupt status &nbsp;and clear the same */<p>&nbsp; &nbsp; getTimerInterrupt = MAP_TimerIntStatus(TIMER2_BASE, true);<p>&nbsp; &nbsp; MAP_TimerIntClear(TIMER2_BASE, getTimerInterrupt);<p>}<p><br/><p>void TIMER1A_IRQHandler(void)<p>{<p>&nbsp; &nbsp; uint32_t getTimerInterrupt;<p><br/><p>// &nbsp; &nbsp;CNT1 = count;<p>// &nbsp; &nbsp;CNT2 = CNT1;<p>// &nbsp; &nbsp;speed = ((CNT1 - CNT2)/506) * 6000;<p>// &nbsp; &nbsp;count = 0;<p><br/><p>&nbsp; &nbsp; time1++;//计时,每10ms增1<p>&nbsp; &nbsp; if(time1 == 10){ &nbsp;<p>&nbsp; &nbsp; &nbsp; CNT1 = count;<p>&nbsp; &nbsp; }if(time1 == 20){<p><br/><p>&nbsp; &nbsp; &nbsp; CNT2 = count;<p>&nbsp; &nbsp; &nbsp; //count1 = CNT2 - &nbsp;CNT1;<p>&nbsp; &nbsp; &nbsp; speed = (int)(((CNT2 - CNT1)/506.0) * 600);<p>&nbsp; &nbsp; &nbsp; //count = 0;<p>&nbsp; &nbsp; &nbsp; time1 = 0;<p>&nbsp; &nbsp; &nbsp; count = 0;<p>&nbsp; &nbsp; }<p><br/><p>// &nbsp; &nbsp;s_r = speed;<p>// &nbsp; &nbsp;pid_r = IncPIDCalc_r(s_r);<p>// &nbsp; &nbsp;pid_r *= 0.01;<p>// &nbsp; &nbsp;pwm_pidr += pid_r;<p>// &nbsp; &nbsp;if(pwm_pidr > 0.99){<p>// &nbsp; &nbsp; &nbsp;<p>// &nbsp; &nbsp; &nbsp;pwm_pidr = 0.99;<p>// &nbsp; &nbsp; &nbsp;<p>// &nbsp; &nbsp;}<p>// &nbsp; &nbsp;<p>// &nbsp; &nbsp;PWM_init(pwm_pidl,0.8); &nbsp;&nbsp;<p>&nbsp; &nbsp; /* Get timer interrupt status &nbsp;and clear the same */<p>&nbsp; &nbsp; getTimerInterrupt = MAP_TimerIntStatus(TIMER1_BASE, true);<p>&nbsp; &nbsp; MAP_TimerIntClear(TIMER1_BASE, getTimerInterrupt);<p><br/><p>}<p><br/><p><br/><p>void GPT_init(void)<p>{<p><br/><p>&nbsp; &nbsp; MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);<p><br/><p>&nbsp; &nbsp; &nbsp; &nbsp; while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOA)))<p>&nbsp; &nbsp; {<p>&nbsp; &nbsp; }<p><br/><p>&nbsp; &nbsp; MAP_GPIOPinConfigure(GPIO_PA4_T2CCP0);<p>&nbsp; &nbsp; MAP_GPIOPinTypeTimer(GPIO_PORTA_BASE, GPIO_PIN_4);<p>&nbsp; &nbsp; MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);<p>&nbsp; &nbsp; while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_TIMER2)))<p>&nbsp; &nbsp; {<p>&nbsp; &nbsp; }<p><br/><p>&nbsp; &nbsp; &nbsp;MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);<p>&nbsp; &nbsp; while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_TIMER1)))<p>&nbsp; &nbsp; {<p>&nbsp; &nbsp; }<p><br/><p>&nbsp; &nbsp; MAP_TimerConfigure(TIMER2_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME_UP);<p>&nbsp; &nbsp; MAP_TimerIntEnable(TIMER2_BASE, TIMER_CAPA_EVENT);<p>&nbsp; &nbsp; MAP_TimerControlEvent(TIMER2_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);<p><br/><p><br/><p>&nbsp; &nbsp; MAP_TimerConfigure(TIMER1_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC);<p>&nbsp; &nbsp; MAP_TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);<p><br/><p>&nbsp; &nbsp; /* Since the 16-bit timer can count only 65536 value, we use the pre<p>&nbsp; &nbsp; &nbsp;* scaler of 256 to divide down the count rate by 256. Thus the actual<p>&nbsp; &nbsp; &nbsp;* count load is16e6/256 = 62500. Now when to count at 0.1 sec the<p>&nbsp; &nbsp; &nbsp;* load value in the timer would be 62500 * 0.1 =6250. */<p>&nbsp; &nbsp; MAP_TimerPrescaleSet(TIMER1_BASE, TIMER_A, 255);<p>&nbsp; &nbsp; MAP_TimerLoadSet(TIMER1_BASE, TIMER_A, 625);//10ms<p>&nbsp; &nbsp; /* Enable Timer Interrupt */<p>&nbsp; &nbsp; MAP_IntEnable(INT_TIMER2A);<p><br/><p>&nbsp; &nbsp; MAP_IntEnable(INT_TIMER1A);<p><br/><p>&nbsp; &nbsp; /* Enable the timer count */<p>&nbsp; &nbsp; MAP_TimerEnable(TIMER2_BASE, TIMER_A);<p><br/><p>&nbsp; &nbsp; MAP_TimerEnable(TIMER1_BASE, TIMER_A);<p><br/><p><br/><p>}<p>/* (C) COPYRIGHT 2018 DY EleTe *END OF FILE/<p><br/> 

讯享网
小讯
上一篇 2025-06-05 11:24
下一篇 2025-05-15 18:49

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/205329.html