mega328 includes?

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

I can't seem to find either m328def.inc or m328pdef.inc in the default directories. Does anyone know what or where they are located? I tried a few GitHub .inc's but the chip will not compile in either v1 or 2 of AS4.18, 19.

Yes in assembler.

 

A few errors are:

can't use //, have to use ; (33) : error : Garbage at end of line There are 50 or so of these one after the other... And there is no garbage or hidden junk on any line.

 

(47) : error : Illegal device name  .device ATmega328  The device name specified in the .inc..

  Any ideas?

 

 

 

 

Attachment(s): 

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

How are you searching? I'd just start a command prompt at \Program Files\Atmel then "dir m328def.inc /s"

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

You haven't given us much to go on.  If you cut out the offending area, do the reports go away?  Usually it is a bit prior to the report that is the problem.

 

How do you get this far without a chip-include file?  What are "the default directories"?

 

Post a complete small test program that demonstrates the symptoms.

 

Why such an old toolchain?  Was your offending chip model even released at that point?  Your toolchain probably has no files for a Tiny1634, either.  [I was quickly able to find many examples with a Google search]

 

 

 

 

 

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

I assumed it would be in the usual default location like all the others at: C:\Atmel\AVR Tools\AvrAssembler\Appnotes

Am I in error?

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

I like what works and I am used to it doing what I need. Also because v7 is bloatware on at least 2 computers that I run it on. All requiring a reboot.

What I am doing is comparing a bit toggle in C vs asm. So putting aside the missing files for now, in your honest opinions, what would be faster C or asm. I can simulate and demonstrate on a tiny2313 that the asm is faster writing 1 to PINx. For 20MHz in asm, I get a maxF of 2.5MHz.

 

.include    "m328pdef.inc"

.def    Temp     =    R16
.cseg             

.org 0x0000        ; Start Vector:

    rjmp    Reset  ; Reset Vector:

;----------------------------------------------------------------------
Reset:

    ldi     Temp,   Low(RAMEND)
    out     SPL,    Temp    ; Init Stack Pointer

    ldi     Temp,   High(RAMEND)
    out     SPH,    Temp    ; Init Stack Pointer

    ldi     Temp,   0xFF      ; set port D bits to outputs
    out     PORTD,  Temp
    out     DDRB,   Temp

   

toggle:

    sbi     PINB, 0

    rjmp,   Toggle

 

Why such an old toolchain?  Was your offending chip model even released at that point? 

 

 

Last Edited: Mon. Oct 8, 2018 - 04:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You don't need to assume. Cliff shows you the command line to find it.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

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

I'm old, slow and easily distracted. Please cut me some slack.

The only place I find the include files is in AS v7. I should have looked there I guess. I do a whole drive search whilst I do other things with Superfinder XT as Windows search is useless.

 

Now any ideas on toggle speed?

 

Thanks for the replies.

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

I just looked in my old AS4 assembler projects and all I have at the top of my source ASM is:

.include "m328Pdef.inc"

AS4 does the rest to find it.

 

It in this location:

C:\Program Files (x86)\Atmel\Atmel Toolchain\AVR Assembler\Native\2.1.1175\avrassembler\include

 

Jim on the East Side.

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

Sparky85 wrote:
The only place I find the include files is in AS v7.

Then use the copy you have!  As mentioned, the datas of your Studio4 and the release of support for the '328 are so close then indeed it may naot have been part of Studio at that point.

theusch wrote:
Your toolchain probably has no files for a Tiny1634, either.
Sparky85 wrote:
Now any ideas on toggle speed?

 

What I am doing is comparing a bit toggle in C vs asm.

Not really.  Or you at least have not given us enough information.  You have given us an assembly language fragment.  You state 2.5MHz (I assume the offending pin) with a 20MHz AVR clock.  Pretty much makes sense, 2 cycles for the SBI and 2 cycles for the RJMP.  Pin changes state every 4 cycles.

 

But compare to C is disingenuous at best.  I'll rephrase:  "With a particular toolchain with C-language support for an AVR target, and configured in a particular manner, then I get [unspecified] results."  So give  the associated test program, tell toolchain/version/settings, tell results, show generated code fragment.  To say "C can't do it as fast" is pretty ridiculous.

 

What is your objective for this snipe hunt?  A timer with CTC can do clk/2.  CKOUT can do clk/1.  Is there a practical application?  I can't think of anything similar in any of my production apps over the years.

 

 

 

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

In AS7 you dont use .include anyway. You set the yargwt device in the project.

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

theusch wrote:
What is your objective for this snipe hunt?

Indeed the AVR "toggle by writing to PINx" is a bit tricky.  Refer to the extensive " |= Considered Harmful" thread -- the C compiler bends the rules when turning |= into SBI.  But I digress...

 

