資源簡介
基于直流電機的 DSP 雙閉環控制系統代碼,使用過的一些代碼資料,盡管有些編程相關的邏輯規則有些問題,但是作為參考與提升,這是有意義的!

代碼片段和文件信息
/****************************************************************************
FILE:??DSP28_CpuTimers.c
title:??DSP28?CPU?32-bit?Timers?Initialization?&?Support?Functions.
*****************************************************************************
??Ver?|?dd?mmm?yyyy?|???Who??|?Description?of?changes
======|=============|========|===============================================
V0106S|?11?Oct?2011?|?Z.H.C.?|
****************************************************************************/
#include?“DSP28_Device.h“
struct?CPUTIMER_VARS?CpuTimer0;
struct?CPUTIMER_VARS?CpuTimer1;
struct?CPUTIMER_VARS?CpuTimer2;
//---------------------------------------------------------------------------
//?InitCpuTimers:?
//---------------------------------------------------------------------------
//?This?function?initializes?all?three?CPU?timers?to?a?known?state.
//
void?InitCpuTimers(void)
{
//?Initialize?address?pointers?to?respective?timer?registers:
CpuTimer0.RegsAddr?=?&CpuTimer0Regs;
CpuTimer1.RegsAddr?=?&CpuTimer1Regs;
CpuTimer2.RegsAddr?=?&CpuTimer2Regs;
//?Initialize?timer?period?to?maximum:
CpuTimer0Regs.PRD.all??=?0xFFFFFFFF;
CpuTimer1Regs.PRD.all??=?0xFFFFFFFF;
CpuTimer2Regs.PRD.all??=?0xFFFFFFFF;
//?Initialize?pre-scale?counter?to?divide?by?1?(SYSCLKOUT):
CpuTimer0Regs.TPR.all??=?0;
CpuTimer0Regs.TPRH.all?=?0;
//?Make?sure?timers?are?stopped:
CpuTimer0Regs.TCR.bit.TSS?=?1;?????????????
CpuTimer1Regs.TCR.bit.TSS?=?1;?????????????
CpuTimer2Regs.TCR.bit.TSS?=?1;?????????????
//?Reload?all?counter?registers?with?period?values:
CpuTimer0Regs.TCR.bit.TRB?=?1;?????????????
CpuTimer1Regs.TCR.bit.TRB?=?1;?????????????
CpuTimer2Regs.TCR.bit.TRB?=?1;?????????????
//?Reset?interrupt?counters:
CpuTimer0.InterruptCount?=?0;
CpuTimer1.InterruptCount?=?0;
CpuTimer2.InterruptCount?=?0;
}
//---------------------------------------------------------------------------
//?ConfigCpuTimer:?
//---------------------------------------------------------------------------
//?This?function?initializes?the?selected?timer?to?the?period?specified
//?by?the?“Freq“?and?“Period“?parameters.?The?“Freq“?is?entered?as?“MHz“
//?and?the?period?in?“uSeconds“.?The?timer?is?held?in?the?stopped?state
//?after?configuration.
//
void?ConfigCpuTimer(struct?CPUTIMER_VARS?*Timer?float?Freq?float?Period)
{
Uint32? temp;
//?Initialize?timer?period:
Timer->CPUFreqInMHz?=?Freq;
Timer->PeriodInUSec?=?Period;
temp?=?(long)?(Freq?*?Period);
Timer->RegsAddr->PRD.all?=?temp;
//?Set?pre-scale?counter?to?divide?by?1?(SYSCLKOUT):
Timer->RegsAddr->TPR.all??=?0;
Timer->RegsAddr->TPRH.all??=?0;
//?Initialize?timer?control?register:
Timer->RegsAddr->TCR.bit.POL?=?0;??????//?0?=?Pulse?Low
Timer->RegsAddr->TCR.bit.TOG?= 0;?????//?0?=?No?Toggle?POL?bit?defines?action
Timer->RegsAddr->TCR.bit.TSS?=?1;??????//?1?=?Stop?timer?0?=?Start/Restart?Timer?
Timer->RegsAddr->TCR.bit.TRB?=
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-01-26?09:01??MDC_BDC_Demo\
?????文件????????1663??2013-04-26?11:30??MDC_BDC_Demo\CodeStartBranch.asm
?????文件????????6469??2013-04-26?11:30??MDC_BDC_Demo\DSP28_Adc.h
?????文件????????1664??2013-04-26?11:30??MDC_BDC_Demo\DSP28_Adc_BDC.C
?????文件????????3604??2013-04-26?11:30??MDC_BDC_Demo\DSP28_CpuTimers.c
?????文件????????5211??2013-04-26?11:30??MDC_BDC_Demo\DSP28_CpuTimers.h
?????文件???????24639??2013-04-26?11:30??MDC_BDC_Demo\DSP28_DefaultIsr.c
?????文件????????4797??2013-04-26?11:30??MDC_BDC_Demo\DSP28_DefaultIsr.h
?????文件????????2447??2013-04-26?11:30??MDC_BDC_Demo\DSP28_DevEmu.h
?????文件????????4025??2013-04-26?11:30??MDC_BDC_Demo\DSP28_Device.h
?????文件?????????955??2013-04-26?11:30??MDC_BDC_Demo\DSP28_ECan.c
?????文件???????46740??2013-04-26?11:30??MDC_BDC_Demo\DSP28_ECan.h
?????文件???????20967??2013-04-26?11:30??MDC_BDC_Demo\DSP28_Ev.h
?????文件????????2128??2013-04-26?11:30??MDC_BDC_Demo\DSP28_Ev_BDC.C
?????文件????????1425??2013-04-26?11:30??MDC_BDC_Demo\DSP28_GlobalPrototypes.h
?????文件????????2796??2013-04-26?11:30??MDC_BDC_Demo\DSP28_GlobalVariableDefs.c
?????文件????????5816??2013-09-23?10:23??MDC_BDC_Demo\DSP28_Gpio.c
?????文件???????29551??2013-04-26?11:30??MDC_BDC_Demo\DSP28_Gpio.h
?????文件????????1714??2013-04-26?11:30??MDC_BDC_Demo\DSP28_InitPeripherals.c
?????文件?????????982??2013-04-26?11:30??MDC_BDC_Demo\DSP28_Mcbsp.c
?????文件???????34739??2013-04-26?11:30??MDC_BDC_Demo\DSP28_Mcbsp.h
?????文件????????1851??2013-04-26?11:30??MDC_BDC_Demo\DSP28_PieCtrl.c
?????文件????????5972??2013-04-26?11:30??MDC_BDC_Demo\DSP28_PieCtrl.h
?????文件????????5442??2013-04-26?11:30??MDC_BDC_Demo\DSP28_PieVect.c
?????文件????????6474??2013-04-26?11:30??MDC_BDC_Demo\DSP28_PieVect.h
?????文件????????3882??2013-04-26?11:30??MDC_BDC_Demo\DSP28_Sci.c
?????文件????????8341??2013-04-26?11:30??MDC_BDC_Demo\DSP28_Sci.h
?????文件????????1793??2013-04-26?11:30??MDC_BDC_Demo\DSP28_Spi.c
?????文件????????6237??2013-04-26?11:30??MDC_BDC_Demo\DSP28_Spi.h
?????文件????????2545??2013-04-26?11:30??MDC_BDC_Demo\DSP28_SysCtrl.c
?????文件????????9979??2013-04-26?11:30??MDC_BDC_Demo\DSP28_SysCtrl.h
............此處省略40個文件信息
- 上一篇:1602LCD顯示仿手機鍵盤按鍵字符
- 下一篇:ASIFT算法實現
評論
共有 條評論