Hello,
Since I am quite experienced in ATmega, I am completely new to AVR32. I use AT32UC3B0256 microcontroller (at speed of 60MHz) -- more precisely, I have already ordered mkII programmer, evaluation board, a few microcontrollers and boards -- I will have those items in a few days.
I would like to write simple application in C using AVR32 Studio. This application should just blink a LED. I found (after much time of searching -- personally, I find available documentation not enough, not comprehensive; there is no simple examples, no tutorials) a piece of code shown below:
#include#include "gpio.h" int main( void ) { int i; while (1) { gpio_set_gpio_pin(AVR32_PIN_PA03); for (i = 0; i < 100; i++); gpio_clr_gpio_pin(AVR32_PIN_PA03); for (i = 0; i < 100; i++); } return 0; }
When I run the application in Debug mode (it throws some exception -- but it is not important now), I saw
that assembler code of gpio_set_gpio_pin(AVR32_PIN_PA03) is like this:
0x800000fc: pushm r7,lr 0x80000100 : mov r7,sp 0x80000102 : sub sp,8 0x80000104 : st.w r7[-8],r12 volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5]; 0x80000108 : ld.w r8,r7[-8] 0x8000010c : lsr r8,0x5 0x8000010e : lsl r8,0x8 0x80000110 : sub r8,61440 0x80000114 : st.w r7[-4],r8 gpio_port->ovrs = 1 << (pin & 0x1F); // Value to be driven on the I/O line: 1. 0x80000118 : ld.w r8,r7[-8] 0x8000011c : bfextu r9,r8,0x0,0x5 0x80000120 : mov r8,1 0x80000122 : lsl r8,r8,r9 0x80000126 : mov r9,r8 0x80000128 : ld.w r8,r7[-4] 0x8000012c : st.w r8[84],r9 gpio_port->oders = 1 << (pin & 0x1F); // The GPIO output driver is enabled for that pin. 0x80000130 : ld.w r8,r7[-8] 0x80000134 : bfextu r9,r8,0x0,0x5 0x80000138 : mov r8,1 0x8000013a : lsl r8,r8,r9 0x8000013e : mov r9,r8 0x80000140 : ld.w r8,r7[-4] 0x80000144 : st.w r8[68],r9 gpio_port->gpers = 1 << (pin & 0x1F); // The GPIO module controls that pin. 0x80000148 : ld.w r8,r7[-8] 0x8000014c : bfextu r9,r8,0x0,0x5 0x80000150 : mov r8,1 0x80000152 : lsl r8,r8,r9 0x80000156 : mov r9,r8 0x80000158 : ld.w r8,r7[-4] 0x8000015c : st.w r8[0x4],r9
It is a huge amount of code just to light a LED.
I would be glad, if somebody would show me faster (after compilation, as small amount of machine commands as possible) and elegant method in C to set or clear particular pin of AT32UC3B0256 microcontroller.
Probably I could do something myself (after hours or days of experimenting), but I wish some experienced AVR32 programmer to show me the best, the fastest and the most elegant (canonical) method in C to set or clear a pin state.
Thanks in advance for Your help.
I find your answer very useful not only to me, but to every unexperienced AVR32 programmer.
Regards,
CypressValley.