xdata_sfr_address

I tried running your code here and it doesn’t seem to work. I fed various voltages to the P0_0 pin and the corresponding column in your program’s output didn’t seem to be correlated to the voltage.

Here is a sample of the output that I got:

     121               1               1               1            1600            1472            1536
     121               1               1               1            1536            1408            1408
     121               1               1               1            1536            1408            1472
     121               1               1               1               0            1472            1344
     121               1               1               1               0            1600            1472

I noticed some bugs in lines of code where you are attempting to clear bits in an SFR. Here are two examples:

P0DIR = ~0x07;
DMAARM = (~(DMA_CHANNEL_2 | DMA_CHANNEL_3 | DMA_CHANNEL_4));

In both lines of code above, you are inadvertently setting several bits in the register to 1, and I think you wanted to leave those bits alone. You can fix bugs like this by changing = to &=. We have discussed this before in this thread: Wixelcmd read provides address too high message.

However, I don’t think that those bugs would explain the problems we are seeing. If you want to fix your program, I suggest simplifying it further, since it is still over 400 lines long.

Is there are reason that you are using DMA instead of using the ADC library that comes with the Wixel SDK?

–David