xdata_sfr_address

Hello.

In your last post, it sounded like you were able to get the ADC working with the DMA by using these lines:

dmaConfig._2.SRCADDRH = XDATA_SFR_ADDRESS(ADC) >> 8;
dmaConfig._2.SRCADDRL = XDATA_SFR_ADDRESS(ADC);

I would expect that those lines of code set SRCADDRH to 0xDF and set SRCADDRL to 0xBA, meaning that the DMA will access the XDATA address 0xDFBA. If you look at Figure 14 in Section 10.2.1 of the CC2511 datasheet, you can verify that the XDATA address 0xDFBA would map to the SFR address 0xBA. Then if you look at Table 30 in section 10.2.3.3, you can see that SFR address 0xBA corresponds to the register ADCL. So the lines of code above should result in your DMA channel pointing to the ADCL register. Note that the 16-bit ADC register is defined differently from ADCL, but they should both have the same address, so they should both give the same result when you pass them to XDATA_SFR_ADDRESS().

After setting up the DMA to point to ADCL, you will need to somehow tell the DMA to read two bytes so that it can get the low byte of the ADC result from ADCL and then get the high byte of the ADC result from ADCH, which is positioned directly after ADCL in memory (SFR address 0xBB, XDATA address 0xDFBB). In your previous post, it looks like you achieved that by putting the DMA into word-size transfer mode.

No. The DMA source address register (SRCADDR) can only hold one address at a time. It cannot point to two different SFRs at the same time. The address is a 16-bit address, and the high bits are loaded into an 8-bit register called SRCADDRH, while the low bits are loaded into an 8-bit register called SRCADDRL. However, it is still just a single address that can point to a single location in the XDATA memory space. So you should point it to ADCL, and then tell the DMA to transfer two bytes.

–David