Need Help With Displaying ADC Value on (four)7 Segment Display.

Thread Starter

devjeetmandal

Joined May 7, 2017
48
Hello Everyone,

i am trying to interface adc(using a potentiometre) using atmega8/atmega32 and show the analog value on four 7 segment displays.

in the begining i tried to interface it with lcd and it was perfectly showing the display.(to know i am doing the adc correctly)
mcu - atmega 32
F_CPU- 16MHz

adc initialization
[
void adc_init()
{
ADMUX |= (1<<REFS0); // 5 volt reference AVCC
ADCSRA |= (1<<ADEN) | (1<<ADPS0) | (1<<ADPS2) | (1<<ADPS1); // prescale-128
}
]

reading adc
[

uint16_t read_adc(uint8_t ch)
{
ch = ch & 0x07;
ADMUX |= ch;
ADCSRA |= (1<<ADSC);
while (! (ADCSRA & (1<<ADIF)) );
ADCSRA |= (1<<ADIF);
return(ADCW); // returning 10bit adc value
}
]
here there is more code for lcd which i am not posting as all i did is to read the adc from channel 7 and displayed it on lcd.



this is my proteus simualtion which is working perfectly showing adc value between 0-1023(as 10 bit adc)

Capture.PNG



now i tried to interface 7-segment using two buttons which can increment or decrement the value. and show it on 7-segment.(i did it to check that i can interface seven segment in general)

mcu used- atmega8
F_CPU = 16MHz

here is how i did it
[

#define Bit(x) (1<<x)

void EverythingOff()
{
PORTB &= ~(1<<PB0);
PORTB &= ~(1<<PB1);
PORTB &= ~(1<<PB2);
PORTB &= ~(1<<PB3);
}


int main(void)
{
DDRB |= Bit(PB0) | Bit(PB1) | Bit(PB2) | Bit(PB3); // bits to select the segment between 4 segments
DDRD |= Bit(PD0) | Bit(PD1) | Bit(PD2) | Bit(PD3) | Bit(PD4) | Bit(PD5) | Bit(PD6); // a,b,c,d,e,f,g of 7 segment
DDRC &= ~(1<<PC0); // button 1
DDRC &= ~(1<<PC1); // button 2

int segArray[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; // array to hold the font of segment
int keypressed = 0; // variable to hold either key is pressed or not

while (1)
{
if ( !(PINC & (1<<PC0)) ) // checking button 1 to incremnt
{
EverythingOff();
_delay_ms(300);
keypressed++;
if (keypressed>9999)
{
keypressed = 0;
}
}
if ( !(PINC & (1<<PC1)) ) // checking button 2 to decrement
{
EverythingOff();
_delay_ms(300);
keypressed--;
if (keypressed<0)
{
keypressed = 9999;
}
}


// displaying on seven segment
EverythingOff(); // switching off all the bits to select segments
PORTB |= (1<<PB3); // switching on the desired one
PORTD = segArray[(keypressed%10)];
_delay_us(0.01);
PORTD &= ~segArray[(keypressed%10)];
_delay_us(0.01);

EverythingOff();
PORTB |= (1<<PB0);
PORTD = segArray[(keypressed/1000)%10];
_delay_us(0.01);
PORTD &= ~segArray[(keypressed/1000)%10];
_delay_us(0.01);

EverythingOff();
PORTB |= (1<<PB1);
PORTD = segArray[(keypressed/100)%10];
_delay_us(0.01);
PORTD &= ~segArray[(keypressed/100)%10];
_delay_us(0.01);


EverythingOff();
PORTB |= (1<<PB2);
PORTD = segArray[(keypressed/10)%10];
_delay_us(0.01);
PORTD &= ~segArray[(keypressed/10)%10];
_delay_us(0.01);



}
}
]

this code is also working perfectly and i am able to increment or decremnt the value on seven segment using two push buttons
here is the proteus image

Capture 2.PNG


so everything is working so far. but when i attach the adc(i.e potentiometre) with seven segment i am not getting the desired result.(this is my actual problem. all was the background details)

my code is this
mcu -atmega8
F_CPU = 16MHz

[

#include <avr/io.h>
#include <util/delay.h>
#define Bit(x) (1<<x)

void adc_init() // adc initialization
{
ADMUX |= (1<<REFS0); // 5 volt on AVCC
ADCSRA |= (1<<ADEN) | (1<<ADPS0) | (1<<ADPS2) | (1<<ADPS1); //prescale 128
}

uint16_t read_adc(uint8_t ch) // read adc
{
ch = ch & 0x07;
ADMUX |= ch;
ADCSRA |= (1<<ADSC);
while (! (ADCSRA & (1<<ADIF)) );
ADCSRA |= (1<<ADIF);
return(ADCW); // return 10 bit adc
}

void EverythingOff() // switing off all the select segments
{
PORTB &= ~(1<<PB0);
PORTB &= ~(1<<PB1);
PORTB &= ~(1<<PB2);
PORTB &= ~(1<<PB3);
}


int main(void)
{
DDRB |= Bit(PB0) | Bit(PB1) | Bit(PB2) | Bit(PB3); // for selecting segments
DDRD |= Bit(PD0) | Bit(PD1) | Bit(PD2) | Bit(PD3) | Bit(PD4) | Bit(PD5) | Bit(PD6); // a,b,c,d,e,f,g, of seven segment
DDRC &= ~(1<<PC2); // PC2 adc potentiometre connect set as input
int segArray[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; // font of seven segment
adc_init(); // initializing adc
float digVal; //to store the value of adc
uint16_t keypressed;
while (1)
{
digVal = read_adc(2); // getting the adc value from channel 2
keypressed = digVal; // taking only the integer part(there is no floating part as read_adc returns integer but just to double check it . moreover who will again change all the keypressed to digval. too much lazy :p)
_delay_us(10);

EverythingOff(); // switching of all the select pin of segments
PORTB |= (1<<PB3); // switching on the desired one
PORTD = segArray[(keypressed%10)];
_delay_us(0.01);
PORTD &= ~segArray[(keypressed%10)];
_delay_us(0.01);

EverythingOff();
PORTB |= (1<<PB0);
PORTD = segArray[(keypressed/1000)%10];
_delay_us(0.01);
PORTD &= ~segArray[(keypressed/1000)%10];
_delay_us(0.01);

EverythingOff();
PORTB |= (1<<PB1);
PORTD = segArray[(keypressed/100)%10];
_delay_us(0.01);
PORTD &= ~segArray[(keypressed/100)%10];
_delay_us(0.01);


EverythingOff();
PORTB |= (1<<PB2);
PORTD = segArray[(keypressed/10)%10];
_delay_us(0.01);
PORTD &= ~segArray[(keypressed/10)%10];
_delay_us(0.01);



}
}
]


this is the proteus image of output

Capture 3.PNG
the result is sometimes 1083 too which is definetly wrong.


i know its a lengthy description. i have been trying this like 2 days and not able to get any output.
please help me with your suggestions.
thank you in advance.
 

jayanthd

Joined Jul 4, 2015
945
Have you used Timer ISR for 7 Segment data displaying ? If not, then you will see random digits turning ON.

I will post the code soon.
What is your Crystal frequency ?

Do you want to display floating point values or just integer values ?

How many digits display you want 3 digits or 4 digits ?
 

Thread Starter

devjeetmandal

Joined May 7, 2017
48
no i have not used timer ISR.(i will check this)

crystal 16Mhz

no floating point(want to show only integers)

4 digits (0 - 1023)

thank you.
 

jayanthd

Joined Jul 4, 2015
945
Is this only for testing or are you building the hardware ? because the circuit lacks 7 Segment Display driving transistors.

I you have proper hardware for testing then I will draw a new circuit and write code using mikroC PRO AVR Compiler. I have Atmel Studio but don't like to write libraries for it when they are available in mikroC PRO AVR.
 

Thread Starter

devjeetmandal

Joined May 7, 2017
48
are you talking about 4511??

it will be really helpful if u add 7 segment display driving transistors.

yeah it will be fine with mikroC PRO i will check out the libraries.

thank you.
 

jayanthd

Joined Jul 4, 2015
945
are you talking about u24511??

it will be really helpful if u add 7 segment display driving transistors.

yeah it will be fine with mikroC PRO i will check out the libraries.

thank you.
What is u24511 ? Never used it.

You are using Common Anode display and you need 4 PNP transistors to drive th enable pins of the display.

I will make new circuit. You build it in hardware. I will retain the same pin connections that you have used.
 

jayanthd

Joined Jul 4, 2015
945
okay. thanks
Build this circuit. Buttons were not shown in your Proteus file. If you want me to add buttons then mention which pins and how the buttons are connected.

Oscillator circuit is not shown. You can add it if you need but it is not required in Proteus. In hardware you will need it.

I can use Internal RC Oscillator. This will eliminate the need of an Oscillator circuit.

I will post mikroC PRO AVR project in 30 minutes. By that time you build the circuit.

If you want my Proteus file which is in 8.6 SP3 format then I can send it to you. You will need Proteus 8.6 SP3 to open my Proteus file.

For RN1 in Schematic use 330R.
R2 = R4 = R6 = R8 = 1k


 

Attachments

jayanthd

Joined Jul 4, 2015
945
I have completed the project and it is working fine.

Find the attached project file. See the Proteus Simulation video inside.




Code:
#define Ascii_Base 0x30
#define Dp_Blank   0x80;
#define Blank      0xFF

#define SSD_DATA_PORT PORTD
#define SSD_CTRL_PORT PORTB

unsigned char digits[4] = {0, 0, 0, 0};
unsigned char digit = 0;
unsigned char ca_mask[10] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};

unsigned int raw_adc_value = 0, previous_raw_adc_value = 1024;

char str_ADCValue[17];

//Timer1 Prescaler = 0; Preload = 3999; Actual Interrupt Time = 1 ms
void InitTimer1() {
    SREG_I_bit = 1;
    TCCR1A = 0x00;
    TCCR1B = 0x09;
    OCR1AH = 0x0F;
    OCR1AL = 0x9F;
    OCIE1A_bit = 1;
}

void Timer1Overflow_ISR() org IVT_ADDR_TIMER1_COMPA {
    //Enter your code here
    SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x0F;

    switch(digit) {
         case 0:
              SSD_DATA_PORT = digits[0];
              SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x0E;
              break;
         case 1:
              SSD_DATA_PORT = digits[1];
              SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x0D;
              break;
         case 2:
              SSD_DATA_PORT = digits[2];
              SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x0B;
              break;
         case 3:
              SSD_DATA_PORT = digits[3];
              SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x07;
              break;
    };

    if(++digit >= 4) {
        digit = 0;
    }
}

void main() {

    PORTB = 0x0F;
    PORTC = 0x00;
    PORTD = 0xFF;
  
    DDRB = 0x0F;
    DDRC = 0b1111011;
    DDRD = 0xFF;

    Delay_ms(100);

    InitTimer1();

    while(1) {

           raw_adc_value = ADC_Read(2);
           Delay_ms(2);
          
           if(previous_raw_adc_value != raw_adc_value) {
                IntToStr(raw_adc_value, str_ADCValue);
                Ltrim(str_ADCValue);
              
                if((raw_adc_value >= 0) && (raw_adc_value < 10)) {
                   digits[0] = Blank;
                   digits[1] = Blank;
                   digits[2] = Blank;
                   digits[3] = ca_mask[str_ADCVAlue[0] - Ascii_Base] | Dp_Blank;
                }
                else if((raw_adc_value >= 10) && (raw_adc_value < 100)) {
                   digits[0] = Blank;
                   digits[1] = Blank;
                   digits[2] = ca_mask[str_ADCVAlue[0] - Ascii_Base] | Dp_Blank;
                   digits[3] = ca_mask[str_ADCVAlue[1] - Ascii_Base] | Dp_Blank;
                }
                else if((raw_adc_value >= 100) && (raw_adc_value < 1000)) {
                   digits[0] = Blank;
                   digits[1] = ca_mask[str_ADCVAlue[0] - Ascii_Base] | Dp_Blank;
                   digits[2] = ca_mask[str_ADCVAlue[1] - Ascii_Base] | Dp_Blank;
                   digits[3] = ca_mask[str_ADCVAlue[2] - Ascii_Base] | Dp_Blank;
                }
                else if(raw_adc_value >= 1000) {
                   digits[0] = ca_mask[str_ADCVAlue[0] - Ascii_Base] | Dp_Blank;
                   digits[1] = ca_mask[str_ADCVAlue[1] - Ascii_Base] | Dp_Blank;
                   digits[2] = ca_mask[str_ADCVAlue[2] - Ascii_Base] | Dp_Blank;
                   digits[3] = ca_mask[str_ADCVAlue[3] - Ascii_Base] | Dp_Blank;
                }
              
                previous_raw_adc_value = raw_adc_value;
           }
    }
}

Code:
#define Ascii_Base 0x30
#define Dp_Blank   0x80;
#define Blank      0xFF

#define SSD_DATA_PORT PORTD
#define SSD_CTRL_PORT PORTB

unsigned char digits[4] = {0, 0, 0, 0};
unsigned char digit = 0;
unsigned char ca_mask[10] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};

