реклама на сайте
подробности

 
 
> Проблема с RTC
Zyoma
сообщение Oct 4 2011, 20:38
Сообщение #1





Группа: Новичок
Сообщений: 3
Регистрация: 4-10-11
Пользователь №: 67 552



Вот все пытаюсь сделать RTC через Timer A на своем MSP430G2231.
Вот код:
Код
#include  <msp430g2231.h>

void main(void)
{
    WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
    P1DIR |= 0x01;                            // P1.0 output
    CCR0 = 32768;                         //  Generate an interrupt every 32768 ACLK cycles.
    TACTL = TASSEL_1 + MC_1;              // 32 KHz ACLK, contmode
    CCTL0 = CCIE;                         // CCR0 interrupt enabled
    _BIS_SR(GIE);
    while (1) {}
}

// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
  P1OUT ^= 0x01;                            // Toggle P1.0
}



По идее лампочка должна гореть ровно 1 сек., но горит она гораздо дольше. И еще, когда останавливаю дебаггер, программа перестает выполняться. Заранее спасибо за помощь.
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
Zyoma
сообщение Oct 5 2011, 06:23
Сообщение #2





Группа: Новичок
Сообщений: 3
Регистрация: 4-10-11
Пользователь №: 67 552



Спасибо большое.
Вроде нашел свою проблему:
Цитата
Function: Interrupt is lost (slow ACLK)
Description: Timer_A counter is running with slow clock (external TACLK or ACLK) compared to
MCLK. The compare mode is selected for the capture/compare channel and the CCRx
register is incremented by one with the occurring compare interrupt (if TAR = CCRx).
Due to the fast MCLK, the CCRx register increment (CCRx = CCRx + 1) happens before
the Timer_A counter has incremented again. Therefore, the next compare interrupt
should happen at once with the next Timer_A counter increment (if TAR = CCRx + 1).
This interrupt is lost.
Workaround: Switch capture/compare mode to capture mode before the CCRx register increment.
Switch back to compare mode afterward.


То есть мне надо переключиться в capture mode перед тем как я плюсую к CCR0, а после этого переключиться в compare mode. Как это реализовать? И как вывести частоту ACLK на P1.0?

Кварц:
Micro Crystal
MS3V-T1R 32.768kHz.
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 20th August 2025 - 11:26
Рейтинг@Mail.ru


Страница сгенерированна за 0.01766 секунд с 7
ELECTRONIX ©2004-2016