专注电子技术学习与研究
当前位置:单片机教程网 >> MCU设计实例 >> 浏览文章

XS128单片机实验:读取拨码开关值

作者:韩冰   来源:本站原创   点击数:  更新时间:2013年11月30日   【字体:


#include <hidef.h>      /* common defines and macros */
#include "derivative.h"      /* derivative-specific definitions */
/*********************************************************
//功能: 读取PORTA口拨码开关状态,通过portb 口的LED灯显示
//This is the third program of mine
//已通过硬件验证;
//Date:  2013/4/13
*********************************************************/
void main(void) {
   unsigned char sw_value;      //定义变量,记录拨码开关设置值
 
   DDRA = 0X00;                 //定义A口为输入口
   DDRB = 0XFF;                 //定义B口为输出口
   while(1){           
    sw_value = PORTA;
    PORTB    = sw_value;
   }
}
 

关闭窗口

相关文章