f28027 内置温度传感器操作

隔壁发哥 2016-08-06 08:33:17
麻烦各路大神帮我看下操作有什么问题,一直跳到非法操作中断那里去
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);
}
}
...全文
300 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
隔壁发哥 2016-08-06
  • 打赏
  • 举报
回复
我通过view --> memory--->data,查看0x3D7E83和0x3D7E80这两个地址根本没数据,所以程序在最后生成摄氏温度的时候出错了,哪位大神知道如何添加刷新这两个地址数据

27,375

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 单片机/工控
社区管理员
  • 单片机/工控社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