Advertisement
RuiViana

Mede_Oscilator

Sep 28th, 2016
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.29 KB | None | 0 0
  1.  
  2. /* Registers associados com o Timer 1 e envolvidos como code
  3.  *  
  4.  * TCCR1A  Timer/Counter1 Control Register A   COM1A1 COM1A0 COM1B1 COM1B0 – – WGM11 WGM10 -->> 0x40
  5.  *      
  6.  *      Compare Output Mode, non-PWM
  7.  *      COM1A1/COM1B1 COM1A0/COM1B0   0 1 Toggle OC1A/OC1B on Compare Match.
  8.  *      
  9.  *      Mode | WGM13 | WGM12 | WGM11 | WGM10 | Timer/Counter   |  TOP  | Update of | TOV1 Flag
  10.  *           |       | CTC1) |(PWM11)|(PWM10)|Mode of Operation|       | OCR1x at  |  Set on
  11.  *       4   |   0   |   1   |   0   |   0   |       CTC       | OCR1A | Immediate |   MAX
  12.  *      
  13.  *          MAX = The counter reaches its MAXimum when it becomes 0xFFFF (decimal 65535).
  14.  *
  15.  * TCCR1B – Timer/Counter1 Control Register B   ICNC1 ICES1 – WGM13 WGM12 CS12 CS11 CS10   -->>  0x09
  16.  *        
  17.  *        Mode | WGM13 | WGM12(CTC1)
  18.  *          4   |   0   |      1  
  19.  *          
  20.  *        CS12 | CS11 | CS10 | Description      
  21.  *         0   |  0   |   0  | No clock source (Timer/Counter stopped).
  22.  *         0   |  0   |   1  | clkI/O/1 (No prescaling)             8 mHz
  23.  *         0   |  1   |   0  | clkI/O/8 (From prescaler)            1 mHz      
  24.  *         0   |  1   |   1  | clkI/O/64 (From prescaler)         125 kHz        
  25.  *         1   |  0   |   0  | clkI/O/256 (From prescaler)      31250 Hz
  26.  *         1   |  0   |   1  | clkI/O/1024 (From prescaler)    7812,5 Hz
  27.  *         1   |  1   |   0  | External clock source on T1 pin. Clock on falling edge.
  28.  *         1   |  1   |   1  | External clock source on T1 pin. Clock on rising edge.  
  29.  *                                                          
  30.  *  DDRB  =  Direction port bits  0 INPUT  1 OUTPUT
  31.  *  
  32.  *  OC1A/PCINT1 – Port B, Bit 1
  33.  *  OC1A, Output Compare Match output: The PB1 pin can serve as an external output for the Timer/Counter1
  34.  *  Compare Match A. The PB1 pin has to be configured as an output (DDB1 set (one)) to serve this function.
  35.  *  OC1A  é o PIN PB1  OC1A (Timer/Counter1 Output Compare Match A Output)   PORT 9  
  36.  */
  37.  
  38.  //------- CODE ----------------
  39. void setup()
  40. {  
  41.   DDRB = 0x02;          // define port 9 como saida
  42.   TCCR1A = 0x40;        // Ler texto acima
  43.   TCCR1B = 0x0A;        // Ler texto acima      1 mHz            
  44. }
  45. //---------------------------
  46. void loop ()
  47. {
  48. ;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement