Does AS6 support external text editor?

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

Hi,

For some time now, I have been working on a makefile, which lets me compile an AVR32 program directly from the toolchain, without the bloated and bulky AS6. And I succeeded! Or so I thought.

When it came to interrupts, I failed. I never figured out how to add interrupts to an AVR32 program, and compile it solely through the toolchain. And others who have asked about this, have been told either some complicated stuff that I didn't understand, or "just accept that you have to use AS6/ASF".

So now I've capitulated. *sigh* But I still think that the AS6 text editor sucks bigtime. Is it possible to combine this with an external text editor? That is, either having AS6 activate a text editor, or remote control AS6 from the external text editor?

I remember when some unfortunate newbie asked why there was no IDE for the gnu compiler. He was nearly chastised for asking such a blasphemic question, and told in very clear language that such extravagance was completely unnecessary. And now we can't avoid the bloody thing. Sic transit gloria mundi.

Br, E

You're absolutely right. This member is stupid. Please help.

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

Hi!

I have really no experience with AVR32, but I'm just curious.
Have you seen this example on how to set up the UART to use interrupts:
http://support.atmel.no/knowledg...

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

I have never used AVR32.

You can use an external editor if you want. Just make sure that you "save all" before AS6.1 starts a Build. After all, AS6.1 will not know whether a file has changed unless it is under its own control.

I see no reason for interrupts to be under AS6 control. You just have to write the correct source code and use the correct 'build' comands in your Makefile.

Compare your "make -n" to an AS6 build. They should use identical command lines. I suspect that any trouble with interrupt vectors would be down to an incorrect Linker command.

David.

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

Quote:

I never figured out how to add interrupts to an AVR32 program, and compile it solely through the toolchain.

If you look at the example Heismann linked to then the only "tricks" to using interrupt seem to be giving a function the __attribute__((__interrupt__)), which presumably involves it ending with the AVR32 equivalent of RETI (and preserving important registers). Then you pass a function pointer for that routine to INTC_register_interrupt() along with the interrupt level to "hook" (AVR32_USART1_IRQ or whatever) and the interrupt priority (AVR32_INTC_INT0).

The following:

http://support.atmel.no/knowledg...

shows the implementation so it divides the interrupt number (AVR32_USART1_IRQ = ) by 32 to work out which "group" it is in then it an entry in a global table of function pointers to the routine address you provided and also sets the priority level into the right entry in the INTC.

I would have thought you could just duplicate that in your own code without the need for any library stuff like ASF. For pre-calculated interrupts you'll know which group it is in so you could hardwire the indices for the vector table and the INTC priority setting.

EDIT: having built an "empty" AVR32 app I see that _int_handler_table[] is not present by default (like an AVR8 vector table) so, to be honest, it's probably just easiest to add the whole of this file to your project:

http://support.atmel.no/knowledg...

EDIT2: Ah, I see, you'd also need this built into your project too:

http://support.atmel.no/knowledg...

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

Heisann: Now, THAT is interesting. I haven't found that one before. I'll definitely have a close look at that.

I've seen exception.S, intc.c and intc.h referenced before, but couldn't figure out where they were located. I think your link will help a lot.

David: Interrupts in AVR32 are nothing like interrupts in tiny, mega or xmega. In the latter, there are fixed interrupt vectors, and you make an ISR simply by typing

ISR(whatever_vector){
blah-blah
}

Interrupts in AVR32 have no fixed vectors, and are so complicated that I can't wholly understand out how they work.

Yeah, comparing my make with the AS6 build was part of how I got the build to work. Now with Heisann's help, I am more hopeful that I can take it the rest of the way.

If I get an AVR32 program with a timer and USART interrupt up and running, purely using the toolchain (and no AS6/ASF), I'll post an example somewhere on AVRfreaks.

Br, E

You're absolutely right. This member is stupid. Please help.

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

Quote:

Interrupts in AVR32 have no fixed vectors, and are so complicated that I can't wholly understand out how they work.

That's not what exception.S appears to show. It looks very "ARM like" (perhaps not a surprise as Atmel France who did UC3 also did the Atmel ARM chips).

