Управление 4-значным 7-сегментным светодиодным интерфейсом MCU 8051 - PullRequest
0 голосов
/ 29 августа 2018

Возникла ошибка при считывании напряжения, отображаемого на 7-сегментном светодиоде. PCB была разработана другим человеком. Они не назначали 7-сегментные светодиодные выводы одному и тому же порту на MCU.

Здесь я предполагаю, что код MCU правильный. Но светодиод показывает неправильное значение напряжения. У меня вопрос первый. Можем ли мы подключить 7-сегментные светодиодные выводы к 2 портам микроконтроллера? Например, сегмент a ~ d подключается к контактам MCU P1.0 ~ P1.3, сегмент e ~ h подключается к контактам P2.0 ~ P2.3. Или подключаться только к одному и тому же порту, например Сегмент светодиода через ~ h подключается к контактам MCU P1.0 ~ P1.7?

Вот код адресации контактов и управления светодиодом:

//      PORT 1
//--------------------------------------

sbit    UP_BUTTON       = P1^0;   
sbit    DOWN_BUTTON     = P1^1;   
sbit    LEFT_BUTTON     = P1^2;   
sbit    RIGHT_BUTTON    = P1^3;   
sbit    ENTER_BUTTON    = P1^4;   
sbit    _7SEG_COM5      = P1^5;   
sbit    _7SEG_COM4      = P1^6;   
sbit    _7SEG_COM3      = P1^7;   

//--------------------------------------
//      PORT 2
//--------------------------------------
sbit    _7SEG_F         = P2^0;  
sbit    _7SEG_G         = P2^1;   
sbit    _7SEG_H         = P2^2;   
sbit    _7SEG_COM0      = P2^3;   
sbit    _7SEG_COM1      = P2^4;   
sbit    _7SEG_COM2      = P2^5;     
sbit    B_RST           = P2^6;   //DATA B RST
sbit    B_RSTSEL        = P2^7;   //DATA B RSTSEL

//--------------------------------------
//      PORT 3
//--------------------------------------
sbit    THREE_ZERO      = P3^0;   
sbit    THREE_ONE       = P3^1;   
sbit    READY           = P3^2;    
sbit    _7SEG_A         = P3^3;   
sbit    _7SEG_B         = P3^4;   
sbit    _7SEG_C         = P3^5;   
sbit    _7SEG_D         = P3^6;   
sbit    _7SEG_E         = P3^7; 


sbit Sinitial_f             = Flag0^1;
unsigned char idata SEG[6]  _at_ 0x82;


