Alpha testing of new AVR calculator

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

I'm attaching an initial version of a freeware AVR calculator (for UART and timers). Any suggestions for improvement would be most welcome.

The windows .exe file can be downloaded from http://b9.com/elect/avr/avrcalc/...

Attachment(s): 

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

There is a special wizard for NEC microcontrollers called Aplilet. It is given for free at the american site of NEC (www.necel.something......). Also there is a compiler for PIC called CCS which includes a very good wizard for PIC micros.
Is there any profetional wizzard for ATMEL AVR micros?

Michael.

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

There is a wizard in one of the commercial C compilers (IAR ??)

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

Jim,

This may make you lough;;; I use the IAR 4.20A and I didn't know it. Does my compiler includes this tool?

Michael

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

ICCAVR has an Application Builder. It doesn't support all devices though but it's very handy.

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

Codevision has a wizard as does Atman AVR

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

Finally,

Does anyone knows this tool that IAR supports, as Jim said in one of the above posts???

I am talking about an AVR wizzard.

Thanks.

Michael

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

Michael, the IAR C/C++ compiler and embedded workbench do not come with a code wizard. However, IAR sells some other tool to help rapidly code finite state systems -- but I haven't tried it.

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

The link have me an error, that the file is not on the server... :-(

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

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

daqq,

There was no error for me. Are you trying to downlod something?

Michael

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

The link routed me to this: http://www.b9.com//elect/avr/avr... . Strange... I am trying to download the file in the link. Tried it with firefox, opera. It gives me:

Not Found
The requested URL /elect/avr/avrcalc/avrcalc.zip was not found on this server.

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

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

Yes, there was a (separate) tool from IAR that allows to configure AVR's, but I didn't check it, and right now I don't know if it is still there. I used the ARM version of that, and I found it too heavy to use, since it creates a whole amount of files, headers, functions, etc. If it is the same vor AVR's, then it could be useless.

I found ICC wizard very handy, but just on the opposite side, since it don't use the more understandable notation like TIMSK=(1<<TOVF1) but TIMSK=0x01.

IIRC, there is some AVRCalculator at some web like forestmoon or similar.

Guillem.
"Common sense is the least common of the senses" Anonymous.

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

I see the same error even trying with Maxthon Browser.

Michael

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

daqq,

I downloaded the avrcalc.exe from this link 5 days ago and I will upload it from my pc asap. Please wait a little bit.

Michael.

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

What about now?

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

Grrrrrrr...

I can't upload it. Why is this hapened?
I upload the file named avrcalc.exe

Michael.

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

Try to zip it first.

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

What about now???

Michael

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

What about now?

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

Oh, I found it. It says Attachment is too big (max 1Mb). The .zip file is ~1,6MB. What can I do for you???

Michael

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

Split it into two files.

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

Thanks for the effort! I'll try downloading it later.

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

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

Daqq,

Try entering the site (http://www.b9.com/elect/avr/avrc...). There is a link in there.

Better yet, here is the link

Felipe Maimon

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

Sorry about the change of URL. As posted in a different thread, I change the name of the program to avoid confusion with an earlier progrma of the same name.

The canonical URL for the current version is http://b9.com/elect/avr/kavrcalc...

Thanks for looking!

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

Here's a screenshot from the latest version for people deciding whether to download or not.

Attachment(s): 

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

Thanks! Works great!

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

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

Thanks for the report, David. Please forward any feature requests that you have.

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

Do you plan on releasing the source? You said freeware, just curious how "free". In any case, this looks great however the linux binary fails with:

20610978 201DA931 -> 201DA85A = ("SYMBOL-FUNCTION-VECTOR" 4258)
206109B8 201E7669 -> 201E75FA = ("SYMBOL-FUNCTION-VECTOR" 629)
206109E0 2023019E -> 2023003A = #:||
20610A00 2025D500 -> 2025D3FA = ("SYMBOL-FUNCTION-VECTOR" 4269)
20610A14 2025FD35 -> 2025FCBA = ("SYMBOL-FUNCTION-VECTOR" 2644)
20610A44 2025C387 -> 2025C242 = ("SYMBOL-FUNCTION-VECTOR" 2235)
20610A8C 20321050 -> 20321042 = ("SYMBOL-FUNCTION-VECTOR" 1305)
20610A98 20321194 -> 2032116A = ("SYMBOL-FUNCTION-VECTOR" 1182)
20610AA0 20098DAB -> 20098D9A = "Unknown"
20610AB0 201C190A -> 201C17CA = "Unknown"
20610B90 2028A49B -> 2028A472 = #:||

Can you provide details on the required libraries? It appears to be some sort of Ruby/Lisp type binary linked against libXm?

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

Good question, uidzer0. I'll add a license file. In summary: free to use and redistribute unmodified binary for any commercial or non-commercial application, no warranty, etc.

As for the linux binary, yes it is Lisp linked against libXm. I'll test and see if I can duplicate your error results. What Linux distribution are you using?

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

Quote:
Thanks for the report, David. Please forward any feature requests that you have.
It would be nice if it wrote some DAMN CODE I'm figthing with for a few hours :-D

Just joking :-D Seems perfect to me - simple, useful, gives you what you need and is small - in terms of GUI. Although a "string to hex to binary and back again" is always useful (I use an opera plugin for the task).

And I hate to be a nitpick, but where did the 5.5MB for a single for application come from?

A little more nitpicking: When I enter a value into the Value text thingie under "Desired Timing" it does not update immediately. It updates only when I press one of the Radio buttons. Or do something else.

Thanks for a valuable tool!

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

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

Ahhh, great =]. I'm running Ubuntu 7.10 here at work, I can check it against Gentoo when I get home. I'm guessing I'm just missing a library here so I'll keep messing with it and let you know exactly what I came up with.

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

daqq wrote:
Quote:
Thanks for the report, David. Please forward any feature requests that you have.
It would be nice if it wrote some DAMN CODE
I think the next major addition of functionality will be an explorer of AVR parts. That is, modules and registers for each AVR part. At some point, I might add the ability to generate code.

Quote:
Although a "string to hex to binary and back again" is always useful
That sounds useful to add. String back and forth to hex certainly. But, do you really want binary 0 and 1 representation? About how many characters would you say the field should hold. 32?

Quote:
And I hate to be a nitpick, but where did the 5.5MB for a single for application come from?
The Lisp runtime libraries. Advatage: using those libraries allows the program to be compiled on Windows, Linux, and Mac. Though, I don't own the Mac compiler.

Quote:
A little more nitpicking: When I enter a value into the Value text thingie under "Desired Timing" it does not update immediately. It updates only when I press one of the Radio buttons. Or do something else.
Excellent note. Thank you that's just the kind of feedback I need. Is this with version 1.4?

Quote:
Thanks for a valuable tool!
And thanks for your feedback and suggestions!

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

uidzer0 wrote:
Ahhh, great =]. I'm running Ubuntu 7.10 here at work, I can check it against Gentoo when I get home. I'm guessing I'm just missing a library here so I'll keep messing with it and let you know exactly what I came up with.
I have Ubuntu 7.10 here as well. Are you using 32-bit or 64-bit Intel distribution?

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

