Tool/software: Code Composer Studio
Hi All,
I am trying to control the ADC triggering with CPU Timer.
My clock is set at 80MHz
"SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);"
And I am trying to trigger the timer int at 1MHz
"TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet()/80); "
SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);//Clock is set at 80MHz //SysCtlClockSet(SYSCTL_OSC_MAIN); //Initialize ADC SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); //Pin for ADC input SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); //ADC peripheral SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); //Pins used for ADC channels GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3); //set GPIO_E3 for channel 1 ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_TIMER, 0); //sequencer 0 ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END); TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet()/80); //1MHz TimerEnable(TIMER0_BASE, TIMER_A); TimerControlTrigger(TIMER0_BASE,TIMER_A,true); ADCSequenceEnable(ADC0_BASE, 3); ADCIntEnable(ADC0_BASE, 3); while(1) { TimerEnable(TIMER0_BASE, TIMER_A); ADCIntClear(ADC0_BASE, 3); ADCIntEnable(ADC0_BASE, 3); //ADCIntClear(ADC0_BASE, 3); while(!ADCIntStatus(ADC0_BASE, 3, 0)); ADCSequenceDataGet(ADC0_BASE, 3, &value); ADCIntDisable(ADC0_BASE, 3); if(i<2048) { data0[i++]=value; } }
Is this the right way to do it?
How can I check the triggering frequency of timer?
I am trying to fill an array of 2048 size with the ADC output - my ADC input is a sine wave generated by function generator of frequency 100KHz
So ideally the each sine period should have 10 samples. And so each period should take 10 places in the array. the complete 2048 array should contain 204 periods of sine "ideally". this is not happening.
I am confused whether I am triggering the ADC at 1MHz or not?:(