"Show me the money offending C fragment and the conditions", as I requested.  A straightforward result with my toolchain

 

                 ;0000 0036 while (1)
                 _0x3:
                 ;0000 0037       {
                 ;0000 0038       PINB = (1<<0);
00007f e0e1      	LDI  R30,LOW(1)
000080 bbe6      	OUT  0x16,R30
                 ;0000 0039       }
000081 cffd      	RJMP _0x3
                 ;0000 003A }

4 cycles, the same as your "faster" ASM.  So wtf?  But with this fragment by itself, the LDI is superfluous as it never changes.  So use a register variable and what ho -- a 3 cycle solution, so now C is faster than your ASM:

                 ;0000 0036 scratch = 1;
00007f e011      	LDI  R17,LOW(1)
                 ;0000 0037 while (1)
                 _0x3:
                 ;0000 0038       {
                 ;0000 0039       PINB = scratch;
000080 bb16      	OUT  0x16,R17
                 ;0000 003A       }
000081 cffe      	RJMP _0x3
                 ;0000 003B }

My C can be coerced to reproduce your results, if you so choose to ignore " |= Considered Harmful":

;0000 0037 while (1)
                 _0x3:
                 ;0000 0038       {
                 ;0000 0039       PINB |= (1<<0);
000080 9ab0      	SBI  0x16,0
                 ;0000 003A       }
000081 cffe      	RJMP _0x3

Most quiche-eating users of the infinite-value toolchain would write it that way anyway.

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.

Last Edited: Mon. Oct 8, 2018 - 06:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@Sparky85 wrote:

I assumed it would be in the usual default location like all the others at: C:\Atmel\AVR Tools\AvrAssembler\Appnotes

How did you determine this was a "default?"

 

My system has a clean AS 7 installation (i.e. there were no previous versions installed when I installed AS 7).  When I do as Cliff suggested I get the following:

 

C:\Program Files (x86)\Atmel>dir m328def.inc /s
 Volume in drive C is OS
 Volume Serial Number is 74E6-C140

 Directory of C:\Program Files (x86)\Atmel\Studio\7.0\packs\atmel\ATmega_DFP\1.2.209\avrasm\inc

06/18/2018  03:41 AM            34,985 m328def.inc
               1 File(s)         34,985 bytes

 Directory of C:\Program Files (x86)\Atmel\Studio\7.0\packs\atmel\ATmega_DFP\1.2.272\avrasm\inc

09/14/2018  04:18 PM            34,985 m328def.inc
               1 File(s)         34,985 bytes

     Total Files Listed:
               2 File(s)         69,970 bytes
               0 Dir(s)  357,419,712,512 bytes free

C:\Program Files (x86)\Atmel>

 

Are your device packs up-to-date?

 

Greg Muth

Portland, OR, US

Xplained/Pro/Mini Boards mostly

 

Make Xmega Great Again!

 

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

Greg_Muth wrote:
Are your device packs up-to-date?
OP is working with a toolchain nearly 10 years old, and the "missing" file was released about that time.  OP won't use current, because of "bloat".  Surely "device packs" are part of that bloat?

 

But I don't expect responses, anyway.  When I take the time and effort to investigate off-the-cuff claims of "ASM better [faster in this case?] than C", or the corollary "you can't do this in C" with counter-examples or even direct refutation the airwaves become strangely quiet and the only thing left behind is the unfounded claim for future punters to take out of context as "evidence".

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

In AS7 you dont use .include anyway.

I do, otherwise there is no way of turning off the pages of listing for the include which is otherwise useless in the list file. wink

 

So delete the AS7 include file in Project> Properties> Toolchain> General

 

The add the include file and everything else that doesn't need to be listed.

;* Uses Atmel Xmega32E5 controller
;**********************************************************
.nolist
.include "Xmega_definition.asm"
.include "ATxmega32E5def.inc"
.include "ASCII_table.asm"
.include "utility_macros.inc"
.list

.include "ATDM-E5_defines.asm"

 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

So you have an extra comma in the code posted above

 

 

removing the comma the code assembles correctly

 

 

and something is wrong with adding photos with copy and paste, it adds 2 copies!

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

js wrote:
So delete the AS7 include file ...

OP isn't using AS7.  OP is using AS4. 

theusch wrote:
OP is working with a toolchain nearly 10 years old, and the "missing" file was released about that time. OP won't use current, because of "bloat". Surely "device packs" are part of that bloat?

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

And to answer the original question I had to fire up my old computer that I think has been thoroughly messed by my Microsoft and apart from being incredibly slow, can't even run Firefox now angry

 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

js wrote:
And to answer the original question...

You might read the question as "where is that file".  But in high probability the answer is "nowhere" as OP's toolchain predates the release of the files in question [probably some time in early 2010].

 

But:

-- OP doesn't want to use a later toolchain.

-- OP apparently doesn't want to use a file from a later toolchain (which is installed on two machines)

-- OP apparently doesn't want to follow any of the hits that Google gives for copies residing about on the 'Net

-- OP has no response to request for more information to support the "C is not as fast as ASM" in toggling an I/O pin

