Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

bug in msp430g2xx3_pinosc_01.c

$
0
0

tried out the capacitive touch code examples.

 

msp430g2xx3_pinosc_01c did not work for me, LEDs blink all

the time, without touching anything.

 

So I tried msp430g2xx3_pinosc_02c (4 channel) . Works a treat.

 

Compared the code and found the bug: from line 159 in msp430g2xx3_pinosc_01c :

 

     if (delta_cnt > j)                    // Determine if each key is pressed 
      {                                     // per a preset threshold
        j = delta_cnt;
        key_pressed = 1;                    // key pressed
      }
      else
        key_pressed = 1;
 
 
looks like key_pressed is forced to 1 ;-)
 
 
changed it to this (same as in pinosc_02c) it works as expected
 
 
     if (delta_cnt > j)                    // Determine if each key is pressed 
      {                                     // per a preset threshold
        j = delta_cnt;
        key_pressed = 1;                    // key pressed
      }
      else
        key_pressed = 0;
 
 
haha... 
 
MSP430 code examples are self-contained low-level programs that typically
 * demonstrate a single peripheral function or device feature in a HIGHLY
 * CONCISE MANNER.
 
At least I had a close look at the code for finding the bug...
 
 

Viewing all articles
Browse latest Browse all 2077

Trending Articles