27,375
社区成员
发帖
与我相关
我的任务
分享
void main(void)
{
// long sum=0;
// float vol=0;
int16 sensorSample,DegreesC;
// int i=0;
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2802x_SysCtrl.c file.
InitSysCtrl();
// Step 2. Initalize GPIO:
// This example function is found in the DSP2802x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
InitGpio();
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
DINT;
// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP2802x_PieCtrl.c file.
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).
// This will populate the entire table, even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in DSP2802x_DefaultIsr.c.
// This function is found in DSP2802x_PieVect.c.
InitPieVectTable();
// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2802x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
// Step 5. User specific code:
InitAdc();
AdcOffsetSelfCal();
InitLCD12864();
EALLOW;
AdcRegs.ADCCTL1.bit.TEMPCONV = 1;
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 1;
AdcRegs.ADCSOC0CTL.bit.CHSEL = 5;
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6;
// AdcRegs.ADCSAMPLEMODE.bit.SIMULEN0 = 0;
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1;
AdcRegs.INTSEL1N2.bit.INT1SEL = 1;
AdcRegs.INTSEL1N2.bit.INT1CONT = 0;
AdcRegs.INTSEL1N2.bit.INT1E = 1;
PieCtrlRegs.PIEIER1.bit.INTx1 = 1;
FlashRegs.FOTPWAIT.bit.OTPWAIT = 1;
EDIS;
CpuTimer0Regs.TCR.bit.TIE = 1;
StartCpuTimer0();
EALLOW;
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
IER |= 0x0001;
EINT;
EDIS;
while(1)
{
if(AdcRegs.ADCSOCFLG1.bit.SOC0==1)
{
while(AdcRegs.ADCSOCFLG1.bit.SOC0==1);
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
DELAY_US(10);
sensorSample=AdcResult.ADCRESULT0;
DegreesC=GetTemperatureC(sensorSample);
DISLPLAY_LONGSTRING(2,0,DegreesC);
// sum+=AdcResult.ADCRESULT0;
// i++;
}
/* if(i==10)
{
// sum/=10;
// vol=sum*3.3/4095;
WRITECMD_LCD12864(0x01);
DISLPLAY_LONGSTRING(2,0,sum);
// DISLPLAY_FLOATSTRING(3,0,vol);
// WRITEDATA_LCD12864('v');
sum=0;
i=0;
}*/
//sum=AdcResult.ADCRESULT0;
//DISLPLAY_LONGSTRING(2,0,sum);
}
}