Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

Fast PWM

Fast PWM

2007-07-14 by vidord

Hi Guys,

I started a new project with an ATmega88, and I need two fast-PWM 
signals. One it will be an inverted signal of the other signal.
I wrote the code, but when I simulate it on AVRStudio, I don't get 
out any signal. Did I missed something?
Here comes the code:


.include	"m88def.inc"
;============================
;Declarations:
.def	temp=r16
;============================
;Start of program:
	rjmp 	Init
Init:
;=====================
;Port B initialization
;---------------------
	ldi temp, 0x00
	out PORTB, temp
	ldi temp, 0x08
	out DDRB, temp
;=====================
;Port D initialization
;---------------------
	clr temp
	out PORTD, temp
	ldi temp, 0x08
	out DDRD, temp
;==============================
;Timer/Counter 2 initialization
;------------------------------
;Clock source: System Clock
;Clock value: 14745,600 kHz
;Mode: Fast PWM top=OCR2A
;OC2A output: Non-Inverted PWM
;OC2B output: Inverted PWM
	ldi temp, 0xB3
	sts TCCR2A, temp
	ldi temp, 0x09
	sts TCCR2B, temp
	ldi temp, 0x00
	sts TCNT2, temp 
	ldi temp, 0x7F
	sts OCR2A, temp
	ldi temp, 0x7F
	sts OCR2B, temp
;=====================
;Main body of program
;--------------------
Start:
;<Write program here>
	rjmp	Start			;loops back to Sart

Re: [AVR-Chat] Fast PWM

2007-07-15 by John Samperi

At 05:23 AM 15/07/2007, you wrote:
>Did I missed something?

Probably the fact that you can't really trust the simulator
when it comes to timers...and a lot of other things too :-(

Have you tried with real hardware?

>         ldi temp, 0x08
>         out DDRB, temp
............
 >       ldi temp, 0xB3
 >       sts TCCR2A, temp
 >       ldi temp, 0x09
 >       sts TCCR2B, temp

Using numbers instead of bit NAMES makes it very hard for anyone
to follow your code (at least it does for me) as I would have to
grab the data sheet and try to figure out if you are setting the
correct bits.

Apart from that, nice comments and layout :-)


Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495       Fax (02) 9674-8745
Email: john@ampertronics.com.au
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.10.6/900 - Release Date: 14/07/2007 3:36 PM

Re: Fast PWM

2007-07-16 by vidord

--- In AVR-Chat@yahoogroups.com, John Samperi <samperi@...> wrote:
>
> At 05:23 AM 15/07/2007, you wrote:
> >Did I missed something?
> 
> Probably the fact that you can't really trust the simulator
> when it comes to timers...and a lot of other things too :-(
> 
> Have you tried with real hardware?
> 
> >         ldi temp, 0x08
> >         out DDRB, temp
> ............
>  >       ldi temp, 0xB3
>  >       sts TCCR2A, temp
>  >       ldi temp, 0x09
>  >       sts TCCR2B, temp
> 
> Using numbers instead of bit NAMES makes it very hard for anyone
> to follow your code (at least it does for me) as I would have to
> grab the data sheet and try to figure out if you are setting the
> correct bits.
> 
> Apart from that, nice comments and layout :-)
> 
> 
> Regards
> 
> John Samperi
> 
> ********************************************************
> Ampertronics Pty. Ltd.
> 11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
> Tel. (02) 9674-6495       Fax (02) 9674-8745
> Email: john@...
> Website  http://www.ampertronics.com.au
> *Electronic Design * Custom Products * Contract Assembly
> ********************************************************
> 
> 
> -- 
> No virus found in this outgoing message.
> Checked by AVG Free Edition. 
> Version: 7.5.476 / Virus Database: 269.10.6/900 - Release Date: 
14/07/2007 3:36 PM
>

Hi John,

Thanks!
I've not tried on the hardware yet. I'll do that today.
I hope it will work.

Regards
Vidor

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.