Split from: Getting a Specific PWM Frequency

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

DAER 

I HAVE TRY TO BUILD A PCB ON BASE OF APPLICATION NOTE AVR444

WITH ATMEGA 48 20MHZ

BUT THE PWM OUTPUT IS ONLY 2KHZ NOT 20KHZ

IS CORRECT,OR WOTH SHEL I DO ?

BEST REGARDS

vandi

Last Edited: Sat. Jul 1, 2017 - 03:00 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Vandi.

 

You have posted 5 times in different threads on the same topic.

 

Stay in  this thread or you will be banned.

 

Moderator

 

Ross McKenzie ValuSoft Melbourne Australia

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

Vandi mauro wrote:
WOTH SHEL I DO ?

First thing to do is to TURN OFF CAPS LOCK !!

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Vandi mauro wrote:
WOTH SHEL I DO ?

For a start:

  • Show us your code.
  • Tell us what clock source you have (crystal, internal RC.. ?).
  • Tell us if/how you've programmed the AVR fuses to select that clock source.
  • Tell us how you measure the PWM frequency.

 

Without this information (and maybe more that we will then ask about) there is nothing we can do to help you. We can not guess what your code looks like. We can not guess what clock source you have, and check that you've set it up correctly.

 

Right now, it if you called a car mechanic and say "My car won't start. Why?". I hope you do realize that with that little information, the car mechanic can do nothing to help you.

 

And I join in with others: Turn off caps lock when you post here!

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"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

Thank for ans ware

The code is the sample avr444

Sorry for caps lock

I attach the project made for IAR compiler

 

I,m using a atmega48 20AU on pcb I use external crystal clock 20Mhz

but i don't find where setting in iar compiler because is first time for me

 

 I measure the PWM frequency by oscilloscope is about 0.479ms (2.5Khz)

 

I don't have programmed avr fuses , you are right .Where is it ?

 

best regards

 

Attachment(s): 

vandi

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

sorry

I do

 

vandi

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

Sorry, but I'm not an IAR user. I can probably not be of much help here.

 

Only this: If the fuses of the AVR never has been programmed they are at their factory default. What the factory defaults are is written in the data sheet for the AVR model you use. I would suspect it says something to the effect of the internal RC oscillator being used, giving an effective frequency of 1 MHz.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"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]

Last Edited: Sun. Jul 2, 2017 - 12:18 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Johan

I think you are Right

the command for write the flash is:

C:\Users\vandi\Documents\dude\avrdude.exe

the argumentis:

-p m48 -c usbasp -P usb -U flash:w:"$PROJ_FNAME$.HEX":i

may be I need to change something here?

thank you

 

vandi

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

I don't know.

 

You're so confusing..

 

You said you use IAR, but now you're talking about AVRDUDE. (Depending on what you're using you need to read either the IAR documentation or the AVRDUDE documentation.)

 

The documentation on the project BLDC project (I hope you've read it!) talks about a clock frequency of 8 MHz, yet you talk about a 20 MHz crystal.

 

If nothing well structured comes next I'm not interested anymore.

 

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"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

sorry for my confusion

I'm using IAR Assembler for AVR  6.80.1 (6.80.1.1057) for made   *.hex file

then avrdude.exe for write device

thank  you

vandi

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

Please explain your real life tools and experience.

 

1.  Do you own an IAR licence?

2.  Do you want to use the free GCC tools?  e.g. that come with AS7

 

The AVR444 App Note that you posted will only build with obsolete IAR tools.

 

It is easier to maintain a C program than an ASM program.

It is almost impossible to do anything with a HEX file.  (except program the AVR with a fully debugged binary)

 

David.

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

You're only getting us more and more confused. Some of what you've said:

  • You're using IAR, specifically you've said "IAR Assembler"
  • You're using the code for Atmels application not #444
  • You've attached that code here. It is C code (not assembler).

 

You obviously 

  • EITHER have no clue about what you're doing (if this is the case - start with something simpler. Blink a LED, is the usual "starter".)
  • OR can not express what you're doing (if this is the case - sit down and take your time to put together an organized description of what you're doing)
  • OR possibly both of the above.

 

Whichever it is you

  • will wear out your welcome, and people will not be interested in helping you, and 
  • you will not solve your problem

 

It is completely up to you to describe what you're doing, and formulate good question, in a way that makes us

  1. interested, and
  2. able to help you.

So far you've done neither.

 

I won't spend more time here.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"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

You're using IAR, specifically you've said "IAR Assembler

sorry you are right I"' write wrong : I use Iar embedded for generate  file .hex .

 

 

but one question :is possible to change the code application avr444 to use

 atmega48 with external clock of 20 MHZ or isn't possible ?

 

Is my first application sorry....

 

I have used the application avr444 for this reason.

 

 

 

vandi

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

I asked whether you had an IAR licence. If you have, that is an excellent reason for using IAR.
There are some but not many IAR licence holders here.
.
But most punters use the free GCC tools.
.
Regardless which tools you use, your atmega48 is never going to run at 20MHz unless you purchase a real-life 20MHz clock module. These normally have 4 or 6 pins and can be bought from Farnell, Digikey etc.
.
David.

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

thank you 

I try to find 20MHZ clock moduls

 

vandi

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

Regardless which tools you use, your atmega48 is never going to run at 20MHz 

Vandi mauro wrote:

 

I,m using a atmega48 20AU

 

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

your atmega48 is never going to run at 20MHz 

Why not? It is a 20MHz chip when used from 4.5V-5.5V with external crystal or oscillator (which seems to be what he want to do).

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

His original intention was to select external clock without buying an external clock.
In #15 he decided that he would try and obtain an external clock.
Yes, of course he could run on a 20MHz external crystal. But he would need to buy a crystal AND set the fuses for external crystal.
.
Life would be a lot easier if we knew about his IAR licence. AVR444 will build with a small chip. Real life projects might need more than a 4kB chip. In which case a paid licence is required. In my humble opinion there is little point in learning how to use IAR unless you are prepared to buy a full licence.
.
David.

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

According to the datasheet the Clock sources are

 

1. Internal RC oscillator

2. Crystal oscillator

3. External clock

 

Vandi mauro wrote:
I use external crystal clock

What should we imagine under this mixture?

 

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

@Vandi.

 

Do you have an IAR licence?

 

Ross McKenzie ValuSoft Melbourne Australia

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

Folks, do you not remember IAR? As far as I recall you do not need a license to use the ASSEMBLER. It is the compiler that you require a license for.

 

I can't help thinking that the "problem" here is using some very old, out dated app note to get BLDC code. Surely there have been many many BLDC projects for AVR posted on the internet (even the projects section here) that are not tied to using some 15..20 year old build tool?

 

Just the shortest of Googles, for example, brings me to here:

 

https://github.com/paulfantom/BL...

 

That appears to be the algorithm from AVR444 implemented in avr-gcc C code

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

Never used it.... so just reinforcing the unanswered question(s) above. Will crawl away quietly....

 

Ross McKenzie ValuSoft Melbourne Australia

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

No i don"t have jar licence at the moment

but i use only for generate .hex file from avr444 source code

 

 

vandi

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

Thank for the help

I think I need to select well the ardude writer for  external clock

I have try for atmega 48 20mhz this argument:

 

-p m48 -c usbasp -P usb -U flash:w:"$(ProjectDir)Debug\$(TargetName).hex":i  lfuse:w:0x66:m -U hfuse:w:0xDF:m

 

seem work the led flashing

 

I test for avr444 application and I inform you

 

 

 

 

vandi