Continue to Site

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.

Problem with simulating PWM on AVR STUDIO 4

Status
Not open for further replies.

Andy_P

Newbie level 2
Joined
Jul 25, 2005
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,295
AVR STUDIO4 and PWM

I am trying to simulate PWM on AVRSTUDIO 4, using the timer0 of ATMEGA8535.
All works except the setting or clearing of pin OC0 which is PB3 in this case.

this is the relevant part of the program:

void port_init(void)
{
PORTA = 0x00;
DDRA = 0x00;
PORTB = 0x00;
DDRB = 0x08;
PORTC = 0x00; //m103 output only
DDRC = 0x00;
PORTD = 0x00;
DDRD = 0x00;
}

//TIMER0 initialize - prescale:8
// WGM: PWM Phase correct
// desired value: 1mSec
// actual value: 1,020mSec (-2,0%)
void timer0_init(void)
{
TCCR0 = 0x00; //stop
TCNT0 = 0x01; //set count
OCR0 = 0x80; //set compare
TCCR0 = 0x62; //start timer
}


Anyone experience in this field?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top