-- OP has no response to demonstration that a C solution can match or be faster than the "reference" ASM solution

-- OP hasn't said what the final objective is for this exercise

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

The above snapshot is for AS4.18 SP3 on my XP machine, so the file SHOULD be there. If it is not then just need to put it there for Studio to find it without the full path name.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

OP asked for the location of the include file(s) in AS4

I would think post #8 answered that

OP has gone silent though

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

js wrote:
The above snapshot is for AS4.18 SP3 on my XP machine, so the file SHOULD be there

It is indeed where you say it is on your machine.  Note the date stamp and speculate that the version was probably about when you installed it.  But I'll again repeat:  OP's version of Studio4 is not as recent as your snapshot sho OP probably does NOT have said files.  And OP does not want to do any toolchain update.  Please, y'all, re-read the thread.

 

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

Jim I don't think that the original assembler (V1) did support the Mega328. On my computers, 2 of them with XP, it jumps from M325 to Mega329

 

 

so sparky85 (is that his age? Good on him! wink) needs to use assembler V2 for Mega328 support.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

speculate that the version was probably about when you installed it.

It's exactly the same on my old laptop 9 Feb 2011 and looking at the file itself

 

;***** THIS IS A MACHINE GENERATED FILE - DO NOT EDIT ********************
;***** Created: 2011-02-09 12:03 ******* Source: ATmega328.xml ***********
;*************************************************************************
;* A P P L I C A T I O N   N O T E   F O R   T H E   A V R   F A M I L Y
;*
;* Number            : AVR000
;* File Name         : "m328def.inc"
;* Title             : Register/Bit Definitions for the ATmega328
;* Date              : 2011-02-09
;* Version           : 2.35
;* Support E-mail    : avr@atmel.com
;* Target MCU        : ATmega328

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

js wrote:
needs to use assembler V2 for Mega328 support.

No, if OP insists on using a toolchain of that vintage, then simply find an appropriate include file from wherever.

 

But I give up -- y'all must know better.

 

 

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

Now any ideas on toggle speed?

 

There was a pretty extensive discussion on the Arduino forum some years ago.  http://forum.arduino.cc/index.php?topic=4324.0

Basically, you can expect the C compiler to produce the same minimal instruction sequences you would write in assembly language.

 

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

Sorry, my absence was due to nap time. It happens in the late afternoon now. no

 

I thank you for all your replies.

I didn't expect so much interaction to my question, but, here we are.

The application is not so much is C or assembly "better" than the other, (I don't care either way) but just an exercise in "I haven't checked in to that".

 

No further "intervention" is necessary" but welcome if you wish to.

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

OK, so I spend my time addressing your posed question with requests for clarification.  None are forthcoming.  No comments on the solutions I presented.  Yet you indeed said

I can simulate and demonstrate on a tiny2313 that the asm is faster writing 1 to PINx.

But now you say

Sparky85 wrote:
The application is not so much is C or assembly "better" than the other, (I don't care either way)

 

 

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

Sparky85 wrote:
No further "intervention" is necessary" but welcome if you wish to.

 

It's hard to intervene when one is not exactly sure what the issue is.

 

Your OP mentions V1 and V2 of the assembler, and mentions both AS4.18 and 4.19.  My reply in post 8 with the path to the include was for 4.19, JS says something otherwise.  JS is the assembler/assembly freak around here so I generally don't argue with him.  THats what we have Lee for wink

 

Now Lee on teh other hand is looking at the thread with a different set of eyes.

 

So I ask you to review the whole thread of replies and sort of 'set us straight' as to what the issue is, and what you are trying to achieve using the old toolset(which worked fine) in lieu of just biting the bullet like the rest of us and upgrade to at least AS6_2.

 

Jim

 

Edit:

I see Lee pinged before I did.

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

Last Edited: Mon. Oct 8, 2018 - 11:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I generally don't argue with him.  Thats what we have Lee for

But my broadbeans seem to better than his broadbeans..... devil

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

I was of a thinking that my posts were of a nuisance to the forum. Not of, I have my answer and bugger all to the rest.

I will post results if anyone actually interested with the various AVR's and fastest clock speeds with the resultant Fmax. that I have collected since the dawn of time (90S1200) to the latest I had.

And if not, well thanks for the replies.

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

Sparky85 wrote:
I was of a thinking that my posts were of a nuisance to the forum

 

Not at all.  We love a good debate!

 

Sparky85 wrote:
And if not, well thanks for the replies.

THats it?  Well...ok.  Thanks for checking is LOL

 

Be well

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

I was of a thinking that my posts were of a nuisance to the forum.

Nah.  We're all good for an ASM vs C debate...

 

Although, if you insist on comparing asm from AS4.x to a C compiler of the same age, we may be a bit ... harsh.

(this is actually one of the advantages of ASM.  Your C code is liable to be different when compiled with a different compiler.  Perhaps suddenly too big, or too slow, or not working at all.  Whereas one has more faith that the ASM will always produce the same binary...)