问题标签 [spi]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
2315 浏览

arduino - 使用 SPI 写入外部 EEPROM

我正在尝试写入一个单独的设备的 EEPROM 以配置该设备的行为,并使用 Arduino Uno 控制该设备。

根据这个网页,我的 SCK 连接到引脚 13,我的 SDA 连接到引脚 11。

我有两个函数,i2c_eeprom_write_bytei2c_eeprom_read_byte,取自这个例子

我的问题是它Wire.available()总是返回 0,这意味着从设备没有向主设备 Arduino 发送任何内容。

如何从从设备读取数据?

0 投票
0 回答
102 浏览

java - 用于 Java 本地化的 SPI

关于语言环境的 SPI 包(服务提供者接口)。直接来自这个oracle java 教程

这些方法首先检查 Java 运行环境是否支持请求的语言环境;如果是这样,他们会使用这种支持。否则,这些方法会调用已安装提供程序的 getAvailableLocales() 方法以获取相应接口,以找到支持所请求语言环境的提供程序。

一旦我创建了一个 spi 接口并通过覆盖所有需要的方法来实现它,我如何安装该类以使该类在运行时可见?

提前致谢。

0 投票
0 回答
230 浏览

kernel - 龙板SPI时钟问题

我正在研究龙板,我需要将 SPI 设备与龙板的 SPI_QUP 模块连接。QUP 模块连接在 msm8960 的 GSBI1 上。我成功运行 SPI 并在示波器上获得了适当的波形。我观察到它将默认以 10M 的时钟速率发送数据,当我尝试降低其时钟速率时,我无法将其降低到 5M 以下。如果我将其降低到 5M 以下,它将开始以默认速率(10M )。与此相比,我的间谍设备的运行速度非常慢(大约 3M Max 时钟速度)。有没有办法把它降低到5M以下?

谢谢。

0 投票
2 回答
3244 浏览

vhdl - 试图在 vhdl 中实现 spi 总线

我一直在尝试通过 SPI 与 LTC2426 DAC 通信,但我失败了。现在我正在寻求帮助。有人可以告诉我为什么我的代码不起作用。CSDAC 工作正常,生成 SCLK 并发送 32 位,但我仍然可能搞砸了时序。我会非常感谢 şf 有人帮我修复代码。

编辑:新代码

我正在脉冲 MOSI,因为当我发送几个位时,SCLK 会恢复。第一个 SCLK 以大约 1.4 mhz 运行,当我将 mosi 脉冲恢复到 4.167 MHZ 注意 1.4 mhz 左右它可能是 1.5 mhz 我记不起它太好了。

0 投票
2 回答
4999 浏览

linux - SPI:Linux驱动模型

我是 SPI 的新手;Linux 内核提供了一个 API,用于声明 SPI 总线和设备,并根据标准 Linux 驱动程序模型管理它们。

您可以在此处找到 struct spi_master 的描述:https ://www.kernel.org/doc/htmldocs/device-drivers/API-struct-spi-master.html

上面链接中的描述说“每个设备都可以配置为使用不同的时钟速率,因为除非选择芯片,否则这些共享信号将被忽略”。要将句子放在比赛中,我不得不说,“设备”是指 SPI 从设备,而“那些共享信号”是指 MOSI、MISO 和 SCK 信号。

事实上,在 struct spi_device ( https://www.kernel.org/doc/htmldocs/device-drivers/API-struct-spi-device.html ) 中有一个名为 max_speed_hz 的属性在 struct spi_master 中不存在. 所以我可以理解上面陈述的第一部分:“每个设备都可以配置为使用不同的时钟速率”。

但是,第二部分是什么意思?“因为除非选择芯片,否则这些共享信号将被忽略”是否意味着我可以通过启用/禁用具有不同速率的从机来使用不同的时钟速率,但一次只能使用一个?

谢谢您的帮助!问候,

——马特奥

0 投票
1 回答
795 浏览

linux - 在linux中读取数据之前手动控制芯片选择?

您好我有一个带有 24 个键的 SPI 触摸设备,每次读取将返回 3 个字节,包含所有 24 个键的状态。我的硬件是定制的类似 beaglebone 的设备,spi0 能够通过将 MISO 连接到 MOSI 来读取自己的写入。

一切(接线、软件)都与本指南完美匹配:http: //communistcode.co.uk/blog/blogPost.php ?blogPostID=1

现在我的触摸设备是 CS 高电平有效设备,但它需要在实际读取之前将片选驱动为低电平并返回高电平。我似乎无法控制 SPI cs 值,我只能在实际读取阶段通过指定 CS 高或低来控制它。据我所知,我必须使用另一个 GPIO 来模拟 CS。

问:有什么办法可以自由控制cs?(即直接通过我的代码设置 0 或 1?)

0 投票
1 回答
559 浏览

optimization - 与 sd 卡 arduino 通信

我在与 Arduino 上的 sd 卡通信时遇到问题。我做了这个配置。我有一个 Arduino Mega,所以代码是:

我在以太网屏蔽上有 SD。所以我注意到有时我在 SD 上出现错误,有时我已经准备好了。当我插入以太网电缆时会出现一些错误,但这不仅是我在没有插入电缆时也会出错的原因。

0 投票
0 回答
2204 浏览

c - DMA interrupt for SPI

I'm trying to recreate a project of writing to an SD card (using FatFS) for a dsPIC33FJ128GP802 microcontroller.

Currently to collect the date from the SPI I have a do/while that loops 512 times and writes a dummy value to the SPI buffer, wait for the SPI flag, then read the SPI value, like so:

I'm trying to recreate this using the DMA intterupts but it's not working like I had hoped. I'm using one DMA channel, SPI is in 8 bit mode for the time being, so DMA is in byte mode, it's also in 'null write' mode, and continuous without ping pong. My buffers are only one member arrays and the DMA is matched.

From what I understand from the null write mode, the DMA will write a null value every time a read is performed. However, the DMA wont start until an initial write is performed by the CPU, so I've used the manual/force method to start the DMA.

The interrupt will now start, and runs without error. However the code later shows that the collection was incorrect.

My interrupt is simple in that all I'm doing is placing the collected data (which I assume is placed in my DMAs buffer as allocated above) into a pointer which is used throughout my program.

When the interrupt has run 512 times, I stop the DMA and throw a flag.

What am I missing? How is this not the same as the non-DMA method? Is it perhaps the lack of the while loop which waits for the completion of the SPI transmission (while (!_SPIRBF);). Unfortunately with the null write mode automatically sending and receiving the SPI data I can't manually put any sort of wait in.

I've also tried using two DMA channels, one to write and one to read, but this also didn't work (plus I need that channel later for when I come to proper writing to the SD card).

Any help would be great!

0 投票
1 回答
2483 浏览

linux - 只能从 ioremap() 内存中读取 0

我正在为 linux 开发一个简单的驱动程序,它将通过 SPI 与设备通信。在我使用 request_mem_region 和 ioremap 之后,即使在我向其写入值之后,我可以从返回的地址读取的所有内容都是 0。偏移量 0 处的地址应该是 SPI 控制器(它是 Xilinx Zynq SoC)的控制寄存器。在引导过程中,控制寄存器被设置为初始值。

代码:

插入模块时的输出是:
驱动程序初始化完成。映射到地址 0xE08C2000
0

提前感谢您的帮助。

0 投票
2 回答
2490 浏览

c - How to transmit and receive data using SPI with LPC1788

I'm trying to write a program using the LPC1788 microcontroller, and I need to send and transmit data to a UFDC (universal frequency-to-digital converter) using SPI protocol. A datasheet for this can be found here. My microcontroller's SSP controller is set as the master and the UFDC presumably becomes the slave. I'm able to transmit information down the MOSI line and see the data appear on an oscilloscope. However, when I try to receive data on the MISO line, I only get back what I sent down the MOSI.

Here is a picture of the schematic.

The relevant part of the code I've written is below:

The output I'm getting from this is below:

Edit: It's possible to set "loop back enable" with the SPI controllers to make the MOSI read input from the MISO and vice versa. However, I've checked the relevant register and this is disabled.