Hello, i have a question about adc14div_x of msp432. If we set DCO = 24Mhz and SMCLK = 12Mhz and this clock (smclk) is the source clock of adc14, then if i want to sample every 10 microsecond (it means that every 10us i want the value converted and in memory from adc14mem), so have i set the adc14 clock or set adc14div_x to give him the correct frequency??
an example of code could be:
CSKEY = 0x695A; // Unlock CS module for register access CSCTL0 = 0; // Reset tuning parameters CSCTL0 = DCORSEL_4; // Set DCO to 24MHz CSCTL1 = CSCTL1 & ~(SELS_M | DIVS_M); // Clear existing registers CSCTL1 = CSCTL1 | (SELS_3 | DIVS_1); // For SMCLK, select DCO as source then divide by 2 CSKEY = 0; // Lock CS module from unintended accesses P6SEL1 |= BIT1; P6SEL0 |= BIT1; // adc pin ADC14CTL0 &= ~ADC14ENC; //Turn off Enable. With few exceptions, the ADC14 control bits can only be modified when ADC14ENC = 0. ADC14CTL0 = ADC14ON | ADC14SHT0_5 | ADC14CONSEQ_2 | ADC14SSEL_4 | ADC14SHP | ADC14SHS_0; // Turn on ADC14, set sampling time, repeat single channel (ssel = smclk) ADC14CTL1 = ADC14RES__14BIT; // Use sampling timer, 14-bit conversion results (16 clock cycles) ADC14MCTL0 = ADC14VRSEL_0 | ADC14INCH_14; // A0 ADC input select; Vref=AVCC=3.3V ADC14IER0 |= ADC14IE0; ADC14CTL0 |= ADC14ENC; // ADC enable
In this case i have 96S&H cycles + 16Conversion(14 bit) --> 96+16/12Mhz = 9.3 us (<10us). Is it correct this?
I add that the start conversion is in Timer_A of msp432. In particulart the code is set as:
void TimerA0_0IsrHandler(void) {
TA0CCTL0 &= ~CCIFG;
if(microseconds > 0 && microseconds <= 1000) {
ADC14CTL0 |= ADC14SC; // Start sampling/conversion; Enable and start conversion.
values[index_N] = ADC14MEM0;
index_N++;
}
[......]
Where microsecond is a variable that increments with timer_A (set to 1Mhz -> 1us)
Thanks