xtqxtq111 发表于 2011-8-2 10:08:31

FPGA是不是不能接4*4键盘啊,那个引脚的direction怎么用也不对

我写的程序嘿嘿
#include <stdio.h>
#include <unistd.h>
#include "../inc/sopc.h"

void display(int m)
{
    while (1)
    {
      F->DATA=1;
      usleep(m);
      F->DATA=0;
      usleep(m);
    };
}
void check_key()
{
   
    KEY->DIRECTION=1;
    KEY->DATA=0xFE;
    usleep(10);
    KEY->DIRECTION=0;
      if((0xFE&(KEY->DATA))==0xEE) display(1000);
      if((0xFE&(KEY->DATA))==0xDE) display(5000);
      if((0xFE&(KEY->DATA))==0xBE) display(10000);
      if((0xFE&(KEY->DATA))==0x7E) display(50000);
    KEY->DIRECTION=1;
    KEY->DATA=0xFD;
    usleep(10);
    KEY->DIRECTION=0;
      if((0xFD&(KEY->DATA))==0xED) display(100000);
      if((0xFD&(KEY->DATA))==0xDD) display(500000);
      if((0xFD&(KEY->DATA))==0xBD) display(1000000);
      if((0xFD&(KEY->DATA))==0x7D) display(5000000);
    KEY->DIRECTION=1;
    KEY->DATA=0xFB;
    usleep(10);
    KEY->DIRECTION=0;
      if((0xFB&(KEY->DATA))==0xEB) display(1000);
      if((0xFB&(KEY->DATA))==0xDB) display(5000);
      if((0xFB&(KEY->DATA))==0xBB) display(10000);
      if((0xFB&(KEY->DATA))==0x7B) display(50000);
    KEY->DIRECTION=1;
    KEY->DATA=0xF7;
    usleep(10);
    KEY->DIRECTION=0;
      if((0xF7&(KEY->DATA))==0xE7) display(100000);
      if((0xF7&(KEY->DATA))==0xD7) display(500000);
      if((0xF7&(KEY->DATA))==0xB7) display(1000000);
      if((0xF7&(KEY->DATA))==0x77) display(5000000);

}


int main()
{

    while(1)
    {
      check_key();

    };
    return 0;
}

这个程序在51单片机上面是正确的,可是在FPGA上就不能实现,我估计是我引脚用的不对。

submars 发表于 2011-9-8 09:01:53

这个程序就不能直接在FPGA上用!

xtqxtq111 发表于 2011-9-8 16:42:05

回复【1楼】submars
-----------------------------------------------------------------------

怎么能这么说啊?

xivisi 发表于 2011-9-8 16:56:49

楼主 V5

qingfengyang 发表于 2011-9-9 22:24:13

回复【楼主位】xtqxtq111
-----------------------------------------------------------------------

这位大哥,请问你是不是在用FPGA在做SOPC设计并调用了51的内核,如果不是,那么你的那段C程序是应该通不过编译的,目前FPGA主要用的是vhdl,verilog。

xtqxtq111 发表于 2011-9-11 11:05:00

回复【3楼】xivisi LiYong
-----------------------------------------------------------------------

。。。

overmountain 发表于 2011-9-11 13:21:26

我觉得是楼主在fpga上使用nios了吧,用c写的程序
页: [1]
查看完整版本: FPGA是不是不能接4*4键盘啊,那个引脚的direction怎么用也不对