本帖最后由 小雪88 于 2015-6-11 09:05 编辑
DSP菜鸟上路,求各位大神指点。我用的芯片是28069.在DSP芯片中所有的初始化都是一样的吗?在一个工程里面,所有的时钟是不是都应该和系统时钟保持一致?
ADC转化时如果用软件的方式触发,是直接将AdcRegs.ADCSOCFRC1.all对应的位置一就可以开始转化了吗?
附上我的AD采样代码,请各位大神指点。
//ADC初始化
InitAdc();
EALLOW;
AdcRegs.ADCCTL2.bit.ADCNONOVERLAP = 1; //Enable non-overlap mode
AdcRegs.ADCCTL1.bit.TEMPCONV = 0; //Connect channel A5 internally to the temperature sensor
AdcRegs.ADCSOC0CTL.bit.CHSEL = 8; //Set SOC0 channel select to ADCINA5
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; //Set SOC0 acquisition period to 26 ADCCLK
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0;
AdcRegs.INTSEL1N2.bit.INT1SEL = 0; //Connect ADCINT1 to EOC0
AdcRegs.INTSEL1N2.bit.INT1E = 1; //Enable ADCINT1
AdcRegs.INTSEL1N2.bit.INT1CONT = 1;
AdcRegs.ADCINTSOCSEL1.bit.SOC0 = 1;
// Set the flash OTP wait-states to minimum. This is important
// for the performance of the compensation function.
FlashRegs.FOTPWAIT.bit.OTPWAIT = 1;
void InitAdc(void)
{
extern void DSP28x_usDelay(Uint32 Count);
EALLOW;
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 0;
(*Device_cal)();
EDIS;
EALLOW;
AdcRegs.ADCCTL1.bit.ADCBGPWD = 1; // Power ADC BG
AdcRegs.ADCCTL1.bit.ADCREFPWD = 1; // Power reference
AdcRegs.ADCCTL1.bit.ADCPWDN = 1; // Power ADC
AdcRegs.ADCCTL1.bit.ADCENABLE = 1; // Enable ADC
AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; // Select interal BG
EDIS;
DELAY_US(ADC_usDELAY); // Delay before converting ADC channels
EALLOW;
AdcRegs.ADCCTL2.bit.CLKDIV2EN = 0;
EDIS;
DELAY_US(ADC_usDELAY); // Delay before converting ADC channels
}
for(;;)
{
AdcRegs.ADCSOCFRC1.all = 0x01;
while(AdcRegs.ADCINT标志寄存器.bit.ADCINT1 == 0){} //Wait for ADCINT1
AdcRegs.ADCINT标志寄存器CLR.bit.ADCINT1 = 1; //Clear ADCINT1
//Get temp sensor sample result from SOC1
CH1 = (AdcResult.ADCRESULT0>>4);
SciaRegs.SCIRXBUF.all=CH1;
// msg = "\r\nEnter a character: \0";
// scia_msg(msg);
// Wait for inc character
while(SciaRegs.SCIFFRX.bit.RXFFST !=1) { } // wait for XRDY =1 for empty state
// Get character
ReceivedChar = SciaRegs.SCIRXBUF.all;
// Echo character back
// msg = " You sent: \0";
// scia_msg(msg);
scia_xmit(ReceivedChar);
}
|