Posts

Showing posts from March, 2017

ATtiny85

Image
                                                          The high-performance, low-power Microchip 8-bit AVR RISC-based microcontroller combines 8KB ISP flash memory, 512B EEPROM, 512-Byte SRAM, 6 general purpose I/O lines, 32 general purpose working registers, one 8-bit timer/counter with compare modes, one 8-bit high speed timer/counter, USI, internal and external Interrupts, 4-channel 10-bit A/D converter, programmable watchdog timer with internal oscillator, three software selectable power saving modes, and debugWIRE for on-chip debugging. The device achieves a throughput of 20 MIPS at 20 MHz and operates between 2.7-5.5 volts. By executing powerful instructions in a single clock cycle, the device achieves throughputs approaching 1 MIPS per MHz, balancing power consumption and processing speed.

PROGRAM

Image
const byte OUTPUT_PIN = 3;  // Timer 2 "B" output: OC2B const byte n = 65;  // for example, 8.89 kHz void setup()  {   pinMode (OUTPUT_PIN, OUTPUT);   TCCR2A = bit (WGM20) | bit (WGM21) | bit (COM2B1); // fast PWM, clear OC2A on compare   TCCR2B = bit (WGM22) | bit (CS21);         // fast PWM, prescaler of 8   OCR2A =  n;                                // from table    OCR2B = ((n + 1) / 2) - 1;                 // 50% duty cycle   }  // end of setup void loop() { } This page can be quickly reached from the link: http://www.gammon.com.au/timers PWM Phase shifting program   Creating a variable frequency PWM output on Arduino UNO: Arduino PWM cheat sheet: