請各位幫我看看為什麼我的graph觀察的波行不管怎麼設置都是錯誤的
我用訊號產生器產生一個0~1.5V左右的100HZ的弦波,但CCS上顯示的都是錯誤波形
是哪裡設置錯了嗎?
我的斷點設在這
按網上的各種設置方法設了都沒用
附上代碼
#include <math.h>
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz
#define ADC_CKPS 0x1 // ADC module clock = HSPCLK/2*ADC_CKPS = 25.0MHz/(1*2) = 12.5MHz
interrupt void cpu_timer0_isr(void);//定時采樣時間20kHz
void AD_read();//采樣值讀取
void InitAdc_configuration();
/*********采樣參數************/
float Iload_U=0.0,Iload_V=0.0,Iload_W=0.0;
float If_U=0.0,If_V=0.0,If_W=0.0;
float Vs_U=0.0,Vs_V=0.0,Vs_W=0.0;
float IC_U=0.0,IC_V=0.0,IC_W=0.0;
float ss=0.0,cc=0.0;
float IC_1=0.0,IC_2=0.0,IC_3=0.0;
float Vdc_temp=0.0,Vdc=0.0,Vdc1=0.0;
float Vx,Verror0,Verror;
void main(void)
{
InitSysCtrl();
InitCpuTimers();
#if (CPU_FRQ_150MHZ)
// Configure CPU-Timer 0,
//T=50us,fs=20k,
//CPU Timer0定時器週期寄存器值為7500
ConfigCpuTimer(&CpuTimer0, 150, 50);
#endif
#if (CPU_FRQ_100MHZ)
ConfigCpuTimer(&CpuTimer0, 100, 50);
#endif
InitAdc();
//Configure adc
InitAdc_configuration();
DINT;//禁用全局中斷
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.EPWM1_INT = &EPWM1_INT_ISR;
EDIS;
InitEPwm();
IER |= M_INT3;
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;//使能PIE級中斷,即Epwm1的事件中斷
EALLOW;
PieVectTable.TINT0=&cpu_timer0_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
// Enable Timer0 INT1 which is connected to Timer0 INT:
IER |= M_INT1;
// Enable CPU INT3 which is connected to TZ INT:
IER |= M_INT2;
// Enable TZ INTn in the PIE: Group 2 interrupt 1-3
//Rewrite by CCL Enable INT0
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
EnableInterrupts();
CpuTimer0Regs.TCR.bit.TSS=0;//start cputimer0
EINT;
ERTM;
for(;;)
{
;
}
}
void InitAdc_configuration()
{
AdcRegs.ADCTRL1.bit.ACQ_PS=15;
AdcRegs.ADCTRL1.bit.CONT_RUN=0;
AdcRegs.ADCTRL1.bit.SEQ_OVRD=0;
AdcRegs.ADCTRL1.bit.SEQ_CASC=1;
AdcRegs.ADCTRL1.bit.CPS=0;
AdcRegs.ADCTRL3.bit.ADCCLKPS=ADC_CKPS ;
AdcRegs.ADCTRL3.bit.SMODE_SEL=0;
AdcRegs.ADCMAXCONV.bit.MAX_CONV1=9;
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x8;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x9;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0xA;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x0;
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x1;
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x2;
AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 0x3;
AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 0x4;
AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 0x5;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCST.bit.INT_SEQ2_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=0;
AdcRegs.ADCTRL2.bit.RST_SEQ2=0;
AdcRegs.ADCTRL2.all = 0x2000;
void AD_read()
{
If_U=(1.702-(AdcRegs.ADCRESULT3>>4)*0.0007326)*53.1;
If_V=(1.689-(AdcRegs.ADCRESULT4>>4)*0.0007326)*53.5;
If_W=(1.682-(AdcRegs.ADCRESULT5>>4)*0.0007326)*52;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1; }
//
interrupt void cpu_timer0_isr(void)
{
IFR=0x0000;
PieCtrlRegs.PIEIFR3.all=0;
PieCtrlRegs.PIEACK.all=0xffff;
AD_read();
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
EINT;
}
user5086318:
請各位幫我看看為什麼我的graph觀察的波行不管怎麼設置都是錯誤的我用訊號產生器產生一個0~1.5V左右的100HZ的弦波,但CCS上顯示的都是錯誤波行是哪裡設置錯了嗎?我的斷點設在這
併按網上的設置方法設了都沒用
附上代碼
#include <math.h>#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File#include "DSP2833x_Examples.h" // DSP2833x Examples Include File#define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz#define ADC_CKPS 0x1 // ADC module clock = HSPCLK/2*ADC_CKPS = 25.0MHz/(1*2) = 12.5MHzinterrupt void cpu_timer0_isr(void);//定時采樣時間20kHzvoid AD_read();//采樣值讀取void InitAdc_configuration();/*********采樣參數************/float Iload_U=0.0,Iload_V=0.0,Iload_W=0.0;float If_U=0.0,If_V=0.0,If_W=0.0;float Vs_U=0.0,Vs_V=0.0,Vs_W=0.0;float IC_U=0.0,IC_V=0.0,IC_W=0.0;float ss=0.0,cc=0.0;float IC_1=0.0,IC_2=0.0,IC_3=0.0;float Vdc_temp=0.0,Vdc=0.0,Vdc1=0.0;float Vx,Verror0,Verror;void main(void){ InitSysCtrl(); InitCpuTimers();#if (CPU_FRQ_150MHZ)// Configure CPU-Timer 0,//T=50us,fs=20k,//CPU Timer0定時器週期寄存器值為7500ConfigCpuTimer(&CpuTimer0, 150, 50);#endif#if (CPU_FRQ_100MHZ)ConfigCpuTimer(&CpuTimer0, 100, 50);#endif InitAdc(); //Configure adc InitAdc_configuration(); DINT;//禁用全局中斷 InitPieCtrl(); IER = 0x0000; IFR = 0x0000; InitPieVectTable(); EALLOW; PieVectTable.EPWM1_INT = &EPWM1_INT_ISR; EDIS; InitEPwm(); IER |= M_INT3; PieCtrlRegs.PIEIER3.bit.INTx1 = 1;//使能PIE級中斷,即Epwm1的事件中斷 EALLOW; PieVectTable.TINT0=&cpu_timer0_isr; EDIS; // This is needed to disable write to EALLOW protected registers // Enable Timer0 INT1 which is connected to Timer0 INT: IER |= M_INT1; // Enable CPU INT3 which is connected to TZ INT: IER |= M_INT2; // Enable TZ INTn in the PIE: Group 2 interrupt 1-3 //Rewrite by CCL Enable INT0 PieCtrlRegs.PIEIER1.bit.INTx7 = 1; EnableInterrupts(); CpuTimer0Regs.TCR.bit.TSS=0;//start cputimer0 EINT; ERTM; for(;;) { ; }} void InitAdc_configuration() { AdcRegs.ADCTRL1.bit.ACQ_PS=15; AdcRegs.ADCTRL1.bit.CONT_RUN=0; AdcRegs.ADCTRL1.bit.SEQ_OVRD=0; AdcRegs.ADCTRL1.bit.SEQ_CASC=1; AdcRegs.ADCTRL1.bit.CPS=0; AdcRegs.ADCTRL3.bit.ADCCLKPS=ADC_CKPS ; AdcRegs.ADCTRL3.bit.SMODE_SEL=0; AdcRegs.ADCMAXCONV.bit.MAX_CONV1=9; AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x8; AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x9; AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0xA; AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x0; AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x1; AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x2; AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 0x3; AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 0x4; AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 0x5; AdcRegs.ADCST.bit.INT_SEQ1_CLR=1; AdcRegs.ADCST.bit.INT_SEQ2_CLR=1; AdcRegs.ADCTRL2.bit.RST_SEQ1=1; AdcRegs.ADCTRL2.bit.RST_SEQ1=0; AdcRegs.ADCTRL2.bit.RST_SEQ2=0; AdcRegs.ADCTRL2.all = 0x2000; void AD_read() { If_U=(1.702-(AdcRegs.ADCRESULT3>>4)*0.0007326)*53.1; If_V=(1.689-(AdcRegs.ADCRESULT4>>4)*0.0007326)*53.5; If_W=(1.682-(AdcRegs.ADCRESULT5>>4)*0.0007326)*52; AdcRegs.ADCST.bit.INT_SEQ1_CLR=1; AdcRegs.ADCTRL2.bit.RST_SEQ1=1; AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1; }// interrupt void cpu_timer0_isr(void) { IFR=0x0000; PieCtrlRegs.PIEIFR3.all=0; PieCtrlRegs.PIEACK.all=0xffff; AD_read(); PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; EINT; }
請各位幫我看看為什麼我的graph觀察的波行不管怎麼設置都是錯誤的
我用訊號產生器產生一個0~1.5V左右的100HZ的弦波,但CCS上顯示的都是錯誤波形
是哪裡設置錯了嗎?
我的斷點設在這
按網上的各種設置方法設了都沒用
附上代碼
#include <math.h>
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz
#define ADC_CKPS 0x1 // ADC module clock = HSPCLK/2*ADC_CKPS = 25.0MHz/(1*2) = 12.5MHz
interrupt void cpu_timer0_isr(void);//定時采樣時間20kHz
void AD_read();//采樣值讀取
void InitAdc_configuration();
/*********采樣參數************/
float Iload_U=0.0,Iload_V=0.0,Iload_W=0.0;
float If_U=0.0,If_V=0.0,If_W=0.0;
float Vs_U=0.0,Vs_V=0.0,Vs_W=0.0;
float IC_U=0.0,IC_V=0.0,IC_W=0.0;
float ss=0.0,cc=0.0;
float IC_1=0.0,IC_2=0.0,IC_3=0.0;
float Vdc_temp=0.0,Vdc=0.0,Vdc1=0.0;
float Vx,Verror0,Verror;
void main(void)
{
InitSysCtrl();
InitCpuTimers();
#if (CPU_FRQ_150MHZ)
// Configure CPU-Timer 0,
//T=50us,fs=20k,
//CPU Timer0定時器週期寄存器值為7500
ConfigCpuTimer(&CpuTimer0, 150, 50);
#endif
#if (CPU_FRQ_100MHZ)
ConfigCpuTimer(&CpuTimer0, 100, 50);
#endif
InitAdc();
//Configure adc
InitAdc_configuration();
DINT;//禁用全局中斷
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.EPWM1_INT = &EPWM1_INT_ISR;
EDIS;
InitEPwm();
IER |= M_INT3;
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;//使能PIE級中斷,即Epwm1的事件中斷
EALLOW;
PieVectTable.TINT0=&cpu_timer0_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
// Enable Timer0 INT1 which is connected to Timer0 INT:
IER |= M_INT1;
// Enable CPU INT3 which is connected to TZ INT:
IER |= M_INT2;
// Enable TZ INTn in the PIE: Group 2 interrupt 1-3
//Rewrite by CCL Enable INT0
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
EnableInterrupts();
CpuTimer0Regs.TCR.bit.TSS=0;//start cputimer0
EINT;
ERTM;
for(;;)
{
;
}
}
void InitAdc_configuration()
{
AdcRegs.ADCTRL1.bit.ACQ_PS=15;
AdcRegs.ADCTRL1.bit.CONT_RUN=0;
AdcRegs.ADCTRL1.bit.SEQ_OVRD=0;
AdcRegs.ADCTRL1.bit.SEQ_CASC=1;
AdcRegs.ADCTRL1.bit.CPS=0;
AdcRegs.ADCTRL3.bit.ADCCLKPS=ADC_CKPS ;
AdcRegs.ADCTRL3.bit.SMODE_SEL=0;
AdcRegs.ADCMAXCONV.bit.MAX_CONV1=9;
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x8;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x9;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0xA;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x0;
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x1;
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x2;
AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 0x3;
AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 0x4;
AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 0x5;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCST.bit.INT_SEQ2_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=0;
AdcRegs.ADCTRL2.bit.RST_SEQ2=0;
AdcRegs.ADCTRL2.all = 0x2000;
void AD_read()
{
If_U=(1.702-(AdcRegs.ADCRESULT3>>4)*0.0007326)*53.1;
If_V=(1.689-(AdcRegs.ADCRESULT4>>4)*0.0007326)*53.5;
If_W=(1.682-(AdcRegs.ADCRESULT5>>4)*0.0007326)*52;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1; }
//
interrupt void cpu_timer0_isr(void)
{
IFR=0x0000;
PieCtrlRegs.PIEIFR3.all=0;
PieCtrlRegs.PIEACK.all=0xffff;
AD_read();
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
EINT;
}
user5086318:
請各位幫我看看為什麼我的graph觀察的波行不管怎麼設置都是錯誤的
我用訊號產生器產生一個0~1.5V左右的100HZ的弦波,但CCS上顯示的都是錯誤波形
是哪裡設置錯了嗎?
我的斷點設在這
按網上的各種設置方法設了都沒用
附上代碼
#include <math.h>
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz
#define ADC_CKPS 0x1 // ADC module clock = HSPCLK/2*ADC_CKPS = 25.0MHz/(1*2) = 12.5MHz
interrupt void cpu_timer0_isr(void);//定時采樣時間20kHz
void AD_read();//采樣值讀取
void InitAdc_configuration();
/*********采樣參數************/
float Iload_U=0.0,Iload_V=0.0,Iload_W=0.0;
float If_U=0.0,If_V=0.0,If_W=0.0;
float Vs_U=0.0,Vs_V=0.0,Vs_W=0.0;
float IC_U=0.0,IC_V=0.0,IC_W=0.0;
float ss=0.0,cc=0.0;
float IC_1=0.0,IC_2=0.0,IC_3=0.0;
float Vdc_temp=0.0,Vdc=0.0,Vdc1=0.0;
float Vx,Verror0,Verror;
void main(void)
{
InitSysCtrl();
InitCpuTimers();
#if (CPU_FRQ_150MHZ)
// Configure CPU-Timer 0,
//T=50us,fs=20k,
//CPU Timer0定時器週期寄存器值為7500
ConfigCpuTimer(&CpuTimer0, 150, 50);
#endif
#if (CPU_FRQ_100MHZ)
ConfigCpuTimer(&CpuTimer0, 100, 50);
#endif
InitAdc();
//Configure adc
InitAdc_configuration();
DINT;//禁用全局中斷
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.EPWM1_INT = &EPWM1_INT_ISR;
EDIS;
InitEPwm();
IER |= M_INT3;
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;//使能PIE級中斷,即Epwm1的事件中斷
EALLOW;
PieVectTable.TINT0=&cpu_timer0_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
// Enable Timer0 INT1 which is connected to Timer0 INT:
IER |= M_INT1;
// Enable CPU INT3 which is connected to TZ INT:
IER |= M_INT2;
// Enable TZ INTn in the PIE: Group 2 interrupt 1-3
//Rewrite by CCL Enable INT0
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
EnableInterrupts();
CpuTimer0Regs.TCR.bit.TSS=0;//start cputimer0
EINT;
ERTM;
for(;;)
{
;
}
}
void InitAdc_configuration()
{
AdcRegs.ADCTRL1.bit.ACQ_PS=15;
AdcRegs.ADCTRL1.bit.CONT_RUN=0;
AdcRegs.ADCTRL1.bit.SEQ_OVRD=0;
AdcRegs.ADCTRL1.bit.SEQ_CASC=1;
AdcRegs.ADCTRL1.bit.CPS=0;
AdcRegs.ADCTRL3.bit.ADCCLKPS=ADC_CKPS ;
AdcRegs.ADCTRL3.bit.SMODE_SEL=0;
AdcRegs.ADCMAXCONV.bit.MAX_CONV1=9;
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x8;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x9;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0xA;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x0;
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x1;
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x2;
AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 0x3;
AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 0x4;
AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 0x5;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCST.bit.INT_SEQ2_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=0;
AdcRegs.ADCTRL2.bit.RST_SEQ2=0;
AdcRegs.ADCTRL2.all = 0x2000;
void AD_read()
{
If_U=(1.702-(AdcRegs.ADCRESULT3>>4)*0.0007326)*53.1;
If_V=(1.689-(AdcRegs.ADCRESULT4>>4)*0.0007326)*53.5;
If_W=(1.682-(AdcRegs.ADCRESULT5>>4)*0.0007326)*52;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1; }
//
interrupt void cpu_timer0_isr(void)
{
IFR=0x0000;
PieCtrlRegs.PIEIFR3.all=0;
PieCtrlRegs.PIEACK.all=0xffff;
AD_read();
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
EINT;
}
笨鸟:
回复 user5086318:
我用訊號產生器產生一個0~1.5V左右的100HZ的弦波,但CCS上顯示的都是錯誤波行。
没明白你的描述,讯号产生器是外部的吗?你意思是外部讯号产生器产生一个0~1.5V左右的100HZ的波形,你用MCU的ad读取,然后想在graph上观察读到的值,对否?
請各位幫我看看為什麼我的graph觀察的波行不管怎麼設置都是錯誤的
我用訊號產生器產生一個0~1.5V左右的100HZ的弦波,但CCS上顯示的都是錯誤波形
是哪裡設置錯了嗎?
我的斷點設在這
按網上的各種設置方法設了都沒用
附上代碼
#include <math.h>
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz
#define ADC_CKPS 0x1 // ADC module clock = HSPCLK/2*ADC_CKPS = 25.0MHz/(1*2) = 12.5MHz
interrupt void cpu_timer0_isr(void);//定時采樣時間20kHz
void AD_read();//采樣值讀取
void InitAdc_configuration();
/*********采樣參數************/
float Iload_U=0.0,Iload_V=0.0,Iload_W=0.0;
float If_U=0.0,If_V=0.0,If_W=0.0;
float Vs_U=0.0,Vs_V=0.0,Vs_W=0.0;
float IC_U=0.0,IC_V=0.0,IC_W=0.0;
float ss=0.0,cc=0.0;
float IC_1=0.0,IC_2=0.0,IC_3=0.0;
float Vdc_temp=0.0,Vdc=0.0,Vdc1=0.0;
float Vx,Verror0,Verror;
void main(void)
{
InitSysCtrl();
InitCpuTimers();
#if (CPU_FRQ_150MHZ)
// Configure CPU-Timer 0,
//T=50us,fs=20k,
//CPU Timer0定時器週期寄存器值為7500
ConfigCpuTimer(&CpuTimer0, 150, 50);
#endif
#if (CPU_FRQ_100MHZ)
ConfigCpuTimer(&CpuTimer0, 100, 50);
#endif
InitAdc();
//Configure adc
InitAdc_configuration();
DINT;//禁用全局中斷
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.EPWM1_INT = &EPWM1_INT_ISR;
EDIS;
InitEPwm();
IER |= M_INT3;
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;//使能PIE級中斷,即Epwm1的事件中斷
EALLOW;
PieVectTable.TINT0=&cpu_timer0_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
// Enable Timer0 INT1 which is connected to Timer0 INT:
IER |= M_INT1;
// Enable CPU INT3 which is connected to TZ INT:
IER |= M_INT2;
// Enable TZ INTn in the PIE: Group 2 interrupt 1-3
//Rewrite by CCL Enable INT0
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
EnableInterrupts();
CpuTimer0Regs.TCR.bit.TSS=0;//start cputimer0
EINT;
ERTM;
for(;;)
{
;
}
}
void InitAdc_configuration()
{
AdcRegs.ADCTRL1.bit.ACQ_PS=15;
AdcRegs.ADCTRL1.bit.CONT_RUN=0;
AdcRegs.ADCTRL1.bit.SEQ_OVRD=0;
AdcRegs.ADCTRL1.bit.SEQ_CASC=1;
AdcRegs.ADCTRL1.bit.CPS=0;
AdcRegs.ADCTRL3.bit.ADCCLKPS=ADC_CKPS ;
AdcRegs.ADCTRL3.bit.SMODE_SEL=0;
AdcRegs.ADCMAXCONV.bit.MAX_CONV1=9;
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x8;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x9;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0xA;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x0;
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x1;
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x2;
AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 0x3;
AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 0x4;
AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 0x5;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCST.bit.INT_SEQ2_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=0;
AdcRegs.ADCTRL2.bit.RST_SEQ2=0;
AdcRegs.ADCTRL2.all = 0x2000;
void AD_read()
{
If_U=(1.702-(AdcRegs.ADCRESULT3>>4)*0.0007326)*53.1;
If_V=(1.689-(AdcRegs.ADCRESULT4>>4)*0.0007326)*53.5;
If_W=(1.682-(AdcRegs.ADCRESULT5>>4)*0.0007326)*52;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1; }
//
interrupt void cpu_timer0_isr(void)
{
IFR=0x0000;
PieCtrlRegs.PIEIFR3.all=0;
PieCtrlRegs.PIEACK.all=0xffff;
AD_read();
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
EINT;
}
user5086318:
回复 笨鸟:
是的,敘述不清楚,請見諒。我是想測試用外部訊號產生器產生一個100hz的弦波給adc讀值,然後在ccs的graph上顯示出ad讀到的是否為弦波,謝謝
請各位幫我看看為什麼我的graph觀察的波行不管怎麼設置都是錯誤的
我用訊號產生器產生一個0~1.5V左右的100HZ的弦波,但CCS上顯示的都是錯誤波形
是哪裡設置錯了嗎?
我的斷點設在這
按網上的各種設置方法設了都沒用
附上代碼
#include <math.h>
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz
#define ADC_CKPS 0x1 // ADC module clock = HSPCLK/2*ADC_CKPS = 25.0MHz/(1*2) = 12.5MHz
interrupt void cpu_timer0_isr(void);//定時采樣時間20kHz
void AD_read();//采樣值讀取
void InitAdc_configuration();
/*********采樣參數************/
float Iload_U=0.0,Iload_V=0.0,Iload_W=0.0;
float If_U=0.0,If_V=0.0,If_W=0.0;
float Vs_U=0.0,Vs_V=0.0,Vs_W=0.0;
float IC_U=0.0,IC_V=0.0,IC_W=0.0;
float ss=0.0,cc=0.0;
float IC_1=0.0,IC_2=0.0,IC_3=0.0;
float Vdc_temp=0.0,Vdc=0.0,Vdc1=0.0;
float Vx,Verror0,Verror;
void main(void)
{
InitSysCtrl();
InitCpuTimers();
#if (CPU_FRQ_150MHZ)
// Configure CPU-Timer 0,
//T=50us,fs=20k,
//CPU Timer0定時器週期寄存器值為7500
ConfigCpuTimer(&CpuTimer0, 150, 50);
#endif
#if (CPU_FRQ_100MHZ)
ConfigCpuTimer(&CpuTimer0, 100, 50);
#endif
InitAdc();
//Configure adc
InitAdc_configuration();
DINT;//禁用全局中斷
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.EPWM1_INT = &EPWM1_INT_ISR;
EDIS;
InitEPwm();
IER |= M_INT3;
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;//使能PIE級中斷,即Epwm1的事件中斷
EALLOW;
PieVectTable.TINT0=&cpu_timer0_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
// Enable Timer0 INT1 which is connected to Timer0 INT:
IER |= M_INT1;
// Enable CPU INT3 which is connected to TZ INT:
IER |= M_INT2;
// Enable TZ INTn in the PIE: Group 2 interrupt 1-3
//Rewrite by CCL Enable INT0
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
EnableInterrupts();
CpuTimer0Regs.TCR.bit.TSS=0;//start cputimer0
EINT;
ERTM;
for(;;)
{
;
}
}
void InitAdc_configuration()
{
AdcRegs.ADCTRL1.bit.ACQ_PS=15;
AdcRegs.ADCTRL1.bit.CONT_RUN=0;
AdcRegs.ADCTRL1.bit.SEQ_OVRD=0;
AdcRegs.ADCTRL1.bit.SEQ_CASC=1;
AdcRegs.ADCTRL1.bit.CPS=0;
AdcRegs.ADCTRL3.bit.ADCCLKPS=ADC_CKPS ;
AdcRegs.ADCTRL3.bit.SMODE_SEL=0;
AdcRegs.ADCMAXCONV.bit.MAX_CONV1=9;
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x8;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x9;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0xA;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x0;
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x1;
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x2;
AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 0x3;
AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 0x4;
AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 0x5;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCST.bit.INT_SEQ2_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=0;
AdcRegs.ADCTRL2.bit.RST_SEQ2=0;
AdcRegs.ADCTRL2.all = 0x2000;
void AD_read()
{
If_U=(1.702-(AdcRegs.ADCRESULT3>>4)*0.0007326)*53.1;
If_V=(1.689-(AdcRegs.ADCRESULT4>>4)*0.0007326)*53.5;
If_W=(1.682-(AdcRegs.ADCRESULT5>>4)*0.0007326)*52;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1; }
//
interrupt void cpu_timer0_isr(void)
{
IFR=0x0000;
PieCtrlRegs.PIEIFR3.all=0;
PieCtrlRegs.PIEACK.all=0xffff;
AD_read();
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
EINT;
}
笨鸟:
回复 user5086318:
你这个只是AD内码,你转换为对应的电压值看看波形,我相信比这个应该好多了。
請各位幫我看看為什麼我的graph觀察的波行不管怎麼設置都是錯誤的
我用訊號產生器產生一個0~1.5V左右的100HZ的弦波,但CCS上顯示的都是錯誤波形
是哪裡設置錯了嗎?
我的斷點設在這
按網上的各種設置方法設了都沒用
附上代碼
#include <math.h>
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz
#define ADC_CKPS 0x1 // ADC module clock = HSPCLK/2*ADC_CKPS = 25.0MHz/(1*2) = 12.5MHz
interrupt void cpu_timer0_isr(void);//定時采樣時間20kHz
void AD_read();//采樣值讀取
void InitAdc_configuration();
/*********采樣參數************/
float Iload_U=0.0,Iload_V=0.0,Iload_W=0.0;
float If_U=0.0,If_V=0.0,If_W=0.0;
float Vs_U=0.0,Vs_V=0.0,Vs_W=0.0;
float IC_U=0.0,IC_V=0.0,IC_W=0.0;
float ss=0.0,cc=0.0;
float IC_1=0.0,IC_2=0.0,IC_3=0.0;
float Vdc_temp=0.0,Vdc=0.0,Vdc1=0.0;
float Vx,Verror0,Verror;
void main(void)
{
InitSysCtrl();
InitCpuTimers();
#if (CPU_FRQ_150MHZ)
// Configure CPU-Timer 0,
//T=50us,fs=20k,
//CPU Timer0定時器週期寄存器值為7500
ConfigCpuTimer(&CpuTimer0, 150, 50);
#endif
#if (CPU_FRQ_100MHZ)
ConfigCpuTimer(&CpuTimer0, 100, 50);
#endif
InitAdc();
//Configure adc
InitAdc_configuration();
DINT;//禁用全局中斷
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.EPWM1_INT = &EPWM1_INT_ISR;
EDIS;
InitEPwm();
IER |= M_INT3;
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;//使能PIE級中斷,即Epwm1的事件中斷
EALLOW;
PieVectTable.TINT0=&cpu_timer0_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
// Enable Timer0 INT1 which is connected to Timer0 INT:
IER |= M_INT1;
// Enable CPU INT3 which is connected to TZ INT:
IER |= M_INT2;
// Enable TZ INTn in the PIE: Group 2 interrupt 1-3
//Rewrite by CCL Enable INT0
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
EnableInterrupts();
CpuTimer0Regs.TCR.bit.TSS=0;//start cputimer0
EINT;
ERTM;
for(;;)
{
;
}
}
void InitAdc_configuration()
{
AdcRegs.ADCTRL1.bit.ACQ_PS=15;
AdcRegs.ADCTRL1.bit.CONT_RUN=0;
AdcRegs.ADCTRL1.bit.SEQ_OVRD=0;
AdcRegs.ADCTRL1.bit.SEQ_CASC=1;
AdcRegs.ADCTRL1.bit.CPS=0;
AdcRegs.ADCTRL3.bit.ADCCLKPS=ADC_CKPS ;
AdcRegs.ADCTRL3.bit.SMODE_SEL=0;
AdcRegs.ADCMAXCONV.bit.MAX_CONV1=9;
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x8;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x9;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0xA;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x0;
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x1;
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x2;
AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 0x3;
AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 0x4;
AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 0x5;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCST.bit.INT_SEQ2_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=0;
AdcRegs.ADCTRL2.bit.RST_SEQ2=0;
AdcRegs.ADCTRL2.all = 0x2000;
void AD_read()
{
If_U=(1.702-(AdcRegs.ADCRESULT3>>4)*0.0007326)*53.1;
If_V=(1.689-(AdcRegs.ADCRESULT4>>4)*0.0007326)*53.5;
If_W=(1.682-(AdcRegs.ADCRESULT5>>4)*0.0007326)*52;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1; }
//
interrupt void cpu_timer0_isr(void)
{
IFR=0x0000;
PieCtrlRegs.PIEIFR3.all=0;
PieCtrlRegs.PIEACK.all=0xffff;
AD_read();
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
EINT;
}
user5086318:
回复 笨鸟:
我這個已經是將ad數字轉乘實際值了,我觀看的波形是If_V
請各位幫我看看為什麼我的graph觀察的波行不管怎麼設置都是錯誤的
我用訊號產生器產生一個0~1.5V左右的100HZ的弦波,但CCS上顯示的都是錯誤波形
是哪裡設置錯了嗎?
我的斷點設在這
按網上的各種設置方法設了都沒用
附上代碼
#include <math.h>
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz
#define ADC_CKPS 0x1 // ADC module clock = HSPCLK/2*ADC_CKPS = 25.0MHz/(1*2) = 12.5MHz
interrupt void cpu_timer0_isr(void);//定時采樣時間20kHz
void AD_read();//采樣值讀取
void InitAdc_configuration();
/*********采樣參數************/
float Iload_U=0.0,Iload_V=0.0,Iload_W=0.0;
float If_U=0.0,If_V=0.0,If_W=0.0;
float Vs_U=0.0,Vs_V=0.0,Vs_W=0.0;
float IC_U=0.0,IC_V=0.0,IC_W=0.0;
float ss=0.0,cc=0.0;
float IC_1=0.0,IC_2=0.0,IC_3=0.0;
float Vdc_temp=0.0,Vdc=0.0,Vdc1=0.0;
float Vx,Verror0,Verror;
void main(void)
{
InitSysCtrl();
InitCpuTimers();
#if (CPU_FRQ_150MHZ)
// Configure CPU-Timer 0,
//T=50us,fs=20k,
//CPU Timer0定時器週期寄存器值為7500
ConfigCpuTimer(&CpuTimer0, 150, 50);
#endif
#if (CPU_FRQ_100MHZ)
ConfigCpuTimer(&CpuTimer0, 100, 50);
#endif
InitAdc();
//Configure adc
InitAdc_configuration();
DINT;//禁用全局中斷
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.EPWM1_INT = &EPWM1_INT_ISR;
EDIS;
InitEPwm();
IER |= M_INT3;
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;//使能PIE級中斷,即Epwm1的事件中斷
EALLOW;
PieVectTable.TINT0=&cpu_timer0_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
// Enable Timer0 INT1 which is connected to Timer0 INT:
IER |= M_INT1;
// Enable CPU INT3 which is connected to TZ INT:
IER |= M_INT2;
// Enable TZ INTn in the PIE: Group 2 interrupt 1-3
//Rewrite by CCL Enable INT0
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
EnableInterrupts();
CpuTimer0Regs.TCR.bit.TSS=0;//start cputimer0
EINT;
ERTM;
for(;;)
{
;
}
}
void InitAdc_configuration()
{
AdcRegs.ADCTRL1.bit.ACQ_PS=15;
AdcRegs.ADCTRL1.bit.CONT_RUN=0;
AdcRegs.ADCTRL1.bit.SEQ_OVRD=0;
AdcRegs.ADCTRL1.bit.SEQ_CASC=1;
AdcRegs.ADCTRL1.bit.CPS=0;
AdcRegs.ADCTRL3.bit.ADCCLKPS=ADC_CKPS ;
AdcRegs.ADCTRL3.bit.SMODE_SEL=0;
AdcRegs.ADCMAXCONV.bit.MAX_CONV1=9;
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x8;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x9;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0xA;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x0;
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x1;
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x2;
AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 0x3;
AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 0x4;
AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 0x5;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCST.bit.INT_SEQ2_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=0;
AdcRegs.ADCTRL2.bit.RST_SEQ2=0;
AdcRegs.ADCTRL2.all = 0x2000;
void AD_read()
{
If_U=(1.702-(AdcRegs.ADCRESULT3>>4)*0.0007326)*53.1;
If_V=(1.689-(AdcRegs.ADCRESULT4>>4)*0.0007326)*53.5;
If_W=(1.682-(AdcRegs.ADCRESULT5>>4)*0.0007326)*52;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1; }
//
interrupt void cpu_timer0_isr(void)
{
IFR=0x0000;
PieCtrlRegs.PIEIFR3.all=0;
PieCtrlRegs.PIEACK.all=0xffff;
AD_read();
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
EINT;
}
笨鸟:
回复 user5086318:
主要是看你纵坐标的数值太大了,所以有疑问,ADC采集一个方波的波形也是杂乱的吗?
請各位幫我看看為什麼我的graph觀察的波行不管怎麼設置都是錯誤的
我用訊號產生器產生一個0~1.5V左右的100HZ的弦波,但CCS上顯示的都是錯誤波形
是哪裡設置錯了嗎?
我的斷點設在這
按網上的各種設置方法設了都沒用
附上代碼
#include <math.h>
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz
#define ADC_CKPS 0x1 // ADC module clock = HSPCLK/2*ADC_CKPS = 25.0MHz/(1*2) = 12.5MHz
interrupt void cpu_timer0_isr(void);//定時采樣時間20kHz
void AD_read();//采樣值讀取
void InitAdc_configuration();
/*********采樣參數************/
float Iload_U=0.0,Iload_V=0.0,Iload_W=0.0;
float If_U=0.0,If_V=0.0,If_W=0.0;
float Vs_U=0.0,Vs_V=0.0,Vs_W=0.0;
float IC_U=0.0,IC_V=0.0,IC_W=0.0;
float ss=0.0,cc=0.0;
float IC_1=0.0,IC_2=0.0,IC_3=0.0;
float Vdc_temp=0.0,Vdc=0.0,Vdc1=0.0;
float Vx,Verror0,Verror;
void main(void)
{
InitSysCtrl();
InitCpuTimers();
#if (CPU_FRQ_150MHZ)
// Configure CPU-Timer 0,
//T=50us,fs=20k,
//CPU Timer0定時器週期寄存器值為7500
ConfigCpuTimer(&CpuTimer0, 150, 50);
#endif
#if (CPU_FRQ_100MHZ)
ConfigCpuTimer(&CpuTimer0, 100, 50);
#endif
InitAdc();
//Configure adc
InitAdc_configuration();
DINT;//禁用全局中斷
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.EPWM1_INT = &EPWM1_INT_ISR;
EDIS;
InitEPwm();
IER |= M_INT3;
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;//使能PIE級中斷,即Epwm1的事件中斷
EALLOW;
PieVectTable.TINT0=&cpu_timer0_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
// Enable Timer0 INT1 which is connected to Timer0 INT:
IER |= M_INT1;
// Enable CPU INT3 which is connected to TZ INT:
IER |= M_INT2;
// Enable TZ INTn in the PIE: Group 2 interrupt 1-3
//Rewrite by CCL Enable INT0
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
EnableInterrupts();
CpuTimer0Regs.TCR.bit.TSS=0;//start cputimer0
EINT;
ERTM;
for(;;)
{
;
}
}
void InitAdc_configuration()
{
AdcRegs.ADCTRL1.bit.ACQ_PS=15;
AdcRegs.ADCTRL1.bit.CONT_RUN=0;
AdcRegs.ADCTRL1.bit.SEQ_OVRD=0;
AdcRegs.ADCTRL1.bit.SEQ_CASC=1;
AdcRegs.ADCTRL1.bit.CPS=0;
AdcRegs.ADCTRL3.bit.ADCCLKPS=ADC_CKPS ;
AdcRegs.ADCTRL3.bit.SMODE_SEL=0;
AdcRegs.ADCMAXCONV.bit.MAX_CONV1=9;
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x8;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x9;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0xA;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x0;
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x1;
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x2;
AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 0x3;
AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 0x4;
AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 0x5;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCST.bit.INT_SEQ2_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=0;
AdcRegs.ADCTRL2.bit.RST_SEQ2=0;
AdcRegs.ADCTRL2.all = 0x2000;
void AD_read()
{
If_U=(1.702-(AdcRegs.ADCRESULT3>>4)*0.0007326)*53.1;
If_V=(1.689-(AdcRegs.ADCRESULT4>>4)*0.0007326)*53.5;
If_W=(1.682-(AdcRegs.ADCRESULT5>>4)*0.0007326)*52;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1; }
//
interrupt void cpu_timer0_isr(void)
{
IFR=0x0000;
PieCtrlRegs.PIEIFR3.all=0;
PieCtrlRegs.PIEACK.all=0xffff;
AD_read();
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
EINT;
}
Rayna Wang:
回复 user5086318:
根据您的代码,
1. 如果输入电压为1.5V的话,(AdcRegs.ADCRESULT4>>4)*0.0007326 = ((1.5/3.3 * 4096) >>4)*0.0007326 = 0.085248,这个数相对1.689 太小。这可能是graph显示不正常的一个原因。
If_V=(1.689-(AdcRegs.ADCRESULT4>>4)*0.0007326)*53.5;
2. 你可以利用DataLog模块来观察Graph波形,该模块可实现Four Channel Data Logger。具体应用请参考下面材料以及参考设计方案TIDM-1000中关于DataLog的代码,主要在pfc3phvienna.c & pfc3phvienna.h文件中。
DataLog的有关说明: http://processors.wiki.ti.com/index.php/GUI_Composer/Logging_Graph_Data
TIDM-1000 文件路径 C:\ti\c2000\C2000Ware_DigitalPower_SDK_1_01_00_00\solutions\tidm_1000
TIDM-1000 User guides:www.ti.com/…/tiducj0d.pdf
請各位幫我看看為什麼我的graph觀察的波行不管怎麼設置都是錯誤的
我用訊號產生器產生一個0~1.5V左右的100HZ的弦波,但CCS上顯示的都是錯誤波形
是哪裡設置錯了嗎?
我的斷點設在這
按網上的各種設置方法設了都沒用
附上代碼
#include <math.h>
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz
#define ADC_CKPS 0x1 // ADC module clock = HSPCLK/2*ADC_CKPS = 25.0MHz/(1*2) = 12.5MHz
interrupt void cpu_timer0_isr(void);//定時采樣時間20kHz
void AD_read();//采樣值讀取
void InitAdc_configuration();
/*********采樣參數************/
float Iload_U=0.0,Iload_V=0.0,Iload_W=0.0;
float If_U=0.0,If_V=0.0,If_W=0.0;
float Vs_U=0.0,Vs_V=0.0,Vs_W=0.0;
float IC_U=0.0,IC_V=0.0,IC_W=0.0;
float ss=0.0,cc=0.0;
float IC_1=0.0,IC_2=0.0,IC_3=0.0;
float Vdc_temp=0.0,Vdc=0.0,Vdc1=0.0;
float Vx,Verror0,Verror;
void main(void)
{
InitSysCtrl();
InitCpuTimers();
#if (CPU_FRQ_150MHZ)
// Configure CPU-Timer 0,
//T=50us,fs=20k,
//CPU Timer0定時器週期寄存器值為7500
ConfigCpuTimer(&CpuTimer0, 150, 50);
#endif
#if (CPU_FRQ_100MHZ)
ConfigCpuTimer(&CpuTimer0, 100, 50);
#endif
InitAdc();
//Configure adc
InitAdc_configuration();
DINT;//禁用全局中斷
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.EPWM1_INT = &EPWM1_INT_ISR;
EDIS;
InitEPwm();
IER |= M_INT3;
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;//使能PIE級中斷,即Epwm1的事件中斷
EALLOW;
PieVectTable.TINT0=&cpu_timer0_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
// Enable Timer0 INT1 which is connected to Timer0 INT:
IER |= M_INT1;
// Enable CPU INT3 which is connected to TZ INT:
IER |= M_INT2;
// Enable TZ INTn in the PIE: Group 2 interrupt 1-3
//Rewrite by CCL Enable INT0
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
EnableInterrupts();
CpuTimer0Regs.TCR.bit.TSS=0;//start cputimer0
EINT;
ERTM;
for(;;)
{
;
}
}
void InitAdc_configuration()
{
AdcRegs.ADCTRL1.bit.ACQ_PS=15;
AdcRegs.ADCTRL1.bit.CONT_RUN=0;
AdcRegs.ADCTRL1.bit.SEQ_OVRD=0;
AdcRegs.ADCTRL1.bit.SEQ_CASC=1;
AdcRegs.ADCTRL1.bit.CPS=0;
AdcRegs.ADCTRL3.bit.ADCCLKPS=ADC_CKPS ;
AdcRegs.ADCTRL3.bit.SMODE_SEL=0;
AdcRegs.ADCMAXCONV.bit.MAX_CONV1=9;
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x8;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x9;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0xA;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x0;
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x1;
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x2;
AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 0x3;
AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 0x4;
AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 0x5;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCST.bit.INT_SEQ2_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=0;
AdcRegs.ADCTRL2.bit.RST_SEQ2=0;
AdcRegs.ADCTRL2.all = 0x2000;
void AD_read()
{
If_U=(1.702-(AdcRegs.ADCRESULT3>>4)*0.0007326)*53.1;
If_V=(1.689-(AdcRegs.ADCRESULT4>>4)*0.0007326)*53.5;
If_W=(1.682-(AdcRegs.ADCRESULT5>>4)*0.0007326)*52;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1; }
//
interrupt void cpu_timer0_isr(void)
{
IFR=0x0000;
PieCtrlRegs.PIEIFR3.all=0;
PieCtrlRegs.PIEACK.all=0xffff;
AD_read();
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
EINT;
}
user5086318:
回复 笨鸟:
我用方波去測試,只有1HZ的方波能看到波形,10HZ以上的方波graph到的都是錯誤的
下圖是測試外部給1HZ方波信號
下圖給10HZ方波,graph看到的波形都是錯的,我也試著調適主要幾個設置,acquisition buffer、sampling rate 、display data size也換過仿真器都沒有幫助。
請各位幫我看看為什麼我的graph觀察的波行不管怎麼設置都是錯誤的
我用訊號產生器產生一個0~1.5V左右的100HZ的弦波,但CCS上顯示的都是錯誤波形
是哪裡設置錯了嗎?
我的斷點設在這
按網上的各種設置方法設了都沒用
附上代碼
#include <math.h>
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz
#define ADC_CKPS 0x1 // ADC module clock = HSPCLK/2*ADC_CKPS = 25.0MHz/(1*2) = 12.5MHz
interrupt void cpu_timer0_isr(void);//定時采樣時間20kHz
void AD_read();//采樣值讀取
void InitAdc_configuration();
/*********采樣參數************/
float Iload_U=0.0,Iload_V=0.0,Iload_W=0.0;
float If_U=0.0,If_V=0.0,If_W=0.0;
float Vs_U=0.0,Vs_V=0.0,Vs_W=0.0;
float IC_U=0.0,IC_V=0.0,IC_W=0.0;
float ss=0.0,cc=0.0;
float IC_1=0.0,IC_2=0.0,IC_3=0.0;
float Vdc_temp=0.0,Vdc=0.0,Vdc1=0.0;
float Vx,Verror0,Verror;
void main(void)
{
InitSysCtrl();
InitCpuTimers();
#if (CPU_FRQ_150MHZ)
// Configure CPU-Timer 0,
//T=50us,fs=20k,
//CPU Timer0定時器週期寄存器值為7500
ConfigCpuTimer(&CpuTimer0, 150, 50);
#endif
#if (CPU_FRQ_100MHZ)
ConfigCpuTimer(&CpuTimer0, 100, 50);
#endif
InitAdc();
//Configure adc
InitAdc_configuration();
DINT;//禁用全局中斷
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.EPWM1_INT = &EPWM1_INT_ISR;
EDIS;
InitEPwm();
IER |= M_INT3;
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;//使能PIE級中斷,即Epwm1的事件中斷
EALLOW;
PieVectTable.TINT0=&cpu_timer0_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
// Enable Timer0 INT1 which is connected to Timer0 INT:
IER |= M_INT1;
// Enable CPU INT3 which is connected to TZ INT:
IER |= M_INT2;
// Enable TZ INTn in the PIE: Group 2 interrupt 1-3
//Rewrite by CCL Enable INT0
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
EnableInterrupts();
CpuTimer0Regs.TCR.bit.TSS=0;//start cputimer0
EINT;
ERTM;
for(;;)
{
;
}
}
void InitAdc_configuration()
{
AdcRegs.ADCTRL1.bit.ACQ_PS=15;
AdcRegs.ADCTRL1.bit.CONT_RUN=0;
AdcRegs.ADCTRL1.bit.SEQ_OVRD=0;
AdcRegs.ADCTRL1.bit.SEQ_CASC=1;
AdcRegs.ADCTRL1.bit.CPS=0;
AdcRegs.ADCTRL3.bit.ADCCLKPS=ADC_CKPS ;
AdcRegs.ADCTRL3.bit.SMODE_SEL=0;
AdcRegs.ADCMAXCONV.bit.MAX_CONV1=9;
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x8;
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x9;
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0xA;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x0;
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x1;
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x2;
AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 0x3;
AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 0x4;
AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 0x5;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCST.bit.INT_SEQ2_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=0;
AdcRegs.ADCTRL2.bit.RST_SEQ2=0;
AdcRegs.ADCTRL2.all = 0x2000;
void AD_read()
{
If_U=(1.702-(AdcRegs.ADCRESULT3>>4)*0.0007326)*53.1;
If_V=(1.689-(AdcRegs.ADCRESULT4>>4)*0.0007326)*53.5;
If_W=(1.682-(AdcRegs.ADCRESULT5>>4)*0.0007326)*52;
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1; }
//
interrupt void cpu_timer0_isr(void)
{
IFR=0x0000;
PieCtrlRegs.PIEIFR3.all=0;
PieCtrlRegs.PIEACK.all=0xffff;
AD_read();
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
EINT;
}
user5086318:
回复 Rayna Wang:
您好 我已經將1.689給拿掉了,但還是一樣無法正常顯示波形,只有在測試1HZ方波情況下,能看到方波,10HZ的以上就完全是錯誤。