This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我参照ti\c2000\C2000Ware_3_03_00_00\device_support\f2837xd\examples\cpu1\adc_soc_software\cpu01
修改后,debug时发现没有读数,不知怎么回事
//########################################################################### // // FILE: main.c // //########################################################################### // // Included Files // #include "main.h" #include "algorithm.h" Uint16 AdcdResult0; // // Main // void main(void) { // // Step 1. Initialize System Control // InitSysCtrl(); // // Step 2. Initialize GPIO // InitGpio(); ConfigureGpio(); // // Step 3. Clear all interrupts and initialize PIE vector table // DINT; // // Initialize the PIE control registers to their default state // InitPieCtrl(); // // Disable CPU interrupts and clear all CPU interrupt flags // IER = 0x0000; IFR = 0x0000; // // Initialize the PIE vector table with pointers to the shell Interrupt Service Routines (ISR) // InitPieVectTable(); ConfigurePieVectTable(); // // Step 4. Initialize the Device Peripheral // // ConfigureADC(); SET_MUX_EN; SET_MUX_A1; SET_MUX_A0; EALLOW; AdcdRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4 AdcSetMode(ADC_ADCD, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE); AdcdRegs.ADCCTL1.bit.INTPULSEPOS = 1; AdcdRegs.ADCCTL1.bit.ADCPWDNZ = 1; DELAY_US(1000); EDIS; EALLOW; AdcdRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 will convert pin A2 AdcdRegs.ADCSOC0CTL.bit.ACQPS = 63; //sample window is acqps + AdcdRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag AdcdRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag AdcdRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared EDIS; // InitCpuTimers(); // ConfigureCpuTimer(); // ConfigureExternalInterrupt(); ConfigureSci(); DisableEpwm(); ConfigureEPwm(); // EnableEpwm(); // // Step 5. User specific code, enable interrupts // EnablingInterrupts(); // // Enable global Interrupts and higher priority real-time debug events // EINT; // Enable Global interrupt INTM ERTM; // Enable Global realtime interrupt DBGM // // for(;;) // do { AdcdRegs.ADCSOCFRC1.all = 0x0001; //SOC0 and SOC1 while(AdcdRegs.ADCINTFLG.bit.ADCINT1 == 0); AdcdRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; AdcdResult0 = AdcdResultRegs.ADCRESULT0; }while(1); }
line 63-78
line106-114
主要就是改成只才ADCD的SOC0
读的就是AdcdResultRegs.ADCRESULT0和AdcdResult0