这段代码是用九齐NY8写的,目的是现实按键开关LED,但是下载到ICE单击按键,没有任何反应,附上原理图如下:
#include <ny8.h>
#include <stdint.h>
#include "ny8_constant.h"
#define UPDATE_REG(x) __asm__("MOVR _" #x ",F")
unsigned char Trg; //全局变量“按键触发”
unsigned char Cont; //全局变量“连续按下”
__sbit key = PORTB:0; //按键是PB0
__sbit light1 = PORTA:7; //LED是PA7
void Keyread() //按键扫描
{
unsigned char ReadData = PORTB ^ 0xFF; //读PORTB的端口数据,取反,然后送到ReadData临时变量保存
Trg = ReadData & (ReadData ^ Cont); //用来计算触发变量的。一个位与操作,一个异或操作
Cont = ReadData; //保存Cont其实就是等于ReadData
}
void main(void)
{
IOSTA = ~IOSTA; //A口为输出
PORTA = 0xFF;
IOSTB = C_PB0_Input; //PB0为输入
while(1)
{
Keyread(); //调用子函数
if (Trg & key) //判断按键是否按下
{
light1 = ~light1; //LED取反
}
}
}
有知道原因的大神希望指定下,不甚感激!
下面是我自己做的最小系统板,连接ICE使用的。