Quote:
Excellent note. Thank you that's just the kind of feedback I need. Is this with version 1.4?

Version 1.4
Build date: January 14, 2008

From the about box.

About the code thingie: I was really just joking :-D

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

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

Exactly! I reinstalled lesstif-dev and then had to modify my LD_LIBRARY_PATH to include /usr/lib (not sure why it wasn't...), ldconfig, then finally found the problem:

 libXm.so.2: wrong ELF class: ELFCLASS64.

So =], any chance for a 64bit binary?

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

daqq wrote:
Version 1.4
Thanks, David.
Quote:
About the code thingie: I was really just joking
I know, you were asking for it to write some really smart code for you. But, I was not joking, after an AVR Explorer module, I'm going to look at writing an application to produce some rather dumb, but necessary, code.

But, how about that string/hex converter. Do you really want a binary 0/1 representation as well?

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

uidzer0 wrote:

 libXm.so.2: wrong ELF class: ELFCLASS64.

So =], any chance for a 64bit binary?

Not unless I find a spare $4500 lying around. But, a less expensive alternative would be for me to bundle the 32-bit Motif libraries with the 32-bit application.

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

Quote:
But, how about that string/hex converter. Do you really want a binary 0/1 representation as well?
Well, I used it a few times (although not for AVR projects. it was for some graphic stuff I did). It's not a requirement, there's a bazilion other programs/pages that do it. In the years when I was starting programming (visual basic) I even wrote my own. So it's not neccesary :-D

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

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