unsigned int raw_adc_value = 0, previous_raw_adc_value = 1024;
unsigned int tmp = 0;

char str_ADCValue[17];

//Timer1 Prescaler = 0; Preload = 3999; Actual Interrupt Time = 1 ms
void InitTimer1() {
    SREG_I_bit = 1;
    TCCR1A = 0x00;
    TCCR1B = 0x09;
    OCR1AH = 0x0F;
    OCR1AL = 0x9F;
    OCIE1A_bit = 1;
}

void Timer1Overflow_ISR() org IVT_ADDR_TIMER1_COMPA {
    //Enter your code here
    SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x0F;

    switch(digit) {
         case 0:
              SSD_DATA_PORT = digits[0];
              SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x0E;
              break;
         case 1:
              SSD_DATA_PORT = digits[1];
              SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x0D;
              break;
         case 2:
              SSD_DATA_PORT = digits[2];
              SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x0B;
              break;
         case 3:
              SSD_DATA_PORT = digits[3];
              SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x07;
              break;
    };

    if(++digit >= 4) {
        digit = 0;
    }
}

void main() {

    PORTB = 0x0F;
    PORTC = 0x00;
    PORTD = 0xFF;
   
    DDRB = 0x0F;
    DDRC = 0b1111011;
    DDRD = 0xFF;

    Delay_ms(100);

    InitTimer1();

    while(1) {

           raw_adc_value = ADC_Read(2);
           Delay_ms(2);
           
           if(previous_raw_adc_value != raw_adc_value) {
                tmp = raw_adc_value;
               
                if((raw_adc_value >= 0) && (raw_adc_value < 10)) {
                   digits[0] = Blank;
                   digits[1] = Blank;
                   digits[2] = Blank;
                   digits[3] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                }
                else if((raw_adc_value >= 10) && (raw_adc_value < 100)) {
                   digits[0] = Blank;
                   digits[1] = Blank;
                   digits[3] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                   digits[2] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                }
                else if((raw_adc_value >= 100) && (raw_adc_value < 1000)) {
                   digits[0] = Blank;
                   digits[3] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                   digits[2] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                   digits[1] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                }
                else if(raw_adc_value >= 1000) {
                   digits[3] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                   digits[2] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                   digits[1] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                   digits[0] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                }
               
                previous_raw_adc_value = raw_adc_value;
           }
    }
}
 

Attachments

Last edited:

Thread Starter

devjeetmandal

Joined May 7, 2017
48
sorry brother i was having fever for few days.. i was unable to check your work.. thank you so much for your help.. i believe this will work.. but i will check and let you know.. thanks again for your work.
 

pauzan

Joined Mar 11, 2019
9
Hi, i'am trying this and it's work.
But, i'm still confuse how to display number (example: a voltage value) in comma?
for example: 05.60. can you help me?
Thank you
 

pauzan

Joined Mar 11, 2019
9
Hi jayanth,
I,m trying this and it's work.
But how to display number in comma? for example: 05.30.
Thank you in advance.


I have completed the project and it is working fine.

Find the attached project file. See the Proteus Simulation video inside.




Code:
#define Ascii_Base 0x30
#define Dp_Blank   0x80;
#define Blank      0xFF

#define SSD_DATA_PORT PORTD
#define SSD_CTRL_PORT PORTB

unsigned char digits[4] = {0, 0, 0, 0};
unsigned char digit = 0;
unsigned char ca_mask[10] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};

unsigned int raw_adc_value = 0, previous_raw_adc_value = 1024;

char str_ADCValue[17];

//Timer1 Prescaler = 0; Preload = 3999; Actual Interrupt Time = 1 ms
void InitTimer1() {
    SREG_I_bit = 1;
    TCCR1A = 0x00;
    TCCR1B = 0x09;
    OCR1AH = 0x0F;
    OCR1AL = 0x9F;
    OCIE1A_bit = 1;
}

void Timer1Overflow_ISR() org IVT_ADDR_TIMER1_COMPA {
    //Enter your code here
    SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x0F;

    switch(digit) {
         case 0:
              SSD_DATA_PORT = digits[0];
              SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x0E;
              break;
         case 1:
              SSD_DATA_PORT = digits[1];
              SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x0D;
              break;
         case 2:
              SSD_DATA_PORT = digits[2];
              SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x0B;
              break;
         case 3:
              SSD_DATA_PORT = digits[3];
              SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x07;
              break;
    };

    if(++digit >= 4) {
        digit = 0;
    }
}