// 7 segment display in addition,3rd number(SEG2) is dot always 
//=======================================================================================
void SEGMENT_DISPLAY(void)
{
    unsigned char SFRPAGE_BUF,seg_num,seg_value;
    int cnt, i, num, temp;
    SFRPAGE_BUF = SFRPAGE;
    SFRPAGE = CONFIG_PAGE;


    if(!Sinitial_f)
    {
        SEG[0] = 0x0A;
        SEG[1] = 0x0A;
        SEG[2] = 0x0A;
        SEG[3] = 0x0A;
        SEG[4] = 0x0A;
        SEG[5] = 0x0A; 
        Sinitial_f = 1;                  
    }
    for(seg_num=0x00;seg_num<=0x04;seg_num++)
    {
        seg_value = SEG[seg_num];
        switch(seg_value)
        {
            case 0x00:  _7SEG_A = 1;//0
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 1;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 0;
                        _7SEG_H = 0;
                        break;

            case 0x01:  _7SEG_A = 0;//1
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 0;
                        _7SEG_E = 0;
                        _7SEG_F = 0;
                        _7SEG_G = 0;
                        _7SEG_H = 0;
                        break;

            case 0x02:  _7SEG_A = 1;//2
                        _7SEG_B = 1;
                        _7SEG_C = 0;
                        _7SEG_D = 1;
                        _7SEG_E = 1;
                        _7SEG_F = 0;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

            case 0x03:  _7SEG_A = 1;//3
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 1;
                        _7SEG_E = 0;
                        _7SEG_F = 0;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

            case 0x04:  _7SEG_A = 0;//4
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 0;
                        _7SEG_E = 0;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

            case 0x05:  _7SEG_A = 1;//5
                        _7SEG_B = 0;
                        _7SEG_C = 1;
                        _7SEG_D = 1;
                        _7SEG_E = 0;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

            case 0x06:  _7SEG_A = 1;//6
                        _7SEG_B = 0;
                        _7SEG_C = 1;
                        _7SEG_D = 1;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

            case 0x07:  _7SEG_A = 1;//7
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 0;
                        _7SEG_E = 0;
                        _7SEG_F = 1;
                        _7SEG_G = 0;
                        _7SEG_H = 0;
                        break;

            case 0x08:  _7SEG_A = 1;//8
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 1;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

            case 0x09:  _7SEG_A = 1;//9
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 0;
                        _7SEG_E = 0;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

            case 0x0A:  _7SEG_A = 0;//.
                        _7SEG_B = 0;
                        _7SEG_C = 0;
                        _7SEG_D = 0;
                        _7SEG_E = 0;
                        _7SEG_F = 0;
                        _7SEG_G = 0;
                        _7SEG_H = 1;
                        break;

            case 0x0B:  _7SEG_A = 0;//-
                        _7SEG_B = 0;
                        _7SEG_C = 0;
                        _7SEG_D = 0;
                        _7SEG_E = 0;
                        _7SEG_F = 0;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

            case 0x0C:  _7SEG_A = 0;//Close
                        _7SEG_B = 0;
                        _7SEG_C = 0;
                        _7SEG_D = 0;
                        _7SEG_E = 0;
                        _7SEG_F = 0;
                        _7SEG_G = 0;
                        _7SEG_H = 0;
                        break;

            case 0x0D:  _7SEG_A = 1;//E
                        _7SEG_B = 0;
                        _7SEG_C = 0;
                        _7SEG_D = 1;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

            case 0x0E:  _7SEG_A = 1;//C
                        _7SEG_B = 0;
                        _7SEG_C = 0;
                        _7SEG_D = 1;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 0;
                        _7SEG_H = 0;
                        break;

            case 0x0F:  _7SEG_A = 1;//A
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 0;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

            case 0x10:  _7SEG_A = 0;//r
                        _7SEG_B = 0;
                        _7SEG_C = 0;
                        _7SEG_D = 0;
                        _7SEG_E = 1;
                        _7SEG_F = 0;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

            case 0x11:  _7SEG_A = 1;//S
                        _7SEG_B = 0;
                        _7SEG_C = 1;
                        _7SEG_D = 1;
                        _7SEG_E = 0;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

             case 0x12:  _7SEG_A = 1;//P
                        _7SEG_B = 1;
                        _7SEG_C = 0;
                        _7SEG_D = 0;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

             case 0x13: _7SEG_A = 1;//C.
                        _7SEG_B = 0;
                        _7SEG_C = 0;
                        _7SEG_D = 1;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 0;
                        _7SEG_H = 1;
                        break;

             case 0x14: _7SEG_A = 0;//d
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 1;
                        _7SEG_E = 1;
                        _7SEG_F = 0;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

             case 0x15: _7SEG_A = 0;//n
                        _7SEG_B = 0;
                        _7SEG_C = 1;
                        _7SEG_D = 0;
                        _7SEG_E = 1;
                        _7SEG_F = 0;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

             case 0x16: _7SEG_A = 0;//V
                        _7SEG_B = 1;
                        _7SEG_C = 0;
                        _7SEG_D = 0;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

             case 0x17: _7SEG_A = 0;//h
                        _7SEG_B = 0;
                        _7SEG_C = 1;
                        _7SEG_D = 0;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

             case 0x18: _7SEG_A = 0;//L
                        _7SEG_B = 0;
                        _7SEG_C = 0;
                        _7SEG_D = 1;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 0;
                        _7SEG_H = 0;
                        break;

             case 0x19: _7SEG_A = 0;//U
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 1;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 0;
                        _7SEG_H = 0;
                        break;


            case 0x1A:  _7SEG_A = 0;//b
                        _7SEG_B = 0;
                        _7SEG_C = 1;
                        _7SEG_D = 1;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

            case 0x1B:  _7SEG_A = 1;//g
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 1;
                        _7SEG_E = 0;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 0;
                        break;

            case 0x1C:  _7SEG_A = 0;//V.
                        _7SEG_B = 1;
                        _7SEG_C = 0;
                        _7SEG_D = 0;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 1;
                        break;

            case 0x1D:  _7SEG_A = 0;//r.
                        _7SEG_B = 0;
                        _7SEG_C = 0;
                        _7SEG_D = 0;
                        _7SEG_E = 1;
                        _7SEG_F = 0;
                        _7SEG_G = 1;
                        _7SEG_H = 1;
                        break;

            case 0x1E:  _7SEG_A = 1;//g.
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 1;
                        _7SEG_E = 0;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 1;
                        break;

            case 0x1F:  _7SEG_A = 0;//b.
                        _7SEG_B = 0;
                        _7SEG_C = 1;
                        _7SEG_D = 1;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 1;
                        break;


            //number + dot
            case 0x20:  _7SEG_A = 1;//0.
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 1;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 0;
                        _7SEG_H = 1;
                        break;

            case 0x21:  _7SEG_A = 0;//1.
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 0;
                        _7SEG_E = 0;
                        _7SEG_F = 0;
                        _7SEG_G = 0;
                        _7SEG_H = 1;
                        break;

            case 0x22:  _7SEG_A = 1;//2.
                        _7SEG_B = 1;
                        _7SEG_C = 0;
                        _7SEG_D = 1;
                        _7SEG_E = 1;
                        _7SEG_F = 0;
                        _7SEG_G = 1;
                        _7SEG_H = 1;
                        break;

            case 0x23:  _7SEG_A = 1;//3.
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 1;
                        _7SEG_E = 0;
                        _7SEG_F = 0;
                        _7SEG_G = 1;
                        _7SEG_H = 1;
                        break;

            case 0x24:  _7SEG_A = 0;//4.
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 0;
                        _7SEG_E = 0;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 1;
                        break;

            case 0x25:  _7SEG_A = 1;//5.
                        _7SEG_B = 0;
                        _7SEG_C = 1;
                        _7SEG_D = 1;
                        _7SEG_E = 0;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 1;
                        break;

            case 0x26:  _7SEG_A = 1;//6.
                        _7SEG_B = 0;
                        _7SEG_C = 1;
                        _7SEG_D = 1;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 1;
                        break;

            case 0x27:  _7SEG_A = 1;//7.
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 0;
                        _7SEG_E = 0;
                        _7SEG_F = 1;
                        _7SEG_G = 0;
                        _7SEG_H = 1;
                        break;

            case 0x28:  _7SEG_A = 1;//8.
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 1;
                        _7SEG_E = 1;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 1;
                        break;

            case 0x29:  _7SEG_A = 1;//9.
                        _7SEG_B = 1;
                        _7SEG_C = 1;
                        _7SEG_D = 0;
                        _7SEG_E = 0;
                        _7SEG_F = 1;
                        _7SEG_G = 1;
                        _7SEG_H = 1;
                        break;

            default:    break;
        }
        switch(seg_num)
        {
            case 0x00:  _7SEG_COM5 = 0;
                        break;

            case 0x01:  _7SEG_COM4 = 0;
                        break;

            case 0x02:  
                        _7SEG_COM3 = 0;
                        break;

            case 0x03:  if(engineering_f)
                            _7SEG_H = 1;
                                                _7SEG_COM2 = 0;
                        break;   

                        case 0x04:  _7SEG_COM1 = 0;
                        break;

            default:    break;
        } 
        DELAY_X2us(100);   
        _7SEG_COM0 = 1;
        _7SEG_COM1 = 1;
        _7SEG_COM2 = 1;
        _7SEG_COM3 = 1;
        _7SEG_COM4 = 1;
        _7SEG_COM5 = 1;      
    }

     SFRPAGE = SFRPAGE_BUF;  
}

