Io_test of openMSP430, open‑io_test

Source: Internet
Author: User

Io_test of openMSP430, open‑io_test

 

OpenMSP430: IO functionality test with interupt

#include "omsp_system.h"volatile char shift = 0x01;  // Global variable int main(void) 
{ WDTCTL = WDTPW | WDTHOLD; // Disable watchdog timer P2DIR = 0xff; // Port 2.0-2.7 = output P2OUT = shift;       // Initialize Port 2 P1DIR = 0x00; // Port 1.0-1.7 = input P1IE = 0x01; // Port 1.0 interrupt enabled P1IES = 0x00; // Port 1.0 interrupt edge selection (0=pos 1=neg) P1IFG = 0x00; // Clear all Port 1 interrupt flags (just in case) eint(); // Enable interrupts while (1)
  { if (P2OUT == 0x00)
   {     P2OUT = shift;  }
    else if (shift == 0x01)
    {
     P2OUT = (P2OUT << 1); }
    else
    {    P2OUT = (P2OUT >> 1); } }} // Port1 Interrupt Service Routineinterrupt(PORT1_VECTOR) port1_isr(void)
{ if (P1IFG & 0x01)
{ shift  ^= 0x81; P1IFG &= ~0x01;  // Clear Port 1.0 interrupt flag }}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.