Видимо, как и положено начинающему, я неправильно инициализирую процессор. Может у кого есть пример, ка завести МСП430Ф149 на частоте достаточной для моего (1мс) прерывания не используя внешний кварц?
Систему тактирования сейчас инициализирую так:
// Может, моя проблема в значении параметра Delta? Delta = 375; BCSCTL1 &= 0xc0; //Set ACLCK to 32768 and rsel to 0 BCSCTL1 |= 0x21; //Now Set ACLCK to 32768/4 and rsel to 7! CCTL2 = 0x5100; // CCR2 forced into Rising adge, source is aclock, set capture mode TACTL = 0x220; // System clock as input to counter cont. UP counting. TACTL |= 0x4; //Reset Counter
DCOCTL=0x80; do { Ovf2=0; while (((CCTL2 & 0x01) != 0x01) && (Ovf2++ <30000)); // Wait until capture occured! CCTL2 &= 0xfffe ; // Capture occured, clear flag and overflow Compare = CCR2; // Get current captured SMCLK Gap = Compare - Oldcapture; // SMCLK difference Oldcapture = CCR2; // Save current captured SMCLK R_Sel=BCSCTL1&0x07; if(Delta == Gap) { Err=0; break; } else if (Delta < Gap) { // DCO is too fast, slow it down DCOCTL--; if (DCOCTL ==0xff && R_Sel>0)BCSCTL1--; // Did DCO role under? Select next lower RSEL } else { DCOCTL++; if (DCOCTL ==0x00 && R_Sel<7)BCSCTL1++; // Did DCO role over? } }while(++Ovf<30000); CCTL2 = 0; // Stop CCR2 function TACTL = 0; // Stop Timer_A BCSCTL1 &= 0xcf; // Set ACLCK to 32768
Сообщение отредактировал Salazar - Jul 7 2007, 23:19
|