Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Attiny26 pwm generator C

Status
Not open for further replies.

bcd8421

Newbie
Joined
Jun 10, 2013
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,304
Hello. I would like to generate 100 kHz pwm signal with attiny26. Please, check my source code, I borow my ISP programmer so I can't do it. Thanks in advance.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
 
 
int main(void)
{
DDRB   |=(1<<PB3);                         //(OC1B) PB3 pwm out
 
PLLCSR |=(1<<PLLE);                     // enable, lock pll
PLLCSR |=(1<<PLOCK);
_delay_us(100);
PLLCSR |=(1<<PCKE);
 
TCCR1A |=(1<<COM1B1)|(1<<PWM1B);
TCCR1B |=(1<<CS11)  |(1<<CS10)  |(1<<PSR1);//preskaler, reset pll
 
OCR1C   =159;
OCR1B   =50;                              //resolution pwm OC1B PB3 
 
while(1)
{
 
}//end while
}//end main

 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top