void SEGMENT_REG_REFRESH(void)
{
    //for display voltage (V)
    unsigned long  voltage;
    unsigned char  voltage_ten_thousand;
    unsigned char  voltage_thousand;
    unsigned char  voltage_hundred;
    unsigned char  voltage_ten;
    unsigned char  voltage_unit;

    unsigned long DAC_buf   =0x0000; 

    //for display pattern index 
    unsigned char  hundred;
    unsigned char  ten;
    unsigned char  unit;


    if(Keyboard ==1)
    {
        switch(Keyboard_Item_Index)
        {

            case 0: //VGH
                    voltage = VGH_VGL_A*0.05+ 3.2;                
                    voltage_ten = voltage/10 ;
                    voltage = voltage%10;

                    SEG[5] = 0x16;
                    SEG[4] = 0x1B;    
                    SEG[3] = 0x17;

                    if(voltage_ten!=0x00)
                    {
                        SEG[2] = voltage_ten;
                        SEG[1] = voltage_unit + 0x20;  //add dot
                        SEG[0] = voltage_hundred;
                    }
                    else
                    {
                        SEG[2] = voltage_thousand + 0x20;  //add dot
                        SEG[1] = voltage_hundred;
                        SEG[0] = voltage_ten;   
                    }
                    break;

            case 1: //VGL
                    voltage = VGH_VGL_B*0.05+ 1.2;                  
                    voltage_ten = voltage/10 ;
                    voltage = voltage%10;

                    SEG[5] = 0x16;
                    SEG[4] = 0x1B;    
                    SEG[3] = 0x18;

                    if(voltage_ten!=0x00)
                    {
                        SEG[2] = voltage_ten;
                        SEG[1] = voltage_unit + 0x20;  //add dot
                        SEG[0] = voltage_hundred;
                    }
                    else
                    {
                        SEG[2] = voltage_thousand + 0x20;  //add dot
                        SEG[1] = voltage_hundred;
                        SEG[0] = voltage_ten;   
                    }
                    break;

// Button Control to switch voltage for adjustment. Keyboard_Item_Index //corresponds each voltage VGH/VGL...
//=======================================================================================
void Button_Check()
{


    if(!UP_BUTTON)
    {
        Debounce_Cnt++;
        if(Debounce_Cnt > 5)
        {
            Debounce_Cnt = 0;
            Up_Button_f = 1;
            Action_f = 0;
            Up_Hold_Cnt++;
            if(Up_Hold_Cnt > 100) 
            {
                Up_Hold_Cnt = 0;
                Up_Button_Hold_f = 1;
                if(Keyboard == 1)
                {
                    BUZZER();
                }
                else
                {
                    BUZZER();
                    DELAY_X2us(50000);
                    BUZZER();
                    DELAY_X2us(50000);
                }
            }
        }
    }
    else if(!DOWN_BUTTON)
    {
        Debounce_Cnt++;
        if(Debounce_Cnt > 5)
        {
            Debounce_Cnt = 0;
            Down_Button_f = 1;
            Action_f = 0;
            Down_Hold_Cnt++;
            if(Down_Hold_Cnt > 100)
            {
                Down_Hold_Cnt = 0;
                Down_Button_Hold_f = 1;
                if(Keyboard==1)
                {
                    BUZZER();
                }
            }
        }
    }
    else if(!LEFT_BUTTON)
    {
        Debounce_Cnt++;
        if(Debounce_Cnt > 5)
        {
            Debounce_Cnt = 0;
            Left_Button_f = 1;
            Action_f = 0;
            Left_Hold_Cnt++;

            if(Keyboard == 1)
            {

            }
            else
            {
                BUZZER();
                DELAY_X2us(50000);
                BUZZER();
                DELAY_X2us(50000);
            }

            if(Left_Hold_Cnt > 100)
            {
                Left_Hold_Cnt = 0;
                Left_Button_Hold_f = 1;
                //BUZZER();
            }
        }
    }
    else if(!RIGHT_BUTTON)
    {
        Debounce_Cnt++;
        if(Debounce_Cnt > 5)
        {
            Debounce_Cnt = 0;
            Right_Button_f = 1;
            Action_f = 0;
            Right_Hold_Cnt++;

            if(Keyboard == 1)
            {

            }
            else
            {
                POWER_SLEEP();      
                //BUZZER();
                DELAY_X2us(50000);
                //BUZZER();
                DELAY_X2us(50000);

            }

            if(Right_Hold_Cnt > 100)
            {
                Right_Hold_Cnt = 0;
                Right_Button_Hold_f = 1;
                //BUZZER();
            }
        }
    }
    else if(!ENTER_BUTTON)
    {
        Debounce_Cnt++;
        if(Debounce_Cnt > 5)
        {
            Debounce_Cnt = 0;
            Enter_Button_f = 1;
            Action_f = 0;
            Enter_Hold_Cnt++;

            if(Enter_Hold_Cnt > 100)
            {
                Enter_Hold_Cnt = 0;
                Enter_Button_Hold_f = 1;
                BUZZER();
                DELAY_X2us(50000);
                BUZZER();
                DELAY_X2us(50000);
            }
        }
    }
    else
    {   
        Action_f = 1;
        Debounce_Cnt = 0;
        Up_Hold_Cnt = 0;
        Down_Hold_Cnt = 0;
        Left_Hold_Cnt = 0;
        Right_Hold_Cnt = 0;
        Enter_Hold_Cnt = 0;

    }
}

 void Button_Function()
{
    //int i;

    if(Up_Button_Hold_f)
    {   
        Up_Button_f = 0;
        Up_Button_Hold_f = 0;

        if(Keyboard ==1)
        {
            Keyboard_Adj(Keyboard_Item_Index,3);
        }
        else
        {
            returnPatternZero();
        }

        //Keyboard = !Keyboard; 
    }
    else if(Down_Button_Hold_f)
    {   
        Down_Button_f = 0;
        Down_Button_Hold_f = 0;
                    BUZZER();
        check_ID();
//      DELAY_X2us(5000);

//      if(Keyboard ==1)
//      {
//          
//          Keyboard_Adj(Keyboard_Item_Index,2);
//      
//      }       


    }
    else if(Left_Button_Hold_f)
    {   
        Left_Button_f = 0;  
        Left_Button_Hold_f = 0;     


    }
    else if(Right_Button_Hold_f)
    {   
        Right_Button_f = 0; 
        Right_Button_Hold_f = 0;

        //DC Power wake up 
        POWER_INITIAL();
        DELAY_X2us(5000);
        returnPatternZero();    

    }
    else if(Enter_Button_Hold_f)
    {   
        Enter_Button_f = 0; 
        Enter_Button_Hold_f = 0;
        Keyboard = !Keyboard;   
    }
    else if(Up_Button_f)
    {   
        Up_Button_f = 0;
        if(Keyboard ==1)
        {
            Keyboard_Adj(Keyboard_Item_Index,1);
        }
        else
        {           
            if(Pattern_Index<Total_Pattern-1)
            {
                Pattern_Index++;        
            }
            else
            {
                Pattern_Index=0;
            }
            quickPattern();
        }                           
    }
    else if(Down_Button_f)
    {   
        Down_Button_f = 0;
        if(Keyboard ==1)
        {
             Keyboard_Adj(Keyboard_Item_Index,0);
        }
        else
        {
            if(Pattern_Index>0)
            {
                Pattern_Index--;        
            }
            else
            {
                Pattern_Index=Total_Pattern-1;
            }
            quickPattern();
        }
    }
    else if(Left_Button_f)
    {   
        Left_Button_f = 0;
        if(Keyboard ==1)
        {
            if(Keyboard_Item_Index >0)
            {
                Keyboard_Item_Index-=1 ;
            }
            else
            {
                Keyboard_Item_Index = Total_Keyboard_Item_Index-1;
            }
        }
        else
        {
            returnPatternZero();
        }                           
    }
    else if(Right_Button_f)
    {   
        Right_Button_f = 0;
        if(Keyboard ==1)
        {
            if(Keyboard_Item_Index < Total_Keyboard_Item_Index-1)
            {
                Keyboard_Item_Index +=1 ;
            }
            else
            {
                Keyboard_Item_Index = 0;
            }
        }
        else
        {
            //DC Power wake up 
            POWER_INITIAL();
            DELAY_X2us(5000);
            returnPatternZero();

        }                               
    }
    else if(Enter_Button_f)
    {   
        Enter_Button_f = 0;                             
    }

}

void main(void)
{
while(1)
    {
        Button_Check();
        if(Action_f)
        {
            Button_Function();
        }
        SEGMENT_REG_REFRESH();
        SEGMENT_DISPLAY();
    }
}

1 Ответ

0 голосов
/ 30 августа 2018

В вашем определении напряжение представляет собой int значение:

unsigned long  voltage;

Вы не можете делать такие вещи:

         voltage = VGH_VGL_B*0.05+ 1.2;    

с целым числом.

Полагаю, вам стоит вообще избегать float.

...