⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dac.#1

📁 采用CYGNAL F015单片机
💻 #1
字号:
//采样值是否已等于或大于门槛值.
//注意是比较绝对值
//假设上位机只传正值,否则也修正.
//是 : return 1; 否 : return 0.
char   HasGreatOrEqual(unsigned char SampleValue[2], unsigned char ThresholdValue[2])
{
    char ret=0;
    unsigned int tempValue=0;
    unsigned char Sample[2];
    Sample[0]=SampleValue[0];
    Sample[1]=SampleValue[1];
    if((Sample[1]&0x80)&&(Sample[1]&0x40)) //Negative value:
    {
		tempValue = Sample[1];
		tempValue = tempValue<<0x08;
        tempValue += Sample[0];
        tempValue=0x10000-tempValue;
        Sample[0]=(uchar)tempValue;  
        Sample[1]=(uchar)(tempValue>>8);
        
    }
    if((Sample[1]>ThresholdValue[1])  //Big or equal.
                   ||((Sample[1]==ThresholdValue[1])
                       &&(Sample[0]>=ThresholdValue[0])) )       
    {
        if((Sample[1]==ThresholdValue[1])//Equal.
                       &&(Sample[0]==ThresholdValue[0]) ) 
            ret=0;
        else
			ret=1;
    }
    else
    {
        ret=-1;
    }
    return ret;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -