Hi everyone. I'm trying to program a very simple application that adds one unit to the outputs of one port (P4), but it has to be as faster as possible. My problem is the speed. The maximum time rating with external clocking is 8 MHz, but such a simple program only arrives to some kHz. I leave you the program. If you have any answer to my question, please, tell to me. The program:
Please use Code tags to maintain formatting and improve code readability. I added them here (mod)
Code:
#include <msp430x16x.h>
unsigned int i = 0; // Variable global
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog
BCSCTL1 = XTS + DIVA_0; // XT2 ON, modo alta frecuencia, sin división.
BCSCTL2 = SELM1 + DIVM_0 + SELS + DIVS_0; // Fuente del MCLK: XT2.
P4DIR |= 0xFF;
P4OUT = 0x00;
//P1SEL &= ~BIT2;
P1IE = BIT2;
P1IES = 0xFF; // Flanco de subida de reloj.
//ADC12CTL0 = REF2_5V + REFON; // Internal 2.5V ref on
_BIS_SR(GIE+SCG0);
//DAC12_0CTL = DAC12IR + DAC12AMP_7 + DAC12ENC + DAC12LSEL0 + DAC12SREF_2;
// Internal ref gain 1
do
{
P4OUT++;
//P4OUT &= 0xFF;
//DAC12_0DAT = DAC12_0DAT++; // Generamos rampa.
//DAC12_0DAT &= 0xFFFF; // Para evitar desbordamiento.
} while (i == 0);
}
#pragma vector=PORT1_VECTOR
__interrupt void ajustado (void)
{
//P1IFG = BIT1;
i = 1;
P1IFG &= ~BIT2;
}
Edited by Dan Henry (Wed Feb 21 2007 08:37 AM)