Incorrect MSP 430 Values ​​Displayed

I am developing a pressure measuring device. I used the MSP430F133 chip and used the built-in IAR workbench. It shows pressure in three different units.

I take 32 samples and average them. The selection of the block on P5 according to the selected output value of the device is calculated and displayed on the LCD.

Now the "IN WC" block shows a binary averaged input scale, for analysis only.

Problem: the default values ​​(MM WC) are displayed correctly, but in a test situation, when the pressure is released, it drops, and the LCD is read below

+31.8
+31.7
+31.6
+31.5
+31.4
+31.3
+31.2
+31.2
+31.1
+31.5 (wrong reading randomly between *.4 to *.7)
+30.9

As you can, one wrong value is displayed, I can not understand the reason.

+3
source share
5

ptiveValue = d1 = , d2 0,    (i = 0; <= 3 || res [i]!= '\ 0'; ++)    (i = 0; <= 3 & res [i]!= '\ 0'; ++) , , ,

:

if (cntd <= 4)
{
    d2 = (unsigned int) abs((ptiveValue - d1) * 10000); // get 4 digits of real part
    itoa1(d2, res, &cntreal);  
    for (i=0; i<= 3||res[i]!='\0'; i++)
    {
       wr_lcd_dr(res[i]);

    }
 }

if (cntd <= 4)
{   
    // get 4 digits of real part
    d2 = (unsigned int) ((ptiveValue - (unsigned int)(d1)) * 10000); 
    itoa1(d2, res, &cntreal);  
    for (i=0; (i<= 3) && (res[i]!='\0'); i++)
    {
       wr_lcd_dr(res[i]);     
    }
 }

, , .

unsigned short Adcinb[32];
for (i = 0; i <= 63; i++)
Adcinb[i] = 3180;

unsigned short Adcinb[32];
for (i = 0; i < 32; i++)
Adcinb[i] = 3180;
+4

, . , , , "" . , - . ( "31", 3 ).

"||" /'& &' , , , , .

" " (TM), , , .

+2

, || , & &:

        for (i=0; i<= 3||res[i]!='\0'; i++)

, .

, . .

+1

- ADC 101, . , . : De-bouncing by Jack G. Ganssle

, , , . , !

: , , , , , . .

+1

, - , , .

32 , , ?

, , .

-Adam

0

Source: https://habr.com/ru/post/1703917/


All Articles