kmr wrote:
But, a less expensive alternative would be for me to bundle the 32-bit Motif libraries with the 32-bit application.

That'll work =]

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

Okay, David, thanks for the suggestion. It actually won't be hard to add, but I'll probably cut the max string size down. 32 characters converting back and forth to 256 bits is a bit(sorry!) much.

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

uidzer0 wrote:
That'll work =]
For now, I took down the Linux version. I'll announce when I re-add (more robust) Linux support.

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

Quote:

For now, I took down the Linux version. I'll announce when I re-add (more robust) Linux support.

Nice, looking forward to it :)

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

kmr wrote:
Any suggestions for improvement would be most welcome.

a linux version

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

Quote:
a linux version
ROFL .... you Brittish !

Very usefull tool Kevin. I used the Windows version, and tried the linux-version on Ubuntu. Hmmm ..... can somebody help this linux-noob with an instruction how to install it ?

Nard

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tessa and Tina, 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

Up a couple of posts will give you details on the status of the linux version. It's a binary so to execute it you should be able to just run ./kavrcalc (when it's available again).

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

But where do I install it ?? .... NOT on the desktop. That doesn't work for a normal user, nor for a user with admin-rights. Did I say I am a Linux-noob ?

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tessa and Tina, 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

Plons wrote:
But where do I install it ?? .... NOT on the desktop. That doesn't work for a normal user, nor for a user with admin-rights. Did I say I am a Linux-noob ?

Ah - gotcha, putting it in /usr/local/bin should make it available to you on the command line. From there adding it to menu's etc is pretty easy.

Assuming you're using gnome and you want to add it to the quick launcher you'd just right click on the panel, click "add to panel". Then click "Custom Application Launcher", fill in the "Name" with whatever you want and "Command" with the path to where you put it ie: /usr/local/bin/kavrcalc

edit: added some screen shots for ya

Attachment(s): 

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

Hi Kevin

Very impressive program.

Suggestion :-
Incorporate a "Delay Calculator" that will generate either the "assembler" or "C" code.
Similar to the
http://www.home.unix-ag.org/tjabo/avr/AVRdelayloop.html
Apparently it can generate the cycles but will not do anything in the time mode.

I did mail to Tjabo Kloppenburg who wrote the program back in November 2006.
To this day, I still not received a reply.

Cheers
Ken

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

Gee Kevin,

With all of the requests for code generation, it looks like I could have just forgone the PM requesting the same...

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

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

pykedgew wrote:
Incorporate a "Delay Calculator"
Thanks for the suggestions, Ken. As a quick feature to add to the next version, I'll add a cycle count to the timing section for use with compilers like IAR which has a __delay_cycles() function that takes a 32-bit integer.

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

uidzer0 wrote:
Ah - gotcha, putting it in /usr/local/bin
Nice explanation and sheetshots!

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

microcarl wrote:
With all of the requests for code generation, it looks like I could have just forgone the PM requesting the same...
Well, I am considering code generation. But, the next step I plan after adding some more computations is to add an AVR part browser. By having a comprehensive list of parts, their modules, registers, and bitfields, that'd be a natural next step before adding code generation.

Thanks for all your suggestions and feedback thus far.

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

uidzer0, thanks for your clarification.
I created a new user with admin-rights, in the same group as I am in, as user, and root is. When logged in as admin, I still don't get access to the folder /usr/local/bin. Very frustrating. Apparently, Linux i.c. Ubuntu is not meant for people like me. Too complicated. I give up. On Linux, that is.

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tessa and Tina, 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

kmr wrote:
Quote:
(...)And I hate to be a nitpick, but where did the 5.5MB for a single for application come from?
The Lisp runtime libraries. Advatage: using those libraries allows the program to be compiled on Windows, Linux, and Mac. Though, I don't own the Mac compiler. (...)

You got to try TCL/Tk on your next version. On Linux, the interpreter is already installed, on Windows you can compress everything in less than 2MB, and the script code is always ready to run on both platforms (and others) :).

Embedded Dreams
One day, knowledge will replace money.

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

kmr wrote:
(...) But, the next step I plan after adding some more computations is to add an AVR part browser. By having a comprehensive list of parts, their modules, registers, and bitfields, that'd be a natural next step before adding code generation.

Suggestion: use the XML files from AVRStudio.

