Digital Input/Output on custom CC430 board

Submitted by fabio on Thu, 2012-11-22 15:23.

Just a dumb video testing digital input/output on buttons in my CC430 based project.. nothing fancy but needed testing.

See the SPI LCD connector and the MPU6050 over I2C.. these will be fun!

Here is the code:

#include  <cc430x613x.h>
#include <inttypes.h>

int main(void) {
   unsigned int count;
   uint8_t but0, but1;
   
   WDTCTL = WDTPW + WDTHOLD; //Stop watchdog timer

   P2OUT = 0; //Configure P1 to output on P1.0
   P2DIR |= BIT7;
   
   P5DIR = 0; // configure P5 as input
   P5OUT |= BIT7; // turn on pulldown
   P5OUT |= BIT6;
   P5REN |= BIT6; // enable pullups
   P5REN |= BIT7;

   for(;;){
      but0 = P5IN & BIT7;
      but1 = P5IN & BIT6;
      if((!but0 || !but1)) {
        P2OUT |= BIT7;
      }
      else {
        P2OUT &= ~BIT7;
      }
   }
}
Posted in:

Post new comment

The content of this field is kept private and will not be shown publicly.
If you have a personal or company website insert its address in the form http://www.example.com/ .
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <small> <del> <img> <h2> <h3> <h4> <b> <video> <sub> <sup>
  • Lines and paragraphs break automatically.
  • Images can be added to this post.
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • You may insert videos with [video:URL]
  • Each email address will be obfuscated in a human readable fashion or (if JavaScript is enabled) replaced with a spamproof clickable link.

More information about formatting options