Thank you very much for your help! I finally found the answer. Your source code with a lot of comments helps me a lot! /* * Timer_A Compare Configuration Parameter * CCR1 is used to trigger the ADC14, conversion time * is defined by the resolution * 14bit -> 16 cycles + 1 cycle (SLAU356d, 20.2.8.3) * 12bit -> 14 cycles + 1 cycle * 10bit -> 11 cycles + 1 cycle * 8bit -> 9 cycles + 1 cycle * * In this example, 14-bit resolution at 24Mhz ~708ns conversion time * Sample time is defined by 4 ADC clocks * Sample period is 24/24Mhz = 1us */ const Timer_A_PWMConfig timerA_PWM = { .clockSource = TIMER_A_CLOCKSOURCE_SMCLK, .clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_1, .timerPeriod = 23, .compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_1, .compareOutputMode TIMER_A_OUTPUTMODE_SET_RESET, .dutyCycle = 11 }; In your program, timerPeriod setting is 23, not 24. To divide the 24MHz SMCLK by 24 to get 1MHz, you must set 23=(24-1). f_sample should be 24MHz /(23+1) = 1MHz f_sample was 24MHz /(24+1) = 960kHz My program which is originated from --- "main.c - MSP-EXP432P401R + Educational Boosterpack MkII - Microphone FFT" I changed the sample frequency setting below. #define SMCLK_FREQUENCY 24000000 // #define SAMPLE_FREQUENCY 8000 #define SAMPLE_FREQUENCY 1000000 I should have changed the line below, too. /* Timer_A PWM Configuration Parameter */ Timer_A_PWMConfig pwmConfig = { TIMER_A_CLOCKSOURCE_SMCLK, TIMER_A_CLOCKSOURCE_DIVIDER_1, // (SMCLK_FREQUENCY/SAMPLE_FREQUENCY), ((SMCLK_FREQUENCY/SAMPLE_FREQUENCY)-1), TIMER_A_CAPTURECOMPARE_REGISTER_1, TIMER_A_OUTPUTMODE_SET_RESET, (SMCLK_FREQUENCY/SAMPLE_FREQUENCY)/2 }; In original sample, SMCLK_FREQUENCY=24MHz and SAMPLE_FREQUENCY=8kHz So the setting was (SMCLK_FREQUENCY/SAMPLE_FREQUENCY) = 24000000/8000 = 3000 f_sample was 24000000/3001 = 7997Hz DIR |= BIT0; // Port7.0 output for SMCLK P7->SEL0 |=BIT0; P7->SEL1 &= ~BIT0; SMCLK from P7.0 output is 24MHz. /* * Debug: set TA0.1 as output to see ADC trigger signal */ MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN4, GPIO_PRIMARY_MODULE_FUNCTION); ADC14 trigger Timer PWM output P2.4 is 1MHz. P8->DIR |= BIT3 | BIT5 | BIT6 | BIT7; /* Completion interrupt for ADC14 MEM0 */ void DMA_INT1_IRQHandler(void) { /* Switch between primary and alternate bufferes with DMA's PingPong mode */ if (DMA_getChannelAttribute(7) & UDMA_ATTR_ALTSELECT) { DMA_setChannelControl(UDMA_PRI_SELECT | DMA_CH7_ADC14, UDMA_SIZE_16 | UDMA_SRC_INC_NONE | UDMA_DST_INC_16 | UDMA_ARB_1); DMA_setChannelTransfer(UDMA_PRI_SELECT | DMA_CH7_ADC14, UDMA_MODE_PINGPONG, (void*) &ADC14->MEM[0], data_array1, SAMPLE_LENGTH); switch_data = 1; P8->OUT |= BIT5; // P8.5 = 1 = high } else { DMA_setChannelControl(UDMA_ALT_SELECT | DMA_CH7_ADC14, UDMA_SIZE_16 | UDMA_SRC_INC_NONE | UDMA_DST_INC_16 | UDMA_ARB_1); DMA_setChannelTransfer(UDMA_ALT_SELECT | DMA_CH7_ADC14, UDMA_MODE_PINGPONG, (void*) &ADC14->MEM[0], data_array2, SAMPLE_LENGTH); switch_data = 0; P8->OUT &= ~BIT5; // P8.5 = 0 = low } } P8.5 output is 500 Hz all right! Thank you very much again for your help!
↧
Forum Post: RE: MSP432P401R LaunchPad 14bit ADC 1Msps using DMA looks 3% slower than expected. Why?
↧