Embedded Dreams
One day, knowledge will replace money.

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

Plons wrote:
uidzer0, thanks for your clarification.
I created a new user with admin-rights, in the same group as I am in, as user, and root is. When logged in as admin, I still don't get access to the folder /usr/local/bin. Very frustrating. Apparently, Linux i.c. Ubuntu is not meant for people like me. Too complicated. I give up. On Linux, that is.

Nooo! Don't give up! You'll have to be a root user to copy the file there, after that you're good.

sudo -s
[enter root password]
cp ./kavrcalc /usr/local/bin
exit

If you're still stuck let me know and I'll be happy to help out.

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

Nuno wrote:
Suggestion: use the XML files from AVRStudio.
It's a good suggestion. I already have written the XML parser and tree-walker to extract information from those files. I need to clarify with Atmel, though, what rights one has to reuse the data in those files in other applications.

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

Nuno wrote:
You got to try TCL/Tk on your next version. On Linux, the interpreter is already installed, on Windows you can compress everything in less than 2MB, and the script code is always ready to run on both platforms (and others) :).
I'm quite familiar with TCL and Tk. You're right, they do have good cross-platform graphic tools. But, as a language, Common Lisp has much greater powers of abstraction making creation of complicated programs rather simple. Plus, it's compiled to native code rather than interpreted. For a simple calculator, Common Lisp can be considered overkill. But, I have plans for extension beyond the calculator.

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

kmr wrote:
(...) Plus, it's compiled to native code rather than interpreted. For a simple calculator, Common Lisp can be considered overkill. But, I have plans for extension beyond the calculator.

Todays PCs are quite fast. Even in TCL you can do amazing things... what have you in mind that you need so much computing power for :)?

Embedded Dreams
One day, knowledge will replace money.

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

Nuno wrote:
Todays PCs are quite fast. Even in TCL you can do amazing things... what have you in mind that you need so much computing power for :)?
I certainly agree about the speed of modern PCs. If TCL/Tk was a better language for programming, I'd use it even if it was interpreted. But, I'm choosing a much more powerful language to program in. Due to it's powerful macro capabilities and the ability to use data as compiled code, Lisp is commonly used in DSL (domain specific languages) applications -- if that gives you an idea where I'm going.

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

kmr wrote:
Here's a screenshot from the latest version for people deciding whether to download or not.
Kevin,

After seeing a number of appends about this tool, I decided to download it. The referenced append does not contain the link. Then I tried the link in the very first append and that failed too. Would you mind editing your posts to put in the correct link so other people don't spend time searching on how to download your tool.

I tried it and it looks good. I have some feedback to improve the user interface:

  • Separate out the clock speed into a nice box - it is kinda underwhelmed at the far far top left of the window.
  • I cannot type a desired baud rate - only choose from a supplied range which is missing the higher speeds by the way as well. I would also like to type in a UBRR value and see the baud rate.
  • The format for the values in the Clock speed drop down is inconsistent with the list of common clocks i.e. how are you going to specify 1MHz; as 1.0 or 1.0000?
  • The background color for the text is slightly different to the color for the window itself. I find this harder to read but this is a nit. The two colors are white (255, 255, 255) and "off-white" (255,251,240).
  • Rather than one very large window, I preferred the tabbed pane approach. Each distinct function is on a separate pane with of course the clock speed common to all tabs. This also allows use to add new function such as TWI SCL frequency or SPI SCK frequency.
  • Some help on how to use the various parts of the interface would be extremely helpful. Some aspects of the UI need "discovery".

--Mike

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

mikeperks wrote:
Would you mind editing your posts to put in the correct link so other people don't spend time searching on how to download your tool.
I appreciate your suggestions very much, Mike. I imagine I'll be able to incorporate most of them in my next release. An answer to one question follows:
Quote:
The format for the values in the Clock speed drop down is inconsistent with the list of common clocks i.e. how are you going to specify 1MHz; as 1.0 or 1.0000?
Well, 1 and 1.0 and 1.0000 are all the same numeric value. What's your idea? Have them all be the same number of decimal places?
Quote:
Rather than one very large window, I preferred the tabbed pane approach. Each distinct function is on a separate pane with of course the clock speed common to all tabs. This also allows use to add new function such as TWI SCL frequency or SPI SCK frequency.
That's a reasonable idea. I've been using tab panes for adding the AVR Part Explorer. I might be able to integrate its tabbed panes along with the calculator's tabbed panes.
Quote:
Some help on how to use the various parts of the interface would be extremely helpful. Some aspects of the UI need "discovery".
Quite true. My plan was to work on that after adding whatever features that will be stable after the initial feature expansion stage.

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

