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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…