zoukankan      html  css  js  c++  java
  • openMSP430之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 Routine interrupt(PORT1_VECTOR) port1_isr(void)
    {
    if (P1IFG & 0x01)
    { shift  
    ^= 0x81; P1IFG &= ~0x01;  // Clear Port 1.0 interrupt flag } }
  • 相关阅读:
    hdu 1174
    计算几何模板
    又是一年博客记
    hdu 1225 Football Score
    与逆序数有关的
    hdu 2844 Coins
    hdu 1171 Big Event in HDU
    UVA Exponentiation
    UVA Summation of Four Primes
    Linux:设置alias永久生效
  • 原文地址:https://www.cnblogs.com/mengdie/p/4572767.html
Copyright © 2011-2022 走看看