Generate signal on pin PB0 in ATtiny25-20SU PWM mode

Go To Last Post
78 posts / 0 new

Pages

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

Brian Fairchild wrote:
I have these fuses...

So, you have a crystal, right?

If I had a crystal, I'd name it Blue Persuasion.

 

https://www.azlyrics.com/lyrics/...

 

Look over yonder
What do you see?

...

Ain't it beautiful, whoo-hoo
Crystal blue persuasion

...

Crystal blue persuasion
Mm-hmm
It's a new vibration
Crystal blue persuasion
Crystal
Blue persuasion
 

I >>had<< to do it, with the "vibration " in there...

 

 

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

Actually I have an external 8MHz oscillator, and those fuses are the wrong way up but because I have the external osc it still works.

 

I get the waveform shown back in #44 with the 8MHz internal oscillator selected.

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

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

If I had a crystal, I'd name it Blue Persuasion.

Tommy?!  Is that you?!

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

theusch wrote:

OP, try 8MHz internal oscillator...

 

 

For 8MHz your code show my on oscillator meander=1.4MHz

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

For clarity, I made the waveform back in #44 with these fuse settings...

 

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

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

@OP, look back at post #44. Is that what you are trying to do?

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

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

For 8MHz your code show my on oscillator meander=1.4MHz

1400000 * 6 clk = 8400000, which is +5% (within the +/-10% tolerance).

 

Now try your original code, but with the change suggested by @sternst in #3.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

Brian Fairchild wrote:

@OP, look back at post #44. Is that what you are trying to do?

 

Yes! but only use int RC generator

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

tvitklg wrote:

Brian Fairchild wrote:

@OP, look back at post #44. Is that what you are trying to do?

 

Yes! but only use int RC generator

 

Which is what I am doing. Ignore my statement about the external oscillator, when I took that photo I was running on the internal RC.

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

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

Ok, so now we have known working code and known working fuses.

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

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

Even more curious, why does AS use "INTRCOSC_4MHZ_6CK_15CK_64MS" for a CKSEL mode which results in a fixed 1.6 MHz system clock?  Since the OP seems to want 4 MHz, it would explain his choice.  AS strikes again?

From tiny25 data sheet:

6.1.6 Internal PLL in ATtiny15 Compatibility Mode
Since ATtiny25/45/85 is a migration device for ATtiny15 users there is an ATtiny15 compatibility mode for backward
compatibility. The ATtiny15 compatibility mode is selected by programming the CKSEL fuses to ‘0011’.
In the ATtiny15 compatibility mode the frequency of the internal RC oscillator is calibrated down to 6.4 MHz and the
multiplication factor of the PLL is set to 4x. See Figure 6-3. With these adjustments the clocking system is
ATtiny15-compatible and the resulting fast peripheral clock has a frequency of 25.6 MHz (same as in ATtiny15).

 

If I am not mistaken, that is how the fuses are set in post #42 and /OC1A is not available in Tiny15 mode (as per post #40).

 

 

Anyone?

 

I'm not an AS user, so can only guess.  I suppose the _4MHZ might be a mangling of 6.4MHz...?  Since the OP was looking for 4 MHz, this would seem to be an unfortunate 'feature' of AS...?

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

Example in post №44 In 8MHz all is work surprise  On PB0 and PB1 is try signal=1kHz... It is incomprehensible... Where simple human logic ...

Last Edited: Fri. Oct 20, 2017 - 04:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

joeymorin wrote:

I'm not an AS user, so can only guess.  I suppose the _4MHZ might be a mangling of 6.4MHz...?  Since the OP was looking for 4 MHz, this would seem to be an unfortunate 'feature' of AS...?

 

Nor me but I have v4.19 installed which correctly shows...

 

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

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

I was going to see what 6.2 did but I've just remembered why I loath Studio...

 

 

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

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

Brian Fairchild wrote:

I was going to see what 6.2 did but I've just remembered why I loath Studio...

 

This is not the only one strangeness of the AS ...
 

Last Edited: Sat. Oct 21, 2017 - 01:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As I understood to run tiny25 on 4MHz does not work in tiny25 mode. 8MHz is a lot for my purposes.

 

I also add that the PB3 and PB4 pins are inverted under different modes. (I have a control buttons on them)

 

Another small question is why PINB=(1<<PB2) gives an inverse signal at the output on PB2 pin? In code from theusch in post №24

I expected this behavior for logical operations for example - PORTB^=(1<<PB2)

