我使用的是基于恩智浦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在此代码段之前已经初始化,用于读取字节。
我正在寻找一个工作的代码示例片段,但没有在网上找到任何。
发布于 2014-03-21 05:22:07
根据该User's Guide表5-1,似乎SSPRX被分配给流0,并且仅支持半字源数据宽度(表5-15)。
您的代码似乎使用了流2和字节地址。
https://stackoverflow.com/questions/22544603
复制相似问题