Hello,
I'm using the MSP430F5438A
The goal: Read analog data using ADC12 (into ADC12MEM0) and copy the data using DMA to ram.
Reading the datasheet under "Table 8. DMA Trigger Assignments" the ADC12 is on 24 (ADC12IFGx).
The code below does what I wanted when the DMA is triggered via Timer B.
I can see the data in the dest updated (with delay).
When changing to DMACTL0 = 24; dest isn't updated allthoght I arrive to break point I've put inside the ADC12ISR
#include <msp430.h>
#include <msp430f5438a.h>
unsigned char dest = 0;
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P4DIR |= 0x01; // Set P4.0 to output direction
//TIMER B
TBCCR0 = 100; // Init TBCCR0 w/ sample prd
TBCCR1 = 100 - 30; // Trigger for ADC12 SC
TBCCTL1 = OUTMOD_7; // Reset OUT1 on EQU1, set on EQU0
TBCTL = TBSSEL__SMCLK + MC_1 ; // SMCLK, up mode
//DMA
DMA0SA = (void *)&ADC12MEM0; // Src address
DMA0DA = (void *)&dest; // Dst address
DMA0SZ = 1;
DMACTL0 = DMA0TSEL_6; // DMA channel 0 transfer select 5: TimerB (TB0CCR0.IFG)
// DMACTL0 = DMA0TSEL_24; // DMA channel 0 transfer select 24: ADC12IFGx
// Repeated single transfer mode, increment src, access as bytes, enable DMA
DMA0CTL = DMADT_4 + DMADSTBYTE + DMASRCBYTE + DMAEN + DMAIE;
//ADC12:
P6SEL |= 0x02; // Enable A/D channel A1
ADC12CTL0 = ADC12ON + ADC12SHT0_0 + ADC12MSC; // Turn on ADC12, set sampling time
// set multiple sample conversion
ADC12CTL1 = ADC12SHP+ADC12CONSEQ_2; // Use sampling timer, set mode
ADC12IE = 0x01; // Enable ADC12IFG.0
ADC12CTL0 |= ADC12SC + ADC12INCH_0 + ADC12ENC; // Enable conversions
for (i = 0xFFF; i > 0; i--); // Time VRef to settle
__bis_SR_register(GIE); // interrupts enabled
for(;;) {
volatile unsigned int i; // volatile to prevent optimization
volatile unsigned char tmp;
tmp = *(unsigned char *)adc12Val;
P4OUT ^= 0x01; // Toggle P4.0 using exclusive-OR
i = 10000; // SW Delay
do i--;
while(i != 0);
}
return 0;
}
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
{
volatile int stopHere = 0;
stopHere = 1;
}
Please advice, how can I use the ADC12 interrupt to initiate the DMA transfer from the ADC12MEM0 to dest.