logo elektroda
logo elektroda
X
logo elektroda
REKLAMA
REKLAMA
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

[Attiny261][C] Fast PWM

KolegaZ 04 Paź 2009 09:39 1263 0
REKLAMA
  • #1 7088545
    KolegaZ
    Poziom 12  
    Witam,

    Niestety mam problem z włączeniem trybu FastPWM w ATTiny 261 przy wykorzystaniu zegara wewnętrznego lub PCK (brak podłączonego zew. kwarcu).

    
    // Timer/Counter 1 initialization
    // Clock source: System Clock
    // Clock value: 8000,000 kHz
    // Mode: Fast PWM top=OCR1C
    // OC1A output: OC1A=1
    // OC1B output: OC1B=1
    // OC1C output: OC1D=1
    // Fault Protection Mode: Off
    // Fault Protection Noise Canceler: Off
    // Fault Protection triggered on Falling Edge
    // Fault Protection triggered by the Analog Comparator: Off
    // Timer 1 Overflow Interrupt: Off
    // Compare A Match Interrupt: Off
    // Compare B Match Interrupt: Off
    // Compare D Match Interrupt: Off
    // Fault Protection Interrupt: Off
    PLLCSR=0x00;
    TCCR1A=0x123;
    TCCR1B=0x01;
    TCCR1C=0x121;
    TCCR1D=0x00;
    TCCR1E=0x00;
    TC1H=0x00;
    TCNT1=0x00;
    OCR1A=0x00;
    OCR1B=0x00;
    OCR1C=0xFF;
    OCR1D=0xFF;
    DT1=0x00;
    


    i dla PCK

    
    // Timer/Counter 1 initialization
    // Clock source: 64MHz PCK
    // Clock value: 8000,000 kHz
    // Mode: Fast PWM top=OCR1C
    // OC1A output: OC1A=1
    // OC1B output: OC1B=1
    // OC1C output: OC1D=1
    // Fault Protection Mode: Off
    // Fault Protection Noise Canceler: Off
    // Fault Protection triggered on Falling Edge
    // Fault Protection triggered by the Analog Comparator: Off
    // Timer 1 Overflow Interrupt: Off
    // Compare A Match Interrupt: Off
    // Compare B Match Interrupt: Off
    // Compare D Match Interrupt: Off
    // Fault Protection Interrupt: Off
    // Enable the PLL
    PLLCSR=0x02;
    // Wait for the PLL to lock
    while ((PLLCSR & 1)==0);
    // Enable the 64MHz clock
    PLLCSR|=0x04;
    TCCR1A=0x123;
    TCCR1B=0x04;
    TCCR1C=0x121;
    TCCR1D=0x00;
    TCCR1E=0x00;
    TC1H=0x00;
    TCNT1=0x00;
    OCR1A=0x00;
    OCR1B=0x00;
    OCR1C=0xFF;
    OCR1D=0xFF;
    DT1=0x00;
    


    Czy może ktoś spotkał się z podobnym problemem
  • REKLAMA
REKLAMA