I need a timer_A generating interrupting each 130 microseconds, but look like that he hangs in the loop. Well, if i elevate the interval the software does what i want. Enter in interrup, add a value in queue type FIFO, exits, remove and shows this value. If i put interval in microseconds he hangs. How i can have this interval working?
i am using msp430g2553
felipe paulo... Enter in interrup, add a value in queue type FIFO, exits, remove and shows this value...
If the above takes more than 130 microseconds, then the next interrupts will be requested before the previous one is handled. Interrupt will pile up or mess-up. Stack and FIFO might overflow.
How fast is the CPU running? How much can it do within 130 microsecond?
CPU running 1MHz. in interrupting he gets a sample of ADC, add in FIFO and verify if the loop was run 128 times
the timer are as configured: CCTL0 = CCIE; CCR0 = 130; TACTL = TASSEL_2 + MC_1;
felipe paulo... in interrupting he gets a sample of ADC, add in FIFO and verify if the loop was run 128 times ...
That probably will take more then 130 MCLK.
Try set MCLK to 8 MHz and keep SMCLK at 1 MHz
BCSCTL1 = CALBC1_8MHZ; DCOCTL = CALDCO_8MHZ; BCSCTL2 = DIVS_3;I set up like this?
is almost solved the problem. Put 130 microseconds in timer e then exit, it worked. But now i trying do in the timer, a ADC converter, but he don´t want leave the interrupt.
BCSCTL1 = CALBC1_8MHZ; //MCLK = 8MHZ DCOCTL = CALDCO_8MHZ; BCSCTL3 = DIVS_3; //SMCLK = 8MHZ/8=1MHZ ADC10CTL1 = INCH_7 + CONSEQ_1; // A2/A1/A0, single sequence ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE; ADC10DTC1 = 0x03; // 3 conversions ADC10AE0 |= 0xC0; // P1.7,6 ADC10 option select InitLCD(); //Inica o LCD LCDClear(); //Limpa a tela __enable_interrupt(); //Habilita interrupções
TACCTL0 = CCIE; // TACCR0 interrupt enabled TACCR0 = 16; //Ciclos de SMCLK TACTL = TASSEL_2 MC_1 ID_3; // SMCLK/8 = 125Khz, upmode LPM0; //Entra em MODO low power mode 0 LCDSetPosition(0,0); //Define posição printDecimal(points); //Exibe a variável pontos }// Timer A0 interrupt service routine#pragma vector=TIMER0_A0_VECTOR__interrupt void Timer_A (void){ ADC10CTL0 &= ~ENC; while (ADC10CTL1 & BUSY); // Wait if ADC10 core is active ADC10SA = (unsigned int)&conv_ADC10; // Inicializa o buffer de dados ADC10CTL0 |= ENC ADC10SC; // Inicia a amostragem/conversão } // ADC10 interrupt service routine#pragma vector=ADC10_VECTOR__interrupt void ADC10_ISR(void){ while (ADC10CTL1 & BUSY); points++; //Increment points for me know how many times the timer was executed //if was executed 150 times, he leave of interrupt, get the values and show in LCD. if(points == 150){ LPM0_EXIT; }}but does not work
if I put the TIMER with ACLK instead of SMCLK could be even faster? Why Are the SMCLK 1MHZ he does not do what I gotta do this time with this range.
felipe paulo while (ADC10CTL1 & BUSY); // Wait if ADC10 core is active
ISRs are fast-in and should be fast-out too. No waiting inside. The ISR is called when something happens, to immediately react on the event. They are definitely not meant to wait until something happens.
Independent of that, ENC does not start the conversion. ADC10SC starts it. (SC for Start Conversion). ENC is just enabling or disabling the encoder (e.g. to emergency-stop a sequence)
Finally, ADC10_VECTOR is called whenever a conversion is done. So if it is called, you know for sure that a conversion was done, and a result is ready. So you should copy the content here and not in the timer ISR.
IN the tiemr ISR, there are two cases: either the sequence is ready when teh timer expires. Then it is superfluous to wait for the ADC: it's done and you only need to set ADC10SC again to start the next sequence. Or it isn't done. In this case your timer is too fast. Always. I tmakes no sense to wait for the ADC then, as you'll have to always wait. Since the ADC requires always the same tiemr for a sequence. You must either speed up the ADC by selecting a different SHTx or slow down the timer.Which one happens should be obvious after a little elementary school math.
_____________________________________Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.