This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SPRUFP0 and DMA addressing

I am a little confused as to the address translation between the CPU space and the DMA space. Reading some sample code in dma_bypass1.c for the USB stick AudioFilter example they take a word address << 1 and add 0x10000. This makes sense to me but when I read SPRUFP0 I have a conflict between Figure 2 and Table 2. In figure 2 they state that the first 192 bytes of CPU space is reserved for MMR. This would be between 00000h – 000C0h for the CPU and 10000h-10180h for the DMA this would be the same as the conversion from word address to DMA byte addressing. My problem is both state they are byte address. And in Table 2 there is no left shift by two. Is the problem only in the 10180h in that it should be 100C0h or is Table 2 incorrect?   

  • I don't think that you're supposed to add 10000h unless that's where your memory is allocated.  My firmware is using both 00000h (DARAM) and 10000h (SARAM) for various data elements, and thus you just shift the address before placing it in the DMA registers.  This is all highly dependent upon your LKR file, and where you've placed things in memory.  Your linker file should block out 00000h - 000C0h, and so long as you do that then you can just use the properly-shifted address without adding the offset.  I haven't looked at the dma_bypass1.c sample code that you mention, but I have a feeling that the offset used there is a by-product of the linking.

    Just keep in mind that the DMA address is a byte address.  Other pieces of your source may involve word addresses, which is the reason you need the shift operation (to convert from word address to byte address).  Apart from that, there should generally be no offset.

    In addition, I believe that the MMR remains at 00000h - 000C0h no matter what memory model you compile with.