RE: [bascom] Attiny26 high speed PWM in bascom


From "Laszlo Juhasz" <laszlo@psaudio.com>
Date Thu, 7 Apr 2005 16:15:35 -0600
Thread-index AcU7mVKP6w3w9AB/RV+oj7MPCb0sZwABctkg
Thread-topic [bascom] Attiny26 high speed PWM in bascom

Thanks a lot Dennis!
It's good to learn about the bugs too! :)
Best Regards.
Laszlo 

-----Original Message-----
From: owner-bascom@grote.net [mailto:owner-bascom@grote.net] On Behalf
Of Dennis Clark
Sent: Thursday, April 07, 2005 12:18 PM
To: bascom@grote.net
Subject: Re: [bascom] Attiny26 high speed PWM in bascom

Laszlo,

   Currently Bascom doesn't deal well with the ATtiny26, you will have
to read the data sheets on the 'T26 and do the PWM yourself.  Here is
what I did:

Tccr1a = &B10100011
This sets the PWM1a and PWM1b to clear on match of Ocr1a and Ocr1b.

Tccr1b = &B00001001
This sets the TMR1 clock to be PCK/256, which at 8MHz = about 31KHz.
You'll want to set this to something you want, you can got all the way
to /16384 with &B00001111

Ocr1c = 255
Regardless of what the data sheet says, if you don't set this register
to be 255, the PWM won't come on properly (which may be what is biting
you).  This register sets the overall period of the PWM module, there
are bits turning a match on and off for this register, but no matter how
you set them, they turn it on (bug in the chip.)

Now to set the PWM duty cycle you need only :
Ocr1a = 128 (for 50%)
Ocr1b = 255 (for 100%) and so on.

have fun,
DLC

This sets the PWM cir

Laszlo Juhasz wrote:
> Hi,
>  
> If someone may help me to find out that,-how can I configure the timer

> in BascomAVR fort he high speed PWM.
> Please forward some sample code or direct me to the "HELP" section of 
> the complier.
> Thanks a million.
> laszlo@psaudio.com <mailto:laszlo@psaudio.com>


--
---------------------------------------
Dennis Clark    TTT Enterprises
---------------------------------------