Other Parts Discussed in Thread: MSP430F2618, ADS1298
I use ADS1298 controlled by MSP430F2618 SPI interface to capture electrophysiology signal.
I send three 8-bit commands to ADS1298. Then the acquired results from ADS1298 are right.
But when I send one 24-bit command via MSP430F2618 DMA to ADS1298, it seems something
wrong. The first 24-bit data from ADS1298 is right, but the following results are wrong.
Here are some partial codes. If I don’t adopt interrupt command via DMA, how should I do or fix it?
Thanks very much.
-------------------------------------------------------------------------------
DMA initialize
-------------------------------------------------------------------------------
const unsigned char Sin_tab[] = { 0x00, 0x00, 0x00 };
void Init_DMA(void)
{
DMACTL0 = DMA2TSEL_12 + DMA0TSEL_13; // URXIFG1, MPY, UTXIFG1
// DMACTL1 = ROUNDROBIN;
DMA0SA = (unsigned int)&Sin_tab; // Source block address
DMA0DA = (unsigned int)&UCB0TXBUF; // Destination
single address
DMA0SZ = sizeof Sin_tab; // Block size
DMA0CTL = DMALEVEL+ DMASRCINCR_3+DMADT_0 + DMASBDB + DMAEN; // Sng
rpt, config
// RX Store
DMA2SA = (unsigned int)&UCB0RXBUF; // Src address = UART RX Buffer
DMA2DA = 0x240; // Dst address = P1
DMA2SZ = 27; // Size in bytes
DMA2CTL = DMADT_0 +DMASBDB + DMADSTINCR_3+ DMAEN; // Sng, config
}
-------------------------------------------------------------------------------------------------------------------------------------
How should I rewrite the following codes to get ADS1298 results via MSP430F2618 DMA ?
-------------------------------------------------------------------------------------------------------------------------------------
unsigned int spiSendByte(const unsigned int data)
{
UCB0TXBUF = data;
while((IFG2 & UCB0TXIFG)==0);
while((IFG2 & UCB0RXIFG)==0);
return(UCB0RXBUF);
}
int ADS1298ReadData(int fWaitForDataReady)
{
if (comm1 == 0) // open readly ads1298
{
ADS1298_init_Command(ADS1298_CMD_START);
ADS1298_init_Command(ADS1298_CMD_RDATAC);
P1OUT |= ADS1298_START ; //同步
Delay_us(1);
P1OUT &= ~(ADS1298_START);
comm1 = 1; //close readly ads1298
}
if (fWaitForDataReady) //wait DRDR ready!
ADS1298WaitForDataReady(0);
for (char f = 0 ; f < 10 ; f++) // read A/D 16ch
{
switch(f)
{
case 0:
{
ADS1298AssertCS(1);
spiSendByte(0);
spiSendByte(0);
spiSendByte(0);
ADS1298AssertCS(0);
break;
}
case 1: //ch1
{
ADS1298AssertCS(1);
while (!(UC1IFG&UCA1TXIFG));
UCA1TXBUF = spiSendByte(0);
while (!(UC1IFG&UCA1TXIFG));
UCA1TXBUF = spiSendByte(0);
while (!(UC1IFG&UCA1TXIFG));
UCA1TXBUF = spiSendByte(0);
ADS1298AssertCS(0);
break;
}
case 2: //ch2
{
ADS1298AssertCS(1);
while (!(UC1IFG&UCA1TXIFG));
UCA1TXBUF = spiSendByte(0);
while (!(UC1IFG&UCA1TXIFG));
UCA1TXBUF = spiSendByte(0);
while (!(UC1IFG&UCA1TXIFG));
UCA1TXBUF = spiSendByte(0);
ADS1298AssertCS(0);
break;
}
case 3: //ch3...........................