Tiny10 PWM on PB0

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

Hello,
I'm having a bit of trouble with this pin. I'm able to get the PWM working and put it out on PB1 but for some reason it won't come out of PB0. I try to connect PB0 to the PWM by setting the top 2 bits of TCCR0A.

Also I've checked that PB0 works as an output pin by toggling it directly.

I must be missing something but I"m not sure what. Can yall tell from the initialization code?
Thanks,
Daniel

// Input/Output Ports initialization
// Port B initialization
// Pull-up initialization
PUEB=0x00;
// Func3=In Func2=In Func1=Out Func0=Out 
// State3=T State2=T State1=0 State0=0 
PORTB=0x00;
DDRB=0x03;

// Break Before Make Mode PORTB: Off
PORTCR=0x00;


// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 1 MHz
// Mode: fast 15 - top=OCR0A
// Input Capture on Falling Edge
// Input Capture Noise Canceler: On
// OC0A output: connected
// OC0B output: connected
// Fast PWM mode Channel A (PB1)
TCCR0A= 0xF3;
TCCR0B=0x9A;
TCNT0=0x0000;
ICR0=0x0000;
OCR0A=0xfff0;
OCR0B=0x0fff;
Last Edited: Wed. Nov 30, 2011 - 05:27 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In light of this comment (I didn't check the datasheet to confirm your setup), what do you expect to see on PB0?

Quote:
// Mode: fast 15 - top=OCR0A

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

Lessee--

First, edit your post and

  practice
    using the Code tags
        to preserve formatting. 

Now, the Tiny10 family (sometimes referred to here as brain-dead due to the register shortage) is a weird duck in some respects but the timer looks familiar enough to this AVR8 person.

In general, you can't do PWM on OCnA in a mode with OCRnA as TOP. See the Waveform Generation Modes table in the datasheet.

Either use Mode 14 with ICR0 as TOP, or Mode 5/6/7 fixed frequency.

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

Today they are trying to program Tiny10 in C, tomorrow they will ask for AndroidTiny for doing that. Where the hell the world is rolling down to?

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

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

Quote:

Today they are trying to program Tiny10 in C,

The CodeVision code generation model maps fairly well to the Tiny10 family. The lost low registers are generally for user "register" variables, anyway. Along with "bit"-type variables--Atmel could at least have given us GPIOR0. For the small and fairly "flat" apps appropriate to the flash size CV should do just fine.

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

Quote:
I must be missing something but I"m not sure what. Can yall tell from the initialization code?

The answer is that missing the correct avr,the assembly and even that how the program uploaded into flash.

Quote:
Where the hell the world is rolling down to?

For PWM tiny/10/11/12 can not do.Try tiny13.
For C programming can't be used since no sram is available,and the bad news are that tiny10/11 are not ispmkii programmable.I noticed after i bought it in my effort to upload the code into tiny11 when i was making some leds for my bike.Finally the job has done with tiny12.

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

theusch wrote:
Lessee--

First, edit your post and

  practice
    using the Code tags
        to preserve formatting. 

Now, the Tiny10 family (sometimes referred to here as brain-dead due to the register shortage) is a weird duck in some respects but the timer looks familiar enough to this AVR8 person.

In general, you can't do PWM on OCnA in a mode with OCRnA as TOP. See the Waveform Generation Modes table in the datasheet.

Either use Mode 14 with ICR0 as TOP, or Mode 5/6/7 fixed frequency.

Hmm, I didnt see a reference to this in teh datasheet. I think this may be something Atmel forgot to mention.
It does let me use OCnB with OCRnB as the duty register though. It seemed like this peripheral was meant to produce a complimentary pair on OCnA and OCnB .

I was hoping to use the one capture register this chip has for input capture.
Oh well. Can't expect the peripherals to be perfect on this chip.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Port Pin Alternate Function
PB0
ADC0: ADC Input Channel 0
AIN0: Analog Comparator, Positive Input
OC0A: Timer/Counter0 Compare Match A Output
PCINT0: Pin Change Interrupt 0, Source 0
TPIDATA:Serial Programming Data
PB1
ADC1: ADC Input Channel 1
AIN1: Analog Comparator, Negative Input
CLKI: External Clock
ICP0: Timer/Counter0 Input Capture Input
OC0B: Timer/Counter0 Compare Match B Output
PCINT1:Pin Change Interrupt 0, Source 1
TPICLK: Serial Programming Clock
PB2
ADC2: ADC Input Channel 2
CLKO: System Clock Output
INT0: External Interrupt 0 Source
PCINT2: Pin Change Interrupt 0, Source 2
T0: Timer/Counter0 Clock Source
PB3
ADC3: ADC Input Channel 3
PCINT3: Pin Change Interrupt 0, Source 3
RESET: Reset Pin

Only PB1 has capture. So PB0 would have to do PWM for me to run capture and PWM. But capture uses the ICR0 reg.

This would mean that they have effectively disabled PWM (with any type of freq resolution) and capture running at the same time on the tiny10.

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

Quote:

It seemed like this peripheral was meant to produce a complimentary pair on OCnA and OCnB .

"Wow, THAT'S a nice pair!" -- example of a complimentary pair
"We should really have two outputs with opposite polarity." -- example of a complementary pair

There are other AVR models that indeed have true complementary timer outputs. And in general on AVRs Timer1 can be set up with the A and B outputs in opposite inverting/non-inverting COM bits.

Who knows what the intent was, but let's just say I've often used compare match A and B together and rarely (never?) as complementary outputs.

Quote:

Hmm, I didnt see a reference to this in teh datasheet. I think this may be something Atmel forgot to mention.

Reference to what? Actually, IIRC, you get exactly what you ask for when setting the COM bits for PWM on OC0A with OCR0A as TOP--you get a PWM with duty cycle equal to the period. Not very interesting, eh?

Quote:

I was hoping to use the one capture register this chip has for input capture.
Oh well. Can't expect the peripherals to be perfect on this chip.

Indeed, you have chosen a brain-dead AVR for this project and one of the few that doesn't have two timers. But it does have a "full" 16-bit "timer1"-style timer.

All is certainly not lost. It depends on your needs and what you are capturing and PWM-ing.

-- You could run 10-bit PWM, adjust ICP calculations accordingly, and run OC0A PWM.
-- You could let the timer free-run for full ICP work, and then use the leap-frog method to do the PWM using the compare-match facilities. https://www.avrfreaks.net/index.p...
-- You can do your own "ICP" using external interrupt and grabbing timer counts.

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

geoelec wrote:
Quote:
I must be missing something but I"m not sure what. Can yall tell from the initialization code?

The answer is that missing the correct avr,the assembly and even that how the program uploaded into flash.

Quote:
Where the hell the world is rolling down to?

For PWM tiny/10/11/12 can not do.Try tiny13.
For C programming can't be used since no sram is available,and the bad news are that tiny10/11 are not ispmkii programmable.I noticed after i bought it in my effort to upload the code into tiny11 when i was making some leds for my bike.Finally the job has done with tiny12.


You've fallen victim to a subtle joke that Atmel has played on us all.

The device currently being sold as the "ATtiny10" bears no relation to the ATtiny10 that was originally announced back in 1999. The original ATtiny10 was a pin-compatible drop-in alternative to the ATtiny11 which was OTP. The original ATtiny10 was discontinued before the ATtiny11/12 family made it into full production, probably because it didn't offer any significant feature/cost benefit over the ATtiny11.

The current ATtiny10 chip is a distinct device. It is the flagship of the extremely small 6-pin ATtiny4/5/9/10 family. It does have SRAM - albeit the amount is tiny. Thus it is possible - albeit cramped - to use a stack-oriented C compiler with it. It also uses a different Flash programming algorithm than either the ATtiny12 (conventional ISP) or the ATtiny11 (HVSP) called TPI. However, if you've wired everything correctly, TPI is also compatible with the AVRISPmkII.

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

Quote:
However, if you've wired everything correctly, TPI is also compatible with the AVRISPmkII
Quote:

Avrispmkii supports isp and PDI modes and no TPI,i didn't make it to program it in practice and one circuit i found on the web was too complicated to build for a such a small and cheap avr with a variety of alternative drop in solutions.

http://www.oocities.org/westfw/e...

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

You are absolutely correct that the ATtiny11 is not compatible with the AVRISP mkII. However, you're incorrect to draw any link between the ATtiny11 and the ATtiny10.

You're still confusing the modern ATtiny10 with a prehistoric ATtiny10 that was never released. The modern ATtiny10 bears no relation to the ATtiny11, in terms of pinout or in terms of programming algorithm.

AVRISP mkII supports TPI programming of the ATtiny10 starting with the firmware that was distributed with AVR Studio 4.18 SP1 on December 11, 2009.