However I guess it is true that while everything seem to be done as a fixed offset to _evba (event base address?) I don't see what actually locates EVBA itself. So perhaps there's also some "linker magic" involved in this that places the ".exception" section?

EDIT: yup when I load that INTC/USART example in AS6 and build it I find that the .map file has:

.exception      0x80002600      0x200
 .exception     0x80002600      0x200 src/ASF/avr32/drivers/intc/exception.o
                0x80002600                _evba
                0x80002704                _int0
                0x80002712                _int1
                0x80002720                _int2
                0x8000272e                _int3

So something has very deliberately put .exception at offset 0x2600 from 0x80000000. There's nothing in the project options that immediately springs out so I guess it's as a result of the link_uc3a0512.lds linker script that's being used. But, studying that, I don't immediately see the correlation. There is a section that says:

  .eh_frame_hdr : { *(.eh_frame_hdr) } >FLASH AT>FLASH :FLASH
  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) } >FLASH AT>FLASH :FLASH
  .gcc_except_table   : ONLY_IF_RO { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) } >FLASH AT>FLASH :FLASH
  .lalign	: { . = ALIGN(8); PROVIDE(_data_lma = .); } >FLASH AT>FLASH :FLASH
  . = ORIGIN(INTRAM);
  .dalign	: { . = ALIGN(8); PROVIDE(_data = .); } >INTRAM AT>INTRAM :INTRAM_ALIGN
  /* Exception handling  */
  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) } >INTRAM AT>FLASH :INTRAM_AT_FLASH
  .gcc_except_table   : ONLY_IF_RW { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) } >INTRAM AT>FLASH :INTRAM_AT_FLASH

In which "eh" clearly stands for "exception handling" but I don't see how this is directly responsible forthe placement of .exception as defined in exception.S?

(this is probably more about AVR32 that I ever planned to learn ;-))

EDIT2: Ah no, like you say, the exception table does not have to be at a specific address. Just at some place with a specific page alignment and then the address of that table is placed into the EVBA system register. So in the C run time I see:

  // Set up EVBA so interrupts can be enabled.
  lda.w   r0, _evba
  mtsr    AVR32_EVBA, r0
8000245c:	fe c0 fe 5c 	sub	r0,pc,-420

and that's what arranges for the _evba: defined in exception.S to be set as the EVBA address.

What's not clear to me is whether this is standard CRT or something that has to be added (otherwise how is _evba resolved if it is not defined?).

EDIT3: OK so i built an "empty" UC3 app and there's no mention of _evba in either the .map or the .lss. So I guess this means that when intc.c and exception.S are used there's a special CRT that does the EVBA setup?

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

Actually, I do a separate editor all the time.

I like the Mac TextWrangler. So, I put the file to be edited in DropBox. I have DropBox both on Mac side, and in Windows on VirtualBox (on the same machine). Updating between DropBox instances on the same machine is very fast.

AtmelStudio editor notes that the underlying file has changed and asks you if you want to update the Edit window. Going the other way, it just happens.

Jim

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

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

Seems like I've got the stuff to work now. Wasn't terribly difficult when I had that example – and all the "missing" files. But it is nowhere near as straight forward as with the 8-bit AVRs.

Actually, I think that calling this device an "AVR32" might be stretching the AVR term a bit. I have a hard time seeing any similarities between AVR and AVR32, apart from the "Atmel" logo.

Quote:
It looks very "ARM like" (perhaps not a surprise as Atmel France who did UC3 also did the Atmel ARM chips).
Well, that might explain it. Maybe it is just an ARM in disguise.

I find it strange that intc.c, intc.h, exception.S and the other files are not included in the toolchain, since they seem to be a necessity if people want to use interrupts. And I don't recall having written a program that doesn't use any interrupts at all.

Thanks a lot for your help, people. I don't know why, but I never seem to find those example projects when I need them. Must be searching in the wrong places.

Now all that's left is some USART stuff, and a bootloader. If those things work out, I guess I'm ready to use AVR32 in some of our future products. But frankly, I'd rather have an XMEGA with built-in CAN controller.

Br, E

You're absolutely right. This member is stupid. Please help.