2015-03-15 09:52 AM
2015-03-15 12:57 PM
Could it be because max DMA transfer size is 64k elements ?
(240x320 => 76800, truncated to 11264 on a 16bit register)2015-03-15 02:28 PM
This is the first time that I hear about some kind of DMA stream restriction...
Why then the DCMI and DMA works....you mean that the DCMI->DR transfers when is full...bacically 38400 x....and with SPI and DMA I want 153600 transfers?2015-03-15 05:28 PM
DMA_InitStructure.DMA_BufferSize is 16-bits, ie 0..65535 bytes, half-words or word
38400 fits, 153600 clearly does not.2015-03-16 11:35 AM
Wow I really didnt know that... So is there a way how to use SPI over DMA with QVGA image? I cant think of anything....Probably redefing the DMA over and over...
Thats stupid right? Problem is that I have to send the data as bytes...That means that I would had to redefine the DMA 4 times for one frame....EDIT: Actually I made it work...It's not elegant but it works...2015-03-16 03:11 PM
OK, so I get that DMA buffer has a limit but I totally dont get how is the transfer driven...The code below is from two diferent versions of the SW...It's not together but I think it's a good example so I just want to explanation how is the DMA behaving...
When I want to copy data from DCMI (32 bit register) to some kind of frame buffer (16 bit array uint16_t frame_buffer[320*240]) then buffer size 38400 is enough and it works well. Then I woud say, yeah the increment is driven by the DCMI register that is 32bit.DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t) (&DCMI->DR); DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t) frame_buffer; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_BufferSize = 320*240*2/4; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;But when I want to for example copy data from SDRAM to SPI for transfer. Now if I follow the same logic because the source is 32 bit than 38400 sould also be enough. But it's not... buffer size 38400 makes only 1/4 od the image...why is now the transfer driven by individual bytes therefore I would need 4*38400= 153600??DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t) p_img; DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t) &(ILI9341_SPI->DR); DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; DMA_InitStructure.DMA_BufferSize = 320*240*2/4; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;2015-03-17 02:17 AM
The explanation is *very* simple: when peripheral and memory data width are different, the number of transfers refers to the width on the peripheral bus. DCMI has word size transfers, so buffersize is 320*200*2/4. Good. SPI has byte size transfers, so buffersize muste be 320*200*2=128000, which is obviously not possible because of the size of NDT register. RTFM 10.3.10 ''Programmable data width''.
To solve you case, you must deal with multiple DMA transfers. Two 64000 transfers should be enough.2015-03-17 03:52 AM
Thanks Gonzalez...So basically peripheral memory width is always the one that determines the number of transfers...
The multiple DMA transfers are a solution and it works well...I just wanted to know what is the system behind it...For me it's not 320x200x2 but 320x240x2=153600 so I need three DMA transfers in total... Anyway thanks for your help...