Announcement

Collapse
No announcement yet.

Fast PWM with Wave Generation - Mode 14

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fast PWM with Wave Generation - Mode 14

    Code:
    // TCCR1A=0b101000 "10";  // 10 = WGM11 WGM10 / 0. i 1. bit// TCCR1B=0b000 "11" 001; // 11 = WGM13 WGM12 / 3. i 4. bit
    //******************************************************************************
    // MODE--WGM13--WGM12--WGM11--WGM10**         DESCRIPTION              TOP
    // ----**-----**-----**-----**-----**------------------------------**-----------
    //   0 **  0  **  0  **  0  **  0  **           NORMAL             **  0xFFFF
    //   1 **  0  **  0  **  0  **  1  **  PWM, Phase Corrected, 8bit  **  0x00FF
    //   2 **  0  **  0  **  1  **  0  **  PWM, Phase Corrected, 9bit  **  0x01FF
    //   3 **  0  **  0  **  1  **  1  **  PWM, Phase Corrected, 10bit **  0x03FF
    //   4 **  0  **  1  **  0  **  0  **            CTC               **  OCR1A
    //   5 **  0  **  1  **  0  **  1  **      FAST PWM. 8bit          **  0x00FF
    //   6 **  0  **  1  **  1  **  0  **      FAST PWM, 9bit          **  0x01FF
    //   7 **  0  **  1  **  1  **  1  **      FAST PWM, 10bit         **  0x03FF
    //   8 **  1  **  0  **  0  **  0  ** PWM, Phase&Freq. Corrected   **  ICR1
    //   9 **  1  **  0  **  0  **  1  ** PWM, Phase&Freq. Corrected   **  OCR1A
    //  10 **  1  **  0  **  1  **  0  ** PWM, Phase Correct           **  ICR1
    //  11 **  1  **  0  **  1  **  1  ** PWM, Phase Correct           **  OCR1A
    //  12 **  1  **  1  **  0  **  0  **            CTC               **  ICR1
    //  13 **  1  **  1  **  0  **  1  **          RESERVED            **  
    //  14 **  1  **  1  **  1  **  0  **         FAST PWM             **  ICR1
    //  15 **  1  **  1  **  1  **  1  **         FAST PWM             **  OCR1A
    //******************************************************************************
    //TCCR1B=0b00011 000 Timer/Counter1 Disabled 
    //TCCR1B=0b00011 001 No Prescaling
    //TCCR1B=0b00011 010 Clock / 8
    //TCCR1B=0b00011 011 Clock / 64
    //TCCR1B=0b00011 100 Clock / 256
    //TCCR1B=0b00011 101 Clock / 1024
    // ICR1 Input Capture 16-bit Register
    // OCR1A Output Compare Register
    
    
    
    
    void setup() 
    {
      pinMode(9, OUTPUT);
      
      //PWM Waveform Generation Modes with a settable TOP value
      // 600Hz, 6.25%, 100uS
      //ICR1=16MHz /1/600Hz = 26666,66666666667 TOP with /1 prescaling
      
      ICR1=26666 ;
      TCCR1A=0b10100010; //fast PWM with Wave Generation Mode 14
      TCCR1B=0b00011001; //Prescaler /1 / No Prescaling
      TCCR1C=0;
      OCR1A=ICR1/16; // 100% duty cycle/16 = 6.25%, 100uS
    }
    void loop() 
    {
      
    }
Working...
X