Hi to everyone,
I use MSP-TS430PN80USB with MSP430F5529 microcontrollers at the first time. I need adc input and to know the sampling time. I start to read the example from ti.com.
Use this code:
"
#include <msp430.h>
/*
* main.c
*/
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
ADC12CTL0 = ADC12SHT02 + ADC12ON; // Sampling time je 16 ADC12CLK cycles, ADC12 on je 4bit 16bitnog registra ADC12CTL0
ADC12CTL1 = ADC12SHP; // ADC12SHP This bit selects the source of the sampling signal, znaci da je 1 i to je pulse sample mode
ADC12IE = 0x01; // Enable interrupt, ukljucuje prekid
ADC12CTL0 |= ADC12ENC; //vazan bit koji mora biti 1 pre konverzije
P6SEL |= 0x01; // P6.0 ADC option select
P1DIR |= 0x03; // P1.0 and P1.1 output
while (1)
{
ADC12CTL0 |= ADC12SC; // Start sampling/conversion
__bis_SR_register(LPM0_bits + GIE); // LPM0, ADC12_ISR will force exit
}
}
#pragma vector = ADC12_VECTOR
__interrupt void ADC12_ISR(void)
{
if (ADC12MEM0 >= 0x947) // ADC12MEM = A0; 947 odabiraka odgovara naponu od 1.8V
P1OUT &= 0xfe; // P1.0 = 0
else
P1OUT |= 0x01; // P1.0 = 1
__bic_SR_register_on_exit(LPM0_bits); // Exit active CPU
}
"
...it give me the increments, and that is great.
But I have a problem to understand how much is sampling time???
---With this line of code
ADC12CTL0 = ADC12SHT02 + ADC12ON;
,I turn on this adc and define number of ADC12CLK cycles, on this case 16cycles, but how much is my ADC12CLK??????????? Which line of code select value of ADC12CLK?
I use 4 Mhz crystal on board. Is this a work frequency of microcontroler?
---With this line of code
ADC12CTL1 = ADC12SHP;
I select the source of the sampling signal. Do I select the pulse sample mode??? In this mode period od SAMPCON depends of how I chose the ADC12SHT0x?
My sampe time is???
thanks,
Srdjan