资源简介
文档包括DSP28335的初始化,有刷电机的控制,驱动,采用续流斩波的控制方法。
代码片段和文件信息
//该文件是初始化ADC模块和读取采样值模块,InitAdc()和F2833x_ADC_VR_init()函数初始化ADC模块,
//F2833x_ADC_VR_read()是读取ADC转换值
#include “DSP2833x_Device.h“ // DSP2833x Headerfile Include File
#define ADC_usDELAY 5000L
//---------------------------------------------------------------------------
// InitAdc:
//---------------------------------------------------------------------------
// This function initializes ADC to a known state.
//
void InitAdc(void)
{
extern void DSP28x_usDelay(Uint32 Count);
// *IMPORTANT*
// The ADC_cal function which copies the ADC calibration values from TI reserved
// OTP into the ADCREFSEL and ADCOFFTRIM registers occurs automatically in the
// Boot ROM. If the boot ROM code is bypassed during the debug process the
// following function MUST be called for the ADC to function according
// to specification. The clocks to the ADC MUST be enabled before calling this
// function.
// See the device data manual and/or the ADC Reference
// Manual for more information.
EALLOW;
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;
ADC_cal();
EDIS;
// To powerup the ADC the ADCENCLK bit should be set first to enable
// clocks followed by powering up the bandgap reference circuitry and ADC core.
// Before the first conversion is performed a 5ms delay must be observed
// after power up to give all analog circuits time to power up and settle
// Please note that for the delay function below to operate correctly the
// CPU_RATE define statement in the DSP2833x_Examples.h file must
// contain the correct CPU clock period in nanoseconds.
AdcRegs.ADCTRL3.all = 0x00E0; // Power up bandgap/reference/ADC circuits
// DELAY_US(ADC_usDELAY); // Delay before converting ADC channels
asm(“ RPT #250 || NOP“);
}
void F2833x_ADC_VR_init(ILEG2DCBUSMEAS *p)
{
//
AdcRegs.ADCTRL3.bit.SMODE_SEL = 0x01; //simultaneous sampling mode
AdcRegs.ADCTRL3.bit.ADCCLKPS = 0x03; //HSPCLK/[6*(ADCTRL1[7] + 1)]
AdcRegs.ADCTRL1.bit.SEQ_CASC = 0x01; //Cascaded mode
AdcRegs.ADCTRL1.bit.CPS = 0x00; //ADCCLK = Fclk/1
AdcRegs.ADCTRL1.bit.ACQ_PS = 0x01; //2 ADCCLK
AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 0x01; //EPWM soc signal allow
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1; // Enable SEQ1 interrupt (every EOS)
AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 0x05; //5 double conv‘s
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x00;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x01;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0x02;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x03;
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x04;
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x05;
}
void F2833x_ADC_VR_read(ILEG2DCBUSMEAS *p)
{
int16 DatAD;
//Motor 1 U phase low gain
DatAD = AdcRegs.ADCRESULT0 >> 4; // ADC转换结果右移四位,低四位为保留位
p->ImeasAU1 = (int16)(DatAD-p->ImeasAU1Offset); //(int32)p->ImeasAGain采样结果减去偏置值
if(p->ImeasAU1 > p->iMaxLowGain)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7314 2013-04-21 10:59 brushDC\28335_RAM_lnk.cmd
文件 0 2013-04-24 21:10 brushDC\ADC
文件 0 2013-04-24 21:10 brushDC\ADC_MIRROR
文件 42216 2013-04-21 10:59 brushDC\algorithm.lib
文件 0 2013-04-24 21:10 brushDC\BEGIN_FLASH
文件 0 2013-04-24 21:10 brushDC\BEGIN_M0
文件 0 2013-04-24 21:08 brushDC\build
文件 3742 2016-01-02 10:58 brushDC\cc_build_Debug.log
文件 2913 2013-04-21 10:59 brushDC\control_algorithm.h
文件 0 2013-04-24 21:10 brushDC\CPU_TIMER0
文件 0 2013-04-24 21:10 brushDC\CPU_TIMER1
文件 0 2013-04-24 21:10 brushDC\CPU_TIMER2
文件 0 2013-04-24 21:10 brushDC\CSM
文件 0 2013-04-24 21:10 brushDC\CSM_PWL
文件 0 2013-04-24 21:10 brushDC\CSM_RSVD
文件 59 2013-04-21 10:59 brushDC\Debug\build.bat
文件 136 2013-04-21 10:59 brushDC\Debug\buildhex.cmd
文件 120307 2013-04-21 10:59 brushDC\Debug\DSP2833x.Spi.obj
文件 120821 2016-01-02 10:58 brushDC\Debug\DSP2833x_Adc.obj
文件 1112 2016-01-02 10:58 brushDC\Debug\DSP2833x_ADC_cal.obj
文件 1391 2016-01-02 10:58 brushDC\Debug\DSP2833x_CodeStartBranch.obj
文件 159271 2016-01-02 10:58 brushDC\Debug\DSP2833x_DefaultIsr.obj
文件 129524 2013-04-21 10:59 brushDC\Debug\DSP2833x_ECan.obj
文件 119728 2016-01-02 10:58 brushDC\Debug\DSP2833x_ECap.obj
文件 128041 2016-01-02 10:58 brushDC\Debug\DSP2833x_EPwm.obj
文件 119853 2016-01-02 10:58 brushDC\Debug\DSP2833x_EQep.obj
文件 128531 2016-01-02 10:58 brushDC\Debug\DSP2833x_GlobalVariableDefs.obj
文件 119291 2016-01-02 10:58 brushDC\Debug\DSP2833x_GPIO.obj
文件 118614 2016-01-02 10:58 brushDC\Debug\DSP2833x_MemCopy.obj
文件 118934 2016-01-02 10:58 brushDC\Debug\DSP2833x_PieCtrl.obj
............此处省略132个文件信息
评论
共有 条评论