ATtiny45 Timer1 PWM <solved>

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

♦I am quite familiar with timers in Tiny and Mega series, but with this Tiny45 I run into an odd problem: Bascom code.

'Init: Timer1 generates PWM on OC1B, using clk/1, OCR1C=top, OCR1B=pwm percentage
Tccr1 = &B10000001                                          'clk/1 = 8 MHz
Gtccr = &B01100000                                          'Clear OC1B on match
'Set Gtccr.com1b0                                            'inverse PWM-signal
Pwm_drv Alias Ocr1b
Pwm_top Alias Ocr1c

The signal on OC1B is the inverse of what I need. But setting Gtccr.com1b0 results in a constant high on OC1B, and not the inverse signal: which is what I expected.

OC1B drives a boost converter and so a constant high kills the power: the boost-inductor saturates. No magic smoke, btw ;) , it simply reboots.

In the main loop, OCR1B and OCR1C are handled.

   Pwm_top = 200
   Pwm_drv = 50

What am I missing ?

Nard

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

Last Edited: Wed. Aug 15, 2012 - 01:47 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you read the errata? ;-) It may be the hardware bug I mention in this post.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I went through the revision history of the datasheet. I should have done the same for the Errata. :oops:

Thank you very much !

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am trying to find the silicon revision level on a DIL8 of the ATtiny45 (used during development) This is what it says on the bottom:

Quote:
SJ7 149
D1 1P
0717 e3

For the final I will use SOIC version. The ones I have in stock say on the bottom:
Quote:
72STWN
6F1291
D-P e3

I'm puzzled ....

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Studied the datasheet, googled, ..... no clue yet.

Who helps me out ?

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Maybe you should remove the from subject?
I don't know what all the the codes mean. Maybe ask Atmel if no one else know the answer?

On the DIP version I guess 0717 is a date code (2007 week 17). I have a tiny45 with date code 0711 which also have the bug (the date code is also on the top of the package).

I have a couple of SOIC tiny85V that also have the bug. They have date code 0846 on top and the first row on the bottom is 846TWN which seems to indicate that that's also the date code. In that case you may have miss read the S in 72STWN, I guess it should be a number. If I'm correct the 7 stands for 2007 and it's older than my t85V so your SOIC's probably have the bug too.

Here's a test program in C if someone is interested in trying.

// Test program that shows the PWM1B inverted mode hardware bug
// in attiny45, attiny85 (and possibly attiny25).
// Connect a LED to PB4 in series with a resistance to Vcc.
// The program should ramp up the intensity with a 1.28 second period,
// but with the bug you will see a short flash with that period instead.

#include 
#include 

int main(void)
{
    // Timer1 for invered PWM on OC1B/PB4, inverted mode
    GTCCR = (1<<PWM1B) | (1<<COM1B1)|(1<<COM1B0);
    // presc. 1:32
    TCCR1 = (1<<CS12)|(1<<CS11);
    // Remove comment to work around hardware bug
    //TCCR1 |= (1<<COM1A1)|(1<<COM1A0);

    // OC1B output
    DDRB = (1<<PB4);

    while(1) {
        // Ramp up in about 1.28 seconds
        OCR1B++;
        _delay_ms(5);
    }
    return 0;
}
========================================================================

One workaround is to configure OC1A in the same way as OC1B, or use another PWM-pin.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you.

I changed my code and made COM1A0 and COM1A1 the same as COM1B0 and COM1B1: that works, but I loose my soft uart on those pins by doing that. But I can live with the wrong polarity of the pwm on OC1B. Alter the math ;)

Cheers,

Nard

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, that may be the easiest, non inverting mode and put out TOP - value instead of value.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dropped a request at Atmel Support about where to find the silicon revision levels.

Note: I registered 2 times earlier (in the past years) but that didn't work anymore. Needed to re-register again. Sigh ...

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Dropped a request at Atmel Support about where to find the silicon revision levels.


It >>used<< to be the letter at the end of the second line on the backside of the chip.

The errata isn't dated, but the problem was several revs back so maybe the date code can give you a clue.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Plons wrote:
I am trying to find the silicon revision level on a DIL8 of the ATtiny45 (used during development) This is what it says on the bottom:
Quote:
SJ7 149
D1 1P
0717 e3

For the final I will use SOIC version. The ones I have in stock say on the bottom:
Quote:
72STWN
6F1291
D-P e3

I'm puzzled ....


It seems they changed that, Lee :(
I am curious to see what Atmel Support comes with.

I can live with this Timer1-flaw, just want to know where to find the silicon revision since I am about to start with Xmega's. Purchased a few months ago.

In the meantime I ran into another problem with the Tiny45, and that is ADC related. I'll start a new topic for that.

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips