| Author |
Message |
|
|
Posted: Nov 24, 2004 - 10:32 AM |
|

Joined: Dec 26, 2002
Posts: 158
Location: Belgium, Europe
|
|
Hi, Here's some newbie AVR-GCC example code...
[note this dates from 2004 and may be out of date - in particular the way the Makefile generates dependencies leads to .d files that include DOS pathnames (on Windows) which are not portable to Linux
The recommendation these days would be to always use the Mfile utility (part of WinAVR) to create any Makefile you use] |
_________________ Greatness isn't measured by achievement, but by persistence after failure.
|
| |
|
|
|
|
|
Posted: Dec 31, 2004 - 02:18 PM |
|


Joined: Sep 18, 2004
Posts: 643
Location: Brisbane, Australia
|
|
I also have some really, really small and basic functions for the absolute beginner here at http://www.users.on.net/~symes/CwithAVR/IntrotoCwithAVR.htm
Will update with more code soon. Updated again today 4/1/05. More to follow.
* 11/01/05 Updated with software I2C routine in AVR-GCC.
*10/2/2005 Updated site with new Mega32 page and an example hardware I2C (TWI) program. Fully commented and explained (I hope:) )
*22/9/05 Update. Added more to the Mega32 category (RTC routines for DS1307). More to come soon. |
_________________ Dingo_aus
http://www.users.on.net/~symes/
Last edited by Dingo_aus on Sep 22, 2005 - 12:42 PM; edited 3 times in total
|
| |
|
|
|
|
|
Posted: Jan 19, 2005 - 04:08 PM |
|

Joined: Dec 25, 2001
Posts: 9
|
|
| hey, dudes, fix the download link =) |
|
|
| |
|
|
|
|
|
Posted: Jan 30, 2005 - 01:57 AM |
|

Joined: Feb 19, 2003
Posts: 2233
Location: Seattle, WA
|
|
|
daggerr wrote:
hey, dudes, fix the download link =)
Just rename the linked file as a .zip file  |
|
|
| |
|
|
|
|
|
Posted: Feb 04, 2005 - 10:46 AM |
|

Joined: Feb 04, 2005
Posts: 14
|
|
Hey I am a newbie tryin to get the hang of serial programming. I am tryin to read the output of a temp sensor (thermistor), put it though an ADC of Port A and make that value appear on a pin of Port B. However with the code below the pin on port B only ouptuts 5V. Any advice or hints would be greatly appreciated.Please!!! Am using the atmega8515
#include <avr/io.h>
#include <avr/delay.h>
int main (void)
{
DDRB = 0xff; //sets all bits of port B for output
DDRA = 0xfe; //sets one bits of portA to be an input
while(1)
{
PORTB= PINA;
}
return 1;
} |
|
|
| |
|
|
|
|
|
Posted: Feb 15, 2005 - 07:04 PM |
|

Joined: Jul 18, 2004
Posts: 59
Location: South Africa
|
|
|
kkempeneers wrote:
Hi, Here's some newbie AVR-GCC example code...
Hi, just tought I would contribute back my changes to you example code. I found bugs in the interrupt driven uart example with the way you hande the queue head and tail. Specifically the way the number of entries in the queue is calculated. The calculation has to change when the tail is above the head (the head has wrapped but the tail not). I also think the way I handle wrapping of the pointers is safer.
A .zip file containing the changed uart.c and uart.h files is attached.
Johan Hartman |
|
|
| |
|
|
|
|
|
Posted: Feb 16, 2005 - 04:57 PM |
|

Joined: Mar 30, 2004
Posts: 97
Location: Hyderabad. India
|
|
Hello no_idea,
The problem could be because of the optimization in Makefile. Open the make file and check "opt = " line. If the line is opt = s replace 's' with '0' (zero). Now re-compile your code and check.
Regards |
_________________ Parthasaradhi Nayani
|
| |
|
|
|
|
|
Posted: Mar 07, 2005 - 08:12 PM |
|

Joined: Jul 18, 2004
Posts: 59
Location: South Africa
|
|
|
Johan Hartman wrote:
kkempeneers wrote:
Hi, Here's some newbie AVR-GCC example code...
Hi, just tought I would contribute back my changes to you example code. I found bugs in the interrupt driven uart example with the way you hande the queue head and tail. Specifically the way the number of entries in the queue is calculated. The calculation has to change when the tail is above the head (the head has wrapped but the tail not). I also think the way I handle wrapping of the pointers is safer.
A .zip file containing the changed uart.c and uart.h files is attached.
Johan Hartman
Please note in the above contributed code - I did not include the main.c file I was using. I enable / disable interrupts in the main.c file. So to make the code work properly for you, you will have to sei() either in the main.c file after calling first_init in uart.c - or put it at the end of first_init.
Johan Hartman |
|
|
| |
|
|
|
|
|
Posted: Mar 14, 2005 - 04:36 PM |
|

Joined: Dec 26, 2002
Posts: 158
Location: Belgium, Europe
|
|
Johan,
You created the bug yourself when you changed;
Code:
rbuf [r_in & RMASK] = c;
r_in++;
in to
Code:
rbuf [r_in] = c;
r_in++;
r_in &= RMASK;
Both code segments aren't equivalent... Think about it. Don't take this the wrong way i hessitated for long before posting this reply.
The bufferpointers must count up to 255 for the wrapping to work. Though i don't doubt your solution works, mine takes less flash.
KK
PS. Thanks for the effort, more people should follow your example! We haven't had any fdeviceopen () related questions since the sample code has become a sticky post. |
_________________ Greatness isn't measured by achievement, but by persistence after failure.
|
| |
|
|
|
|
|
Posted: Mar 28, 2005 - 10:13 AM |
|

Joined: Sep 01, 2004
Posts: 24
Location: UK, Essex
|
|
Hi.. can i ask if there is a newbie guide to how to actually compile C code and get it onto the chip?
I have a STK500 dev board and either an ATMega16 or an AT90S8515.
Cheers. |
|
|
| |
|
|
|
|
|
Posted: Mar 28, 2005 - 03:09 PM |
|

Joined: Nov 14, 2001
Posts: 3438
Location: Charlottesville, VA USA
|
|
|
|
|
|
|
Posted: May 28, 2005 - 04:20 AM |
|

Joined: Dec 30, 2004
Posts: 134
|
|
Here is a soft timer example in the academy:
ID: 358 |
|
|
| |
|
|
|
|
|
Posted: May 31, 2005 - 07:37 PM |
|

Joined: May 17, 2005
Posts: 165
|
|
|
kkempeneers wrote:
Hi, Here's some newbie AVR-GCC example code...
Hi, I have a little question, I compiled UART and UART-IntSIO from your examples with WinAvr,
but hex file is to big, it is about 14Kb, each.
I saw in makefile, that you use at90s8515, but it has (I think) 8Kb flash and it can't accept 14kb in flash, how can this works?
(PS. sorry for my bad english, I hope you will understand me ) |
|
|
| |
|
|
|
|
|
Posted: May 31, 2005 - 08:12 PM |
|

Joined: Dec 08, 2004
Posts: 4719
Location: Nova Scotia, Canada
|
|
The hex file is much larger than the size the code will occupy on the chip.
It expresses each byte of data with 2 ASCII characters. Typically, avr-gcc will store 16 data bytes per record (32 ASCII characters). Plus, you have 12 or 13 control characters (depending on your computer system's 'text mode') per record.
So, for example, 4 kB of compiled code could be split into 256 records, each containing 32 data characters and 12 control characters, adding up to a final Hex file size of approximately 11 kB.
(By the way: This is really an unrelated question, which is inappropriate to have attached to this 'sticky' announcement the way it is. Next time, you'd be better off posting questions like this in a separate thread rather than hijacking an existing one.) |
|
|
| |
|
|
|
|
|
Posted: May 31, 2005 - 09:10 PM |
|

Joined: May 17, 2005
Posts: 165
|
|
Thanks for your answer ,I'm novice and sorry for the inconvenience from next time i will take care of that  |
|
|
| |
|
|
|
|
|
Posted: Jul 03, 2005 - 12:03 PM |
|

Joined: Dec 26, 2002
Posts: 158
Location: Belgium, Europe
|
|
Not Newbie sample code but maybe someone would appriciate this; Adam Dunkel's µIP httpd (Webserver) sample application ported to AVR-GCC
Acknowledgements;
Adam Dunkels http://www.sics.se/~adam/uip/
Louis Beaudoin http://www.laskater.com/projects/uipAVR.htm
The tricky part is setting up the filesystem for the Harvard oriented AVR Target. The sample code runs on a M32 at 16MHz.
The server is nothing more nor less than the sample webserver at http://uip-demo.sics.se/
Enjoy,
KK |
_________________ Greatness isn't measured by achievement, but by persistence after failure.
|
| |
|
|
|
|
|
Posted: Aug 11, 2005 - 05:53 PM |
|

Joined: May 25, 2005
Posts: 1
|
|
|
SteveN wrote:
Hi,
Your question is kind of broad but maybe the below document will help somewhat (as far simulating code and getting it into your chip).
http://www.atmel.com/dyn/resources/prod ... novice.pdf
What have you looked at so far and where are you confused?
Regards,
Steve
Hi Steve et al,
Another newbie here. Thanks for the link, but I (and, I suspect, Srosam1) am having problems with getting the GCC compiler to work with Studio. Someone sent me a file called avrgcc_studio.pdf which was written in 2001 and is somewhat out of date.
When I try to compile files I get told:
The system cannot find the file specified.
Could Not Find c:\tmpout.txt
Do you have any suggestion for a more up-to-date Studio/GCC primer or a specific suggestion w.r.t. tmpout.txt?
Thanks!
Allison (outoftune24601) |
|
|
| |
|
|
|
|
|
Posted: Aug 11, 2005 - 06:49 PM |
|

Joined: Dec 08, 2004
Posts: 4719
Location: Nova Scotia, Canada
|
|
AVR Studio version 3 allowed you to invoke external compilers, such as avr-gcc, from within AVR Studio. You could use AVR Studio to create, edit, and compile your C files.
That is not currently possible in version 4 of AVR Studio.
Instead, you have to write and compile your programs separately. You can then use AVR Studio to debug/simulate, and to program your software onto an AVR.
Check the documentation section of WinAVR's webpage on sourceforge for a more recent primer on installing and configuring WinAVR (avr-gcc for Windows) as well as details on creating makefiles and compiling projects. |
|
|
| |
|
|
|
|
|
Posted: Sep 09, 2005 - 09:46 PM |
|

Joined: Sep 09, 2005
Posts: 2
|
|
[quote]i'm a newbie for programming avr...
firs of all sorry for my english (i'm from indonesia ;P)
i want to program my atmega8535 with stk500 like board and using codevisionAVR c compiler...
since i didn't find any book for programming the avr with c code so untill now i'm really confused...
does anyone could help me for giving any list of syntax c codes for avr?
of course i would really thank for the help and if you dont mind for giving me some examle code with lot's of comment....
thanks....  |
|
|
| |
|
|
|
|
|
Posted: Sep 10, 2005 - 04:20 PM |
|

Joined: Nov 14, 2001
Posts: 3438
Location: Charlottesville, VA USA
|
|
Hi,
I know this isn't specifically what you asked for but it is another option.
www.smileymicros.com
"C Programming for Microcontrollers"
Many people here have said this is a great book. (I hope so, I just ordered one myself .)
[edit] Sorry, I just noticed you mentioned Codevision. " Embedded C Programming and the Atmel AVR" by Barnett, Cox & O'Cull. This book is expensive but I have seen many people here say it is a great book also.
Regards,
Steve |
|
|
| |
|
|
|
|
|