A calculator application is nice for the design phase and play "what-if". When you get to implementation, I like to have the computer do the math for me instead of having "meanless" constants around. I wrote a small pre-processor to calculate timer constants. This means that I can use "extra functions" in my code, like:

[[t0cnt_us period_us]]  (calculate TCNT0 for 'period_us' given in us)

which allows me to do code or macros like this one:

#define timer0_SetupPeriodicHz(frequency) \
        { \
            TCCR0 = 0; \
            TCNT0 = [[t0cnt_hz frequency]]; \
            TCCR0 = (TCCR0 & 0xF8) | [[t0pre_hz frequency]]; \
            TIMSK |= _BV(TOIE0); \
        }

The code generated is "constant" so there's no run-time penalties.
My pre-processor (I call it AVR-CPP) is inserted as the 2nd compilation stage (after C preprocessing), and is perfectly integrated with the C toolchain (WinAVR) in a way that, if there's any error, the correct source code lines are always displayed.
Here's an extract example of a compilation output:

> make.exe all
avr-gcc -pipe -g -I. -O2  -Wall -mmcu=attiny26 -DF_CPU=6000000UL -Werror  -E -o stepdriver.i.tmp stepdriver.c
tclsh.exe avrcpp.tcl -mcu=attiny26 -fcpu=6000000UL  -in=stepdriver.i.tmp -out=stepdriver.i
AVR-CPP: attiny26 @ 6.0 MHz
	208 us - 1 8 64 256 1024
	FREQ Timer 0: 4800Hz, div 100
	208 us - 1 8 64 256 1024
	FREQ Timer 0: 4800Hz, pres 2 (/8)
	F = 4807 Hz
rm -f stepdriver.i.tmp
avr-gcc -pipe -g -I. -O2  -Wall -mmcu=attiny26 -DF_CPU=6000000UL -Werror  -c -o stepdriver.o stepdriver.i
(...)

The CPP picks up stepdriver.c and runs it only through the CPP outputting stepdriver.i.tmp. Then my AVR-CPP picks it and generates stepdriver.i, which is then finally handed-over to the compiler. This is all done in a makefile, of course.

I targeted AVR-CPP at my needs at the time, which were counters on tiny26 so that's what it supports. But would be nice to have it for everything on all AVR models, and even have more complex functions too, like generating pieces of code and not only constants calculation. This is a suggestion to where you could head your application next :).

Embedded Dreams
One day, knowledge will replace money.

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

Interesting idea about the preprocessor, Nuno. With the C preprocessor and static functions, gcc (and iar) can do a lot of the computation at compile-time. Like the setbaud.h header file floating around that automatically calculates a UBRR and displays a C #error if the error rate for the requested baud is too high. But, your C preprocessor obviously can do more than just the C preprocessor -- cool thing!

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

kmr wrote:
[Well, 1 and 1.0 and 1.0000 are all the same numeric value. What's your idea? Have them all be the same number of decimal places?

Yes, use the same number of decimal places for a particular number so 1MHz is always written as 1.0 for example.

--Mike

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

Okay, Mike. I changed to formatting so that clock rate is always display with the same (6) number of decimal places. That number of decimal places was to support the lowest clock speed of 0.032768 MHz

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

Kevin,

I get this error when I try to run under XP. Works great on another machine with Windows2000.

Quote:
This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.

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

I have XP (home edition? not the pro one) and not problems with the calculator.

Embedded Dreams
One day, knowledge will replace money.

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

Same here: WinXP-home: no problems

Nard

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tessa and Tina, 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

Thanks for the report, Dave. I'm finishing up a number of new features for the next release. Would you mind testing some prelease versions (and maybe a few other tests) on your XP system to assist in discovering what is causing the .exe problems on some Windows systems?

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

Sure thing.

Dave

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

Thanks, Dave. I'll send you PM when the next release is ready for initial testing.

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

Hi Kevin

Found the source code, whether this is any help.
http://www.home.unix-ag.org/tjabo/avr/dlg_02/src_coder.php
http://www.home.unix-ag.org/tjabo/avr/dlg_02/dlg_02.tgz

Quote:
Source of 'dlg02_coder.php'
The central code of my AVR delay loop generators.
License: GPL. Yes. Use it. :-)
Some functions are very ugly, especially burn_level_2. I think I'll reinvent that wheel...

