- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用连接到 FPGA 的 FT232H 设备,我正在尝试向其写入一些字节。读(转FPGA->PC)完美,写(转PC->FPGA)根本不行。我正在使用以下代码:
libusb_open(board, &board_handle);
if (libusb_kernel_driver_active(board_handle, 0) == 1) {
if(libusb_detach_kernel_driver(board_handle, 0) == 0);
}
libusb_set_configuration(board_handle, 1);
libusb_claim_interface(board_handle, 0);
libusb_control_transfer(board_handle, 0x40, 0x0B, 0x00FF, 0x01, NULL, 0, 5000);
libusb_control_transfer(board_handle, 0x40, 0x0B, 0x40FF, 0x01, NULL, 0, 5000);
libusb_bulk_transfer(board, 0x02, bufout, 3, &transfered, 5000);
bufin = calloc(512, 1);
libusb_bulk_transfer(board, 0x81, bufin, 512, &transfered, 5000);
Bufout
填充了数据。当我尝试将 FPGA 上生成的一些数据发送到 PC 时没有问题; bufin
填充了正确的数据。
但是当我尝试将一些数据发送到 FPGA,并将其显示在 LED 上或发回时,问题就出现了。
无论 bufout
内容如何,我在 FPGA 站点收到的每个字节都是 0xFF。 Bufout
和 bufin
都声明为 unsigned char *。
unsigned char *bufin, *bufout;
令人惊讶的是(或者不是)FPGA 接收到的字节数与 PC 发送的字节数匹配,但所有字节的值为 0xFF。
我做错了什么吗?
我试过使用 libftdi,但效果是一样的(我认为 libftdi 使用 libusb 作为引擎并不奇怪)。
也许我忘了在主机端调用一些重要的功能?
FPGA端的代码也很简单:
process(ftdi_clk, sys_rst)
begin
if sys_rst = '0'then
ftdi_wr <= '1';
ftdi_data <= "ZZZZZZZZ";
ftdi_rd <= '1';
ftdi_oe <= '1';
read <= '1';
elsif rising_edge(ftdi_clk) then
if ftdi_txe = '0' then
ftdi_wr <= '0';
ftdi_data <= buf;
else
ftdi_wr <= '1';
ftdi_data <= "ZZZZZZZZ";
end if;
if (read = '0') and (ftdi_rxf = '0') then
ftdi_rd <= '0';
buf <= ftdi_data;
else
ftdi_rd <= '1';
end if;
if ftdi_rxf = '0' then
ftdi_oe <= '0';
read <= '0';
else
ftdi_oe <= '1';
read <= '1';
end if;
end if;
end process;
编辑:我已经检查了所有可能的电气配置、上拉、I/O 电压,一切似乎都很好。从 FTDI 传输到 FPGA 的所有数据仍然是 2 个独立芯片上的数据,因此很可能是软件问题。我已经检查了模拟,甚至是适配后模拟,通信应该根据文档进行。
EDIT2:我尝试过使用原始供应商库。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ftd2xx.h>
int main(){
FT_STATUS ftStatus;
FT_HANDLE ftHandle;
DWORD BytesWritten;
unsigned char data[512];
int i;
FT_PROGRAM_DATA ftData = {
0x00000000, 0xFFFFFFFF, // Headers
0x00000005, // Version (5 = 232H)
0x0403, 0x6014, // VID:PID
"StackOverflow", "Stack", "StackBoard", NULL,
500, 0, 1, 1, // MaxPower, PnP, SelfPowered, Remote WakeUp
// FT232B
0, 0, 0, 0, 0, 0, 0,
// FT2232
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// FT232R
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// FT2232H
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,
// FT4232H
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0,
// FT232H
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0,
};
ftStatus = FT_Open(0, &ftHandle);
ftStatus = FT_SetTimeouts(ftHandle, 5000, 5000);
ftStatus = FT_EE_Program(ftHandle, &ftData);
ftStatus = FT_EE_Program(ftHandle, &ftData);
ftStatus = FT_SetBitMode(ftHandle, 0xFF, FT_BITMODE_SYNC_FIFO);
for(i = 0; i<512; i++) data[i] = 0x02;
ftStatus = FT_Write(ftHandle, data, 512, &BytesWritten);
printf("%d bytes written\n", BytesWritten);
ftStatus = FT_Read(ftHandle, &data, 512, &BytesWritten);
printf("%d bytes read\n", BytesWritten);
for(i = 0; i<BytesWritten; i++) printf("%#2x ", data[i]);
FT_Close(ftHandle);
}
仍然是完全相同的行为。我已将 Linux 内核更新到最新版本 (4.2.3),但结果是一样的。遗憾的是,我检查了几台不同的机器和 3 种不同的芯片。
最佳答案
不确定这是否是您唯一的问题,但我认为您在 ftdi_data 上发生了一些短路。它可以在 ftdi_oe 处于事件状态的同时由 FPGA 驱动。
关于c - 用FT245同步方式写入芯片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33169125/
我正在实现 IMAP 客户端,但 IMAP 邮箱同步出现问题。 首先,可以从 IMAP 服务器获取新邮件,但我不知道如何从邮箱中查找已删除的邮件。 我是否应该从服务器获取所有消息并将其与本地数据进行比
我研究线程同步。当我有这个例子时: class A { public synchronized void methodA(){ } public synchronized void met
嗨,我做了一个扩展线程的东西,它添加了一个包含 IP 的对象。然后我创建了该线程的两个实例并启动它们。他们使用相同的列表。 我现在想使用 Synchronized 来阻止并发更新问题。但它不起作用,我
我正在尝试使用 FTP 定期将小数据文件从程序上传到服务器。用户从使用 javascript XMLHttpRequest 函数读取数据的网页访问数据。这一切似乎都有效,但我正在努力解决由 FTP 和
我不知道如何同步下一个代码: javascript: (function() { var s2 = document.createElement('script'); s2.src =
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 7 年前。 Improve this qu
一 点睛 1 Message 在基于 Message 的系统中,每一个 Event 也可以被称为 Message,Message 是对 Event 更高一个层级的抽象,每一个 Message 都有一个
一 点睛 1 Message 在基于 Message 的系统中,每一个 Event 也可以被称为 Message,Message 是对 Event 更高一个层级的抽象,每一个 Message 都有一个
目标:我所追求的是每次在数据库中添加某些内容时(在 $.ajax 到 Submit_to_db.php 之后),从数据库获取数据并刷新 main.php(通过 draw_polygon 更明显)。 所
我有一个重复动画,需要与其他一些 transient 动画同步。重复动画是一条在屏幕上移动 4 秒的扫描线。当它经过下面的图像时,这些图像需要“闪烁”。 闪烁的图像可以根据用户的意愿来来去去和移动。它
我有 b 个块,每个块有 t 个线程。 我可以用 __syncthreads() 同步特定块中的线程。例如 __global__ void aFunction() { for(i=0;i #
我正在使用azure表查询来检索分配给用户的所有错误实体。 此外,我更改了实体的属性以声明该实体处于处理模式。 处理完实体后,我将从表中删除该实体。 当我进行并行测试时,可能会发生查询期间,一个实体已
我想知道 SQLite 是如何实现它的。它基于文件锁定吗?当然,并不是每个访问它的用户都锁定了整个数据库;那效率极低。它是基于多个文件还是仅基于一个大文件? 如果有人能够简要概述一下 sqlite 中
我想post到php,当id EmpAgree1时,然后它的post变量EmpAgree=1;当id为EmpAgree2时,则后置变量EmpAgree=2等。但只是读取i的最后一个值,为什么?以及如何
CUBLAS 文档提到我们在读取标量结果之前需要同步: “此外,少数返回标量结果的函数,例如 amax()、amin、asum()、rotg()、rotmg()、dot() 和 nrm2(),通过引用
我知道下面的代码中缺少一些内容,我的问题是关于 RemoteImplementation 中的同步机制。我还了解到该网站和其他网站上有几个关于 RMI 和同步的问题;我在这里寻找明确的确认/矛盾。 我
我不太确定如何解决这个问题......所以我可能需要几次尝试才能正确回答这个问题。我有一个用于缓存方法结果的注释。我的代码目前是一个私有(private)分支,但我正在处理的部分从这里开始: http
我对 Java 非常失望,因为它不允许以下代码尽可能地并发移动。当没有同步时,两个线程会更频繁地切换,但是当尝试访问同步方法时,在第二个线程获得锁之前以及在第一个线程获得锁之前再次花费太长时间(比如
过去几周我一直在研究java多线程。我了解了synchronized,并理解synchronized避免了多个线程同时访问相同的属性。我编写此代码是为了在同一线程中运行两个线程。 val gate =
我有一个关于 Java 同步的简单问题。 请假设以下代码: public class Test { private String address; private int age;
我是一名优秀的程序员,十分优秀!