Hi,
I am using an MSP430F5336 device and trying to get the DMAs to work with the multiplier block. I can't seem to get anything to work at all with them. I have used DMA blocks in the past and know I there are some tricks to get them to work properly but I can't seem to get this to work at all. The DMA don't trigger and they won't move any data. When I try to trigger manually, I get garbage data that I don't know where it is coming from. The documentation is lacking for this particular function. The MPY section refers to the DMA section for more information on using DMAs with the multiplier but there is no information at all in the DMA block on how to correctly use the multiplier in conjunction with the DMA block. The sample code is also lacking with this particular procedure.
Is there someone out there that has gotten this to work that would be willing to share their code? I am trying to use the DMA both as feeding the MPY block and pulling data from it, but if you have either one alone and it works, I would be most grateful for that also.
My particular problem that I am trying to solve is I have an array of unsigned integers (16 bits) that need to be multiplied by a constant that is an unsigned long (32 bits). I am only interested in saving the second integer of the result (second 16 bits) and they are stored in a new array. This is a perfect use of the DMAs and I would really like to get it working.
I will supply my sample code for anyone that would like to pick through it and make suggestions. This is just a test function that I used so it is missing some items and is only for reference. Don't worry about the math involved, I just care about the flow. (By the way, I have tried writing manually to the OP2 register to kick things off but that does not work either.) I tried each one alone and have not been able to get either one to work.
Thanks,
Brent
void test_stim_tmp(uint16 scale_value, uint16 ramp_time)
{
uint16 waveform[256];
uint16 waveform_scaled[256];
uint16 index1;
uint16 index2;
uint16 index3;
uint32 operand1;
volatile uint16 tmp1;
volatile uint16 tmp2;
volatile uint16 tmp3;
for (i = 0; i < 256; i++)
waveform[i] = i;
operand1 = (uint32)scale_value * (uint32)0x10000 / (uint32)ramp_time;
// setup multiplier
MPY32CTL0 |= OP1_32;
MPY32L = operand1 & 0xffff;
MPY32H = (operand1 >> 16) & 0xffff;
// setup DMA4 - MPY to array
DMACTL2 = DMA4TSEL_29;
DMA4CTL = DMADT_4+DMADSTINCR_3; // repeat single block xfer, dest inc
DMA4DAL = (uint16)waveform_scaled;
DMA4SAL = (uint16)(&RES1);
DMA4SZ = 256;
DMA4CTL |= DMAEN;
// setup DMA5 - array to MPY
DMACTL2 |= DMA5TSEL_29;
DMA5CTL = DMADT_4+DMASRCINCR_3; // repeat single block xfer, source inc
DMA5DAL = (uint16)(&OP2);
DMA5SAL = (uint16)(waveform + 1);
DMA5SZ = 256;
DMA5CTL |= DMAEN;
// halt here with debugger and single step but DMAs never to fire
}