Have phun, tk.

  // Author: Tjabo Kloppenburg (tjabo at  unix-ag.org)
  // Date: 08.Dez2002
  // Version: 0.0.1 (without level 3)

  // Disclaimer: The license of this file is the GPL, so use the
  //             code and spread it.
  // If you find bugs or have a better idea for LEVEL2, please send
  // me an email.

  // In this file you find the following core functions:
  

  // Nice output of AVR Code:
  /*
  function getNewLabel( $prefix="L" ) {
  function printCodeLine( $label="", $code="", $comment="" ) {
  function printCommentLine( $comment="" ) {
  */

  // helper functons:
  /*
  function byte2hex( $b ) {
  */

  // how many bytes does the start/end code take?
  // "burn" because of the heat generated when doing active delays...
  /*
  function num_start_code_cycles( $num ) {  // RCALL
  function burn_start_code( $num ) {
  function num_end_code_cycles( $num ) {    // RET
  function burn_end_code( $num ) {
  */


  // Level0: NOPs, Level1: 1 register, Level2: 2 rgisters:
  /*
  function burn_level_0( $num ) {

  function level_1_get_cycles( $startvalue ) {
  function burn_level_1( $num ) {

  function level_2_get_cycles( $A, $B ) {
  function burn_level_2( $num ) {
  */



  // time burn functions, generation of delay loops:

  function getNewLabel( $prefix="L" ) {
    global $LABEL_NUMBER;
    $LABEL_NUMBER += 1;
    $tmp = "" . $prefix . $LABEL_NUMBER;
    return $tmp;
  }


  function printCodeLine( $label="", $code="", $comment="" ) {
    $column1 = 10;
    $column2 = 15;

    $L1 = "";
    $L2 = "";
    $C1 = "";
    $C2 = "";

    $label = $label == "" ? " " : "$label:";

    while (strlen($label) < $column1) $label .= " ";
    while (strlen($code)  < $column2) $code  .= " ";

    $tmp  = "$L1$label$L2 $code";
    $tmp .= ($comment == "") ? "\n" : " $C1;$comment$C2\n";
    print $tmp;
  }


  function printCommentLine( $comment="" ) {
    $C1 = "";
    $C2 = "";
    $comment = $comment == "" ? "\n" : "$C1; $comment$C2\n";
    print $comment;
  }



  function num_start_code_cycles( $num ) {
    global $callmethod, $pcwidth;
    if ($callmethod == "rcall") {
      if (($pcwidth==16) && ($num >= 3))  {
        return 3;
      }
      if (($pcwidth==22) && ($num >= 4))  {
        return 4;
      }
    }
    return 0;
  }

  function burn_start_code( $num ) {
    global $callmethod, $pcwidth;
    $numcycles = num_start_code_cycles( $num );
    if ($callmethod == "rcall") {
      $n = getNewLabel();
      printCodeLine( $n, "", "RCALL $n ($numcycles cycles / $pcwidth Bit PC)" );
      return $numcycles;
    }
    return 0;
  }

  function byte2hex( $b ) {
    return sprintf("%02X", $b);
  }


  function num_end_code_cycles( $num ) {
    global $callmethod, $pcwidth;
    if ($callmethod == "rcall") {
      if ($pcwidth==16) {
        return 4;
      }
      elseif ($pcwidth==22) {
        return 5;
      }
      else {
        print "unknown pc width. in num_end_code_cycles()\n";
      }
    }
    return 0;
  }


  function burn_end_code( $num ) {
    global $callmethod, $pcwidth;

    $cycles_needed = num_end_code_cycles( $num );

    if ($cycles_need >= $num ) {
      if ($callmethod == "rcall") {
        printCodeLine( "", "ret", "return (" . $cycles_needed . " cycles, $pcwidth Bit PC)" );
        return $cycles_need;
      }
    }
    else {
      print "out of cylces, burn_end_code()\n";
      return 0;
    }
    return 0;
  }


  // -------------------------------------------------
  // -------------------------------------------------
  // Level 0 construction:
    /*
           nop  [nop...]
           ...
    */
  function burn_level_0( $num ) {
    printCodeLine( "", "", "$num NOPs:" );
    for ($i = 1; $i <= $num; $i++ ) {
      printCodeLine( "", "nop", "" );
    }
    return $num;
  }


  // -------------------------------------------------
  // -------------------------------------------------
  // Level 1 construction:
    /*
           ldi Rxx, $xx
       L0: dec Rxx
           brne L0
           ...
    */

  // -------------------------------------------------
  function level_1_get_cycles( $startvalue ) {
    if ($startvalue == 1) {
      return 3;
    }
    return ( 1 + (($startvalue - 1) * 3) + 2);
  }
  // -------------------------------------------------

  function burn_level_1( $num ) {
    global $registers;

    if (count($registers) == 0) {
      return 0;
    }

    if (($num >= 3) && ($num <= ( (254*3) + 255*2 ))) {

      // find start value for loop:
      $found = false;
      $test  = 256;
      while ((! $found ) && ($test >= 1)) {
        $can_do = level_1_get_cycles( $test );
        $found = ( $can_do <= $num );
        if (!$found) { $test -= 1; }
      }

      if ($found) {
        $val  = ($test == 256) ? 0 : $test;
        $val2 = byte2hex( $val );

        $Rxx = $registers[0];

        $n = getNewLabel();
        printCodeLine( "", "ldi $Rxx, \$$val2", " = $val (decimal)" );
        printCodeLine( $n, "dec $Rxx"         , ""                  );
        printCodeLine( "", "brne $Rxx, $n"    , "loop" );

        return round(level_1_get_cycles( $test ));
      }

    }
    return 0;
  }
  // -------------------------------------------------
  // -------------------------------------------------

  // Level 2 construction:
    /*
           ldi Rxx, $xx   1
       L0: ldi Ryy, $yy   1    ___
       L1: dec Ryy        1     |
           brne L1        2/1  _|_1 X
           dec Rxx        1
           brne L0        2/1
           ...
    */

  // -------------------------------------------------
  function level_2_get_cycles( $A, $B ) {
    // $A = $A == 0 ? 256 : $A;
    // $B = $B == 0 ? 256 : $B;

    // annahme: A  != 1 und B != 1:
    $X = (($A - 1)*(1+2)) + (1+1);
    $Y = 1 + (($B - 1)*(1+$X+1+2)) + (1+$X+1+1);

    return $Y;
  }
  // -------------------------------------------------


  function burn_level_2( $num ) {
    global $registers;

    $bestes_a = 1;
    $bestes_b = 1;
    $bestes_unter_diff = 50000;
    $found = false;

    for ($i = 1; $i <= 256; $i++) {
      $j = 1;
      $abbruchJ = false;
      while (($j <= 256) && (! $abbruchJ )) {
        $Y = level_2_get_cycles( $i, $j );
        if ($Y <= $num) {
          if (($num - $Y) < $bestes_unter_diff) {
            $bestes_a = $i;
            $bestes_b = $j;
            $bestes_unter_diff = $num - $Y;
            $found = true;
          }
        }
        else {
          $abbruchJ = true;
        }
        $j += 1;
      }
    }
    if ($found) {
      $gain = level_2_get_cycles( $bestes_a, $bestes_b );
      printCommentLine( "LEVEL 2 LOOP: gain=$gain");

      $val1  = ($bestes_a == 256) ? 0 : $bestes_a;
      $val2  = ($bestes_b == 256) ? 0 : $bestes_b;

      $val1h = byte2hex( $val1 );
      $val2h = byte2hex( $val2 );

      $Rxx = $registers[0];
      $Ryy = $registers[1];

      $n = getNewLabel();
      $m = getNewLabel();

      printCodeLine( "", "ldi $Rxx, \$$val1h", " \$$val1h = $val1 (decimal)" );
      printCodeLine( $n, "ldi $Ryy, \$$val2h", " \$$val2h = $val2 (decimal)" );
      printCodeLine( $m, "dec $Ryy", "" );
      printCodeLine( "", "brne $m" , "" );
      printCodeLine( "", "dec $Rxx", "" );
      printCodeLine( "", "brne $n" , "" );
      return $gain;
    }

    return 0;
  }

  // -------------------------------------------------
  // -------------------------------------------------

Ken

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

Hi Ken, thanks for looking for the file. I've already got a delay code generator written, but I appreciate your effort.