void main() {

    PORTB = 0x0F;
    PORTC = 0x00;
    PORTD = 0xFF;

    DDRB = 0x0F;
    DDRC = 0b1111011;
    DDRD = 0xFF;

    Delay_ms(100);

    InitTimer1();

    while(1) {

           raw_adc_value = ADC_Read(2);
           Delay_ms(2);
        
           if(previous_raw_adc_value != raw_adc_value) {
                IntToStr(raw_adc_value, str_ADCValue);
                Ltrim(str_ADCValue);
            
                if((raw_adc_value >= 0) && (raw_adc_value < 10)) {
                   digits[0] = Blank;
                   digits[1] = Blank;
                   digits[2] = Blank;
                   digits[3] = ca_mask[str_ADCVAlue[0] - Ascii_Base] | Dp_Blank;
                }
                else if((raw_adc_value >= 10) && (raw_adc_value < 100)) {
                   digits[0] = Blank;
                   digits[1] = Blank;
                   digits[2] = ca_mask[str_ADCVAlue[0] - Ascii_Base] | Dp_Blank;
                   digits[3] = ca_mask[str_ADCVAlue[1] - Ascii_Base] | Dp_Blank;
                }
                else if((raw_adc_value >= 100) && (raw_adc_value < 1000)) {
                   digits[0] = Blank;
                   digits[1] = ca_mask[str_ADCVAlue[0] - Ascii_Base] | Dp_Blank;
                   digits[2] = ca_mask[str_ADCVAlue[1] - Ascii_Base] | Dp_Blank;
                   digits[3] = ca_mask[str_ADCVAlue[2] - Ascii_Base] | Dp_Blank;
                }
                else if(raw_adc_value >= 1000) {
                   digits[0] = ca_mask[str_ADCVAlue[0] - Ascii_Base] | Dp_Blank;
                   digits[1] = ca_mask[str_ADCVAlue[1] - Ascii_Base] | Dp_Blank;
                   digits[2] = ca_mask[str_ADCVAlue[2] - Ascii_Base] | Dp_Blank;
                   digits[3] = ca_mask[str_ADCVAlue[3] - Ascii_Base] | Dp_Blank;
                }
            
                previous_raw_adc_value = raw_adc_value;
           }
    }
}

Code:
#define Ascii_Base 0x30
#define Dp_Blank   0x80;
#define Blank      0xFF

#define SSD_DATA_PORT PORTD
#define SSD_CTRL_PORT PORTB

unsigned char digits[4] = {0, 0, 0, 0};
unsigned char digit = 0;
unsigned char ca_mask[10] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};

unsigned int raw_adc_value = 0, previous_raw_adc_value = 1024;
unsigned int tmp = 0;

char str_ADCValue[17];

//Timer1 Prescaler = 0; Preload = 3999; Actual Interrupt Time = 1 ms
void InitTimer1() {
    SREG_I_bit = 1;
    TCCR1A = 0x00;
    TCCR1B = 0x09;
    OCR1AH = 0x0F;
    OCR1AL = 0x9F;
    OCIE1A_bit = 1;
}

void Timer1Overflow_ISR() org IVT_ADDR_TIMER1_COMPA {
    //Enter your code here
    SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x0F;

    switch(digit) {
         case 0:
              SSD_DATA_PORT = digits[0];
              SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x0E;
              break;
         case 1:
              SSD_DATA_PORT = digits[1];
              SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x0D;
              break;
         case 2:
              SSD_DATA_PORT = digits[2];
              SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x0B;
              break;
         case 3:
              SSD_DATA_PORT = digits[3];
              SSD_CTRL_PORT = (SSD_CTRL_PORT & 0xF0) | 0x07;
              break;
    };

    if(++digit >= 4) {
        digit = 0;
    }
}

void main() {

    PORTB = 0x0F;
    PORTC = 0x00;
    PORTD = 0xFF;
 
    DDRB = 0x0F;
    DDRC = 0b1111011;
    DDRD = 0xFF;

    Delay_ms(100);

    InitTimer1();

    while(1) {

           raw_adc_value = ADC_Read(2);
           Delay_ms(2);
         
           if(previous_raw_adc_value != raw_adc_value) {
                tmp = raw_adc_value;
             
                if((raw_adc_value >= 0) && (raw_adc_value < 10)) {
                   digits[0] = Blank;
                   digits[1] = Blank;
                   digits[2] = Blank;
                   digits[3] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                }
                else if((raw_adc_value >= 10) && (raw_adc_value < 100)) {
                   digits[0] = Blank;
                   digits[1] = Blank;
                   digits[3] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                   digits[2] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                }
                else if((raw_adc_value >= 100) && (raw_adc_value < 1000)) {
                   digits[0] = Blank;
                   digits[3] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                   digits[2] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                   digits[1] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                }
                else if(raw_adc_value >= 1000) {
                   digits[3] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                   digits[2] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                   digits[1] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                   digits[0] = ca_mask[tmp % 10] | Dp_Blank; tmp /= 10;
                }
             
                previous_raw_adc_value = raw_adc_value;
           }
    }
}
 
Top