Last Edited: Sat. Oct 21, 2017 - 01:31 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As I understood to run tiny25 on 4MHz does not work. 8MHz is a lot for my purposes.

#include <avr/power.h>
.
.
.
  clock_prescale_set(clock_div_2)

 

 

Another small question is why pinb = 1 << PB2 gives an inverse signal at the output? I expected this behavior for logical operations of the type - PORTB^=(1<<PB2)

Recent (last 10 years?) models of AVR support this:

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Many Thanks a lot, everyone thanks! smiley

The question is closed.

 

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

tvitklg wrote:
8MHz is a lot for my purposes.

??? 

1)  What does that have to do with your waveform generation problem?

2)  As the datasheet says, there is NO direct selection of a 4MHz clock in that model series.

2a)  The apparent selection, as in your earlier post, appears to be a typographical error or editorial contraction for the 6.4MHz selection in Tiny15 mode

3)  Your model has a CLKPR register, which has a /2 setting ...

3a) ...and in fact, nine choices from /1 through /256.

4)  What difference does it make for your purposes if your AVR runs at ~8MHz or some fraction of that?

5)  Besides CLKPR to select a nominal value, OSCCAL can be used to tune that nominal value.

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

theusch wrote:

tvitklg wrote:
8MHz is a lot for my purposes.

??? 

1)  What does that have to do with your waveform generation problem?

2)  As the datasheet says, there is NO direct selection of a 4MHz clock in that model series.

2a)  The apparent selection, as in your earlier post, appears to be a typographical error or editorial contraction for the 6.4MHz selection in Tiny15 mode

3)  Your model has a CLKPR register, which has a /2 setting ...

3a) ...and in fact, nine choices from /1 through /256.

4)  What difference does it make for your purposes if your AVR runs at ~8MHz or some fraction of that?

5)  Besides CLKPR to select a nominal value, OSCCAL can be used to tune that nominal value.

 

1. For the test, it does not matter. For subsequent use, some difficulties may arise.

2. Now it is clear. I'm used to if the IDE for programming is 4MHz, it means that the registers write the corresponding values so that I do not waste time and do not check every step

3. I do not know exactly the details and subtleties of the possibility of tiny25. I did not draw attention to the full study of the subtleties of the chip. He was engaged in other higher-level issues and focused on the main task.

4. Big difference. This system works constantly 24 hours a day and controls light with voice recognition. Therefore, you need a minimum consumption. In addition, the tiny25 Has function zero cross detector voltage of 220v on Analog comparator for performs the control of the thyristor 220v and recognizes trained commands for control from the IR remote. Also detects commands and delays between pulses from the older brother (AT32UC3L064). Therefore delays and dividers are extremely important. Everything is tuned for another 1.6MHz frequency. And the PWM mode was required with a new approach for controlling the LED strips for example sources 12v...

5. I did not disassemble the instructions to the this chip to the nuances. I was hoping for the IDE AtmelStudio programming environment. I did not expect that there will be problems with Tiny. And forgot about the compatibility mode of tini15. However, the coincidence of the Russian description for tiny15 alarmed me. But he did not attach much importance to this, I thought it was just because of the compatibility of the chips. That they are similar. Earlier, maybe I was the one who chose this particular mode tiny15, but it was a long time difficult to remember why I chose the mode of tini15

 

Most likely, maybe for the first time I did not suspect that Tiny25 works like a tini15. Case in the AS, I just calculated that 4 MHz is enough for me and focused on other problems and the real frequency of the chip did not check, but the AS recorded 1.6 MHz and switched on the mode of tiny15 ...

 

Last Edited: Sun. Oct 22, 2017 - 03:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are a couple of issues which have bitten you.

 

One is that the CKSEL fuses select an >>oscillator<< source.  This only indirectly sets a clock speed.  This is true of all devices, not just the t25.  The clock is derived from the oscillator.  In the case of the t25, the CKSEL=0b0011 selects the internal oscillator, >>and<< tunes it to 6.4MHz, >>and<< fixes the system clock prescaler to /4, >>and<< enables t15 compatibility mode.  It's true that your IDE gives no indication of this, but IMO if you are working with a device then you shouldn't rely on the IDE to educate you about that device.  That's what the datasheet is for.

 

Second, and this is a bit of a kick in the teeth, you were truly misled by the "INTROSC_4MHZ_..." descriptor for your choice of CKSEL.  As shown by Cliff and Brian, that problem appears to be unique to AS 6.x, whereas 4.x and 7.x correctly show 6.4 MHz, and 4.x even correctly shows that t15 compatibility mode will be selected.

 

