步进电机 插补算法stm.docx
《步进电机 插补算法stm.docx》由会员分享,可在线阅读,更多相关《步进电机 插补算法stm.docx(8页珍藏版)》请在冰点文库上搜索。
步进电机插补算法stm
#include""
#include""
#include""
#include<>
#include""
#include""
#include""
#include<>
voidRCC_Configuration(void);
voidGPIO_Configuration(void);
voidNVIC_Configuration(void);
voidTIM_Configuration(void);
voidUSART_Configuration(void);
intfputc(intch,FILE*f);
intfgetc(FILE*f);
floatMx=,My=;*Thisfileprovidestemplateforallexceptionshandlerand
*peripheralsinterruptserviceroutine.
******************************************************************************
*@copy
*
*THEPRESENTFIRMWAREWHICHISFORGUIDANCEONLYAIMSATPROVIDINGCUSTOMERS
*WITHCODINGINFORMATIONREGARDINGTHEIRPRODUCTSINORDERFORTHEMTOSAVE
*TIME.ASARESULT,STMICROELECTRONICSSHALLNOTBEHELDLIABLEFORANY
*DIRECT,INDIRECTORCONSEQUENTIALDAMAGESWITHRESPECTTOANYCLAIMSARISING
*FROMTHECONTENTOFSUCHFIRMWAREAND/ORTHEUSEMADEBYCUSTOMERSOFTHE
*CODINGINFORMATIONCONTAINEDHEREININCONNECTIONWITHTHEIRPRODUCTS.
*
*
©COPYRIGHT2009STMicroelectronics
*/
/*Includes------------------------------------------------------------------*/
#include""
#include""
#include""
#include""
#include""
#include""
#include<>
/**@addtogroupTemplate_Project
*@{
*/
/*Privatetypedef-----------------------------------------------------------*/
/*Privatedefine------------------------------------------------------------*/
/*Privatemacro-------------------------------------------------------------*/
/*Privatevariables---------------------------------------------------------*/
/*Privatefunctionprototypes-----------------------------------------------*/
/*Privatefunctions---------------------------------------------------------*/
/******************************************************************************/
/*Cortex-M3ProcessorExceptionsHandlers*/
/******************************************************************************/
/**
*@briefThisfunctionhandlesNMIexception.
*@paramNone
*@retval:
None
*/
voidNMI_Handler(void)
{
}
/**
*@briefThisfunctionhandlesHardFaultexception.
*@paramNone
*@retval:
None
*/
voidHardFault_Handler(void)
{
/*GotoinfiniteloopwhenHardFaultexceptionoccurs*/
*@paramNone
*@retval:
None
*/
voidMemManage_Handler(void)
{
/*GotoinfiniteloopwhenMemoryManageexceptionoccurs*/
while
(1)
{
}
}
/**
*@briefThisfunctionhandlesBusFaultexception.
*@paramNone
*@retval:
None
*/
voidBusFault_Handler(void)
{
/*GotoinfiniteloopwhenBusFaultexceptionoccurs*/
while
(1)
{
}
}
/**
*@briefThisfunctionhandlesUsageFaultexception.
*@paramNone
*@retval:
None
*/
voidUsageFault_Handler(void)
{
/*GotoinfiniteloopwhenUsageFaultexceptionoccurs*/
while
(1)
{
}
}
/**
*@briefThisfunctionhandlesSVCallexception.
*@paramNone
*@retval:
None
*/
voidSVC_Handler(void)
{
}
/**
*@briefThisfunctionhandlesDebugMonitorexception.
*@paramNone
*@retval:
None
*/
voidDebugMon_Handler(void)
{
}
/**
*@briefThisfunctionhandlesPendSVCexception.
*@paramNone
*@retval:
None
*/
voidPendSV_Handler(void)
{
}
/**
*@briefThisfunctionhandlesSysTickHandler.
*@paramNone
*@retval:
None
*/
externvoidTimingDelay_Decrement(void);
voidSysTick_Handler(void)
{
}
/******************************************************************************/
/*STM32F10xPeripheralsInterruptHandlers*/
/*AddheretheInterruptHandlerfortheusedperipheral(s)(PPP),forthe*/
/*availableperipheralinterrupthandler'snamepleaserefertothestartup*/
/*file.*/
/******************************************************************************/
/**
*@briefThisfunctionhandlesPPPinterruptrequest.
*@paramNone
*@retval:
None
*/
/*voidPPP_IRQHandler(void)
{
}*/
/**
*@}
*/
/*******************(C)COPYRIGHT2009STMicroelectronics*****ENDOFFILE****/
voidDMA1_Channel4_IRQHandler(void)
{
}
externintcounter;
externdoubletime;
externinta;
externintnumx,numy,a,tx,ty;
voidTIM2_IRQHandler(void)//catchx
{
if(TIM_GetITStatus(TIM2,TIM_IT_CC3)==SET)
{
TIM_Cmd(TIM3,DISABLE);//X
//numx++;//走的步数
tx=0;
TIM_ClearITPendingBit(TIM2,TIM_IT_CC3);
}
if(TIM_GetITStatus(TIM2,TIM_IT_CC4)==SET)
{
TIM_Cmd(TIM4,DISABLE);//y
//numy++;//走的步数
ty=0;
TIM_ClearITPendingBit(TIM2,TIM_IT_CC4);
}
}
voidTIM6_IRQHandler(void)
{
if(TIM_GetITStatus(TIM6,TIM_IT_Update)==SET)
{
a++;
//counter=TIM_GetCounter(TIM6);
//TIM_Cmd(TIM6,DISABLE);
//time=a*65536/+counter/;
//printf("%d\n",a);
//printf("%d\n",counter);
//printf("%fus\n",time);
TIM_ClearITPendingBit(TIM6,TIM_FLAG_Update);
}
}