Hello dear e2e, I want to run my ADC in repeat single channel mode at 1MSPS. For the clock source I select MODCLK at 24MHz, with it I've had the best results. SYSCLK runs at 48MHz. I measure the speed by toggling a pin every time the ADC Interrupt handler is called. On an oscilloscope I read a frequency of 377kHz. Multiply by 2 and you get a sample rate of 754kHz, which is only 3/4 of the maximum achievable rate. I tried to keep the code as basic as possible and I don't think I can optimise it any further. Why am I not reaching 1MSPS? ~Andy Here is my code: #include "msp.h" #include volatile uint16_t A0result; int main(void) { WDT_A->CTL = WDT_A_CTL_PW | // Stop watchdog timer WDT_A_CTL_HOLD; // Configure GPIO P5->SEL1 |= BIT5; // Enable A/D channel A0 P5->SEL0 |= BIT5; P5->SEL1 &= ~BIT4; // Pulsing pin config P5->SEL0 &= ~BIT4; P5->DIR |= BIT4; P5->OUT &= ~BIT4; // Turn on ADC14 ADC14->CTL0 = ADC14_CTL0_ON | ADC14_CTL0_SSEL__MODCLK | ADC14_CTL0_MSC | ADC14_CTL0_SHT0__4 | //Shortest sampling time possible ADC14_CTL0_SHP | ADC14_CTL0_CONSEQ_2; //Repeat single channel ADC14->MCTL[0] = ADC14_MCTLN_INCH_0; // ref+=AVcc, channel = A0; ADC14->CTL0 |= ADC14_CTL0_ENC | ADC14_CTL0_SC; SCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk; // Wake up on exit from ISR __enable_interrupt(); NVIC->ISER[0] = 1 IER0 = ADC14_IER0_IE0; // Enable ADC14IFG.0 while(1) { __sleep(); __no_operation(); // For debugger } } // ADC14 interrupt service routine void ADC14_IRQHandler(void) { if (ADC14->IFGR0 & ADC14_IFGR0_IFG0) { A0result = ADC14->MEM[0]; // Move A0 results, IFG is cleared P5->OUT ^= BIT4; } }
↧