Perhaps it's time to upgrade to AS 7?

 

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Sun. Oct 22, 2017 - 04:09 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

joeymorin wrote:

There are a couple of issues which have bitten you.

 

One is that the CKSEL fuses select an >>oscillator<< source.  This only indirectly sets a clock speed.  This is true of all devices, not just the t25.  The clock is derived from the oscillator.  In the case of the t25, the CKSEL=0b0011 selects the internal oscillator, >>and<< tunes it to 6.4MHz, >>and<< fixes the system clock prescaler to /4, >>and<< enables t15 compatibility mode.  It's true that your IDE gives no indication of this, but IMO if you are working with a device then you shouldn't rely on the IDE to educate you about that device.  That's what the datasheet is for.

 

Second, and this is a bit of a kick in the teeth, you were truly misled by the "INTROSC_4MHZ_..." descriptor for your choice of CKSEL.  As shown by Cliff and Brian, that problem appears to be unique to AS 6.x, whereas 4.x and 7.x correctly show 6.4 MHz, and 4.x even correctly shows that t15 compatibility mode will be selected.

 

Perhaps it's time to upgrade to AS 7?

 

 

1. AS 7 does not work in Windows XP...

2. I'm going to switch to Linux and gradually write all the programs for Linux. There is no AS for Linux and as I understand it Will not appear soon or will not exist at all. Support for several years said there is a GCC and avrtoolkit.

3. With such prices for chips from Atmel, I will gradually move to STM in which 32 bits of chips from $ 0.5

4. The whole problem was due to the fact that in Russia to make a device and sell you must pay for the paid certification and development of technical documentation for the product. If your device works above 50 volts. The certificate costs $ 1000 per year. Therefore, in order to do something and sell, you must enclose in Russia a tribute to the state, an entrance ticket. Prove that everything is safe, although no one has proven to you that your device is dangerous and it can not be sold to the public. For comparison, there are no certificates in Finland. There, information on the product is written on the label or in the instructions to the product ... For factories and large companies to pay for a certificate is not a problem. But for entrepreneurs and a private business or a small company it is actually a ban on any innovative activity and gradual progressive development ...

 

Last Edited: Sun. Oct 22, 2017 - 04:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I personally have never (and will never) used AS, so I can't blame you there ;-)

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

tvitklg wrote:
For comparison, there are no certificates in Finland. There, information on the product is written on the label or in the instructions to the product ...

 

Having never done this myself, but read about it in several posts here in the past my memory might fail me in details but this is how I understand the regulation of high-voltage devices in EU:

 

In Finland, as in the rest of the EU, you will need to guarantee that your device is "reasonably" safe. If it later turns out that it isn't you're in potentially big trouble.

 

For this reason, many (most?) manufacturers of high-voltage products hire special "proving laboratories" that are specialists on performing the necessary inspections and tests. And that can potentially cost many thousands of $ / €.

 

(Mind you, if something still goes wrong you're still in potential trouble, not the test lab. You only hire them to get a "valued opinion" so to say.)

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

JohanEkdahl wrote:

tvitklg wrote:
For comparison, there are no certificates in Finland. There, information on the product is written on the label or in the instructions to the product ...

 

Having never done this myself, but read about it in several posts here in the past my memory might fail me in details but this is how I understand the regulation of high-voltage devices in EU:

 

In Finland, as in the rest of the EU, you will need to guarantee that your device is "reasonably" safe. If it later turns out that it isn't you're in potentially big trouble.

 

For this reason, many (most?) manufacturers of high-voltage products hire special "proving laboratories" that are specialists on performing the necessary inspections and tests. And that can potentially cost many thousands of $ / €.

 

(Mind you, if something still goes wrong you're still in potential trouble, not the test lab. You only hire them to get a "valued opinion" so to say.)

 

This is so and it is useful when one time. And when every year with you rip off all the wool, then the question arises - where is the logic. After all, my device did not change.

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

Sorry if I came through as defending the Russian scheme you described - it was not my intention. I merely wanted to point out that in practice you might very well spend a five digit sum of € to be relatively safe from trouble in the future.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

tvitklg wrote:
Therefore, you need a minimum consumption.

Again, in exploring your original problem situation, we know nothing that minimum consumption is a primary criterion.

 

Still, "Water, water, everywhere and not a drop to drink" -- interesting situation with the mains actually connected, eh?

 

Anyway, there are many ways to get a lower clock than selecting between 8MHz and 6.4MHz.  And in fact, nearly all the time lower consumption is had with going fast and then going back to sleep faster.

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.

Pages