Other Parts Discussed in Thread: MSP430FR2355
I am trying to send out contents of a 4 element buffer at once using SPI slave with STE
active low and DMA.
Assume buffer contents are: Buff = {30, 31, 32, 33}. This is just for elaboration purpose otherwise Buff updates every 250ms in a timer ISR.
Behavior:
When continuous running the scope shows 30 on all 4 transactions.
When running to curser:
click1: 30 30 30 30
click2: 31 31 31 31
click3: 32 32 32 32
click4: 33 33 33 33
click5: 30 30 30 30
... and so on
Whereas I expect it to look like this at each cycle: 30 31 32 33
Here is the code portion that should accomplish this:
void main(void)
{
SPI_Init();
DMA_INIT();
while(1)
{
Buff = {30, 31, 32, 33};
DMA0CTL |= DMAEN + DMAREQ;
}
}
void SPI_Init(void)
{
// Setup SPI Mode for UCA1
UCA1CTLW0 = UCMSB + UCSYNC + UCMODE1 + UCSWRST;
// turn on SPI
UCA1CTLW0 &= ~UCSWRST;
}
void DMA_INIT(void)
{
DMACTL0 = DMA0TSEL_17; // Triger 17 on Channel 0 corresponds to UCA1TX
/*DMA channel 0 source address*/
DMA0SA = (unsigned short)TempBuff1; // Src = RAM memory
/*DMA channel 0 destination address*/
DMA0DA = (unsigned short)&UCA1TXBUF; // Dest single address
/*DMA channel 0 transfer block size*/
DMA0SZ = 0x04; // Block size
/*DMA channel0 Source address increment by 1 */
/*transfer is in repeated single byte*/
/*transfer is byte wise */
/*DMA channel0 INT disabled */
/*DMA channel0 is disabled */
DMA0CTL = DMADT_4 + DMASRCINCR_3 + DMASBDB + DMALEVEL;// inc src, enable, byte access
}