Hello,
I am starting a new project in Arudino with the Leonardo board where I need to access the ATmega registers.
To start, I tried a code found on these pages to set-up PWM on timer 2.
However the complier does not seem to find the AVR libraries and return the following errors?
sketch_jun27c.ino: In function 'void setup()':
sketch_jun27c:12: error: 'COM2A1' was not declared in this scope
sketch_jun27c:12: error: 'COM2B1' was not declared in this scope
sketch_jun27c:12: error: 'WGM21' was not declared in this scope
sketch_jun27c:12: error: 'WGM20' was not declared in this scope
sketch_jun27c:13: error: 'TCCR2B' was not declared in this scope
sketch_jun27c:13: error: 'CS22' was not declared in this scope
sketch_jun27c:14: error: 'OCR2A' was not declared in this scope
sketch_jun27c:15: error: 'OCR2B' was not declared in this scope
Did I miss something during installation? where are supposed to be those libraries. I search the forum but it does not seems to happen to others.
I have found libraries in :
C:\Program Files (x86)\Arduino\hardware\tools\avr\avr\include\
Thanks
David
//test PWM bit mode
#include <stdio.h>
#include <EEPROM.h>
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/sleep.h>
void setup (){
pinMode(3, OUTPUT);
pinMode(11, OUTPUT);
TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
TCCR2B = _BV(CS22);
OCR2A = 180;
OCR2B = 50;
}
void loop(){
}