0

我正在使用 NXP LH79525,基于 ARM7TDMI 的处理器。有一个 EEPROM 通过 SPI 总线连接到 SSP 端口。

目的是将 EEPROM 读入 SRAM 以便更快地访问。

目前的工作代码向 EEPROM 发送一个读取命令,每个字节读取数据字节,这需要很长时间。

我想使用 DMA 直接读取 SPI 总线上的 EEPROM,无需 CPU 干预。

这是我的代码片段:

// Initialize the DMA for use with SPI bus.
// Source is the EEPROM on the SPI bus.
// Destination is "buffer".

p_dma_stream_2->source_low = 0U;
p_dma_stream_2->source_high = 0U;
const uint32_t dest_addr = (uint32_t) buffer;

p_dma_stream_2->dest_low = (dest_addr & 0xFFFFU);
p_dma_stream_2->dest_high = (dest_addr >> 16U);

p_dma_stream_2->max_count = bytesToRead;

*p_dma_intr_mask = 0U;  // Disable all dma interrupts.
*p_dma_intr_clear = 0xFF;   // Clear the interrupts.

SSP->dmacr = 0x01;  // Enable reading with DMA

p_dma_stream_2->control = 0x06U; // + 0x01 to enable transfer.

// 0x400 - status of stream 2. 1 == stream is active.

uint32_t status = *p_dma_status;
while ((status & 0x400U) != 0U)
{
    OSTimeDelay(10U); // 10 milliseconds
    status = *p_dma_status;
}

使用上述示例时,我从 EEPROM 中读取了不正确的值。
DMA 寄存器计数正确。SSP 在此代码片段之前已经初始化,用于读取字节。

我正在寻找一个有效的代码示例片段,但在网上没有找到。

4

1 回答 1

0

根据本用户指南表 5-1,似乎 SSPRX 被分配给流 0,并且仅支持半字源数据宽度(表 5-15)。

您的代码似乎使用 Stream 2 和字节寻址。

于 2014-03-20T21:22:06.977 回答