Do you have a question? Post it now! No Registration Necessary
Subject
- Posted on
Newbie AVR-gcc - function weirdness
- 01-17-2006
- Thomas Ruschival
January 17, 2006, 11:33 pm

Hi Group
I am a Student of Electronic engineering and new to program my
own Atmega128 microcontroller, and I started with basic tests to verify the
hardware is correct, it is indeed. For now I am checking the results with
an oscilloscope to eliminate probable hardware bugs.
Here is the weird problem:
if I call a function in my code it doesn't do anything
in following code I expect to get a rectangle signal on PORTD
and a static bitpattern representing the number 17 on PORTC
but none happens, if I comment out the function call I get the rectangle
on PORTD with the funtion call I get nothing.....
I am desperate as I don't understand what is going on......
this is the compile command
avr-gcc test.c -Wall -mmcu=atmega128 -o test.o ;
Here is the simple but not working code:
#include <avr/io.h>
#include <inttypes.h>
void test2(uint8_t c);
int main(){
DDRD = 0xFF;
DDRC = 0xFF;
PORTC = 0xFF; // init port
// wait a bit
asm volatile("nop\n\t"
"nop\n\t"
"nop\n\t"
::);
// test2(17); // uncomment this line and it stops working!!
while (1){
PORTD = 0x00; // init port
// wait a bit
asm volatile("nop\n\t"
"nop\n\t"
"nop\n\t"
::);
PORTD = 0xFF;
// wait a bit
asm volatile("nop\n\t"
"nop\n\t"
"nop\n\t"
::);
}
return 0;
}
void test2(uint8_t c){
PORTC = c;
}
Site Timeline
- » pic -> sed1530 lcd asm code?
- — Next thread in » Microcontroller Discussions
-
- » Motorola 68Hc08 programming help
- — Previous thread in » Microcontroller Discussions
-
- » iPhone SUPER 80% discounts
- — Newest thread in » Microcontroller Discussions
-
- » PCA9957 defektes SPI
- — The site's Newest Thread. Posted in » Electronics (German)
-
- » cheap solder smoke filter or overkill?
- — The site's Last Updated Thread. Posted in » Electronics Repair
-