NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Support Forum » Source Codes For Learning Purposes Wanted
August 05, 2009 by Nerdful_com |
I am a newbie to microcontrollers, but looked around at many AVR programming kits before I went with a NerdKit. I am hoping to find source codes to other AVR firmwares (like Audrino clones) that will work with a NerdKit or be ported/hacked to work? I learn new languages best with many source code sample projects that perform simple tasks. I have found about a dozen actual source codes on Nerdkits.com forums and videos (c files) that I can get to work from my brand new NerdKit, but I would like to have even more codes to learn from. There should be tons of codes as this technology has been around for a bit... I know that each AVR system has different bootloader/firmware, which I assume are like mini operating systems. I am hoping that it is as simple as say getting codes from an Audrino developer and changing some command names/calls. I hope that there is a hack for using Audrino clone codes as there seems to be hundreds of snippets online to give me hints to learn from. I do know that I can just burn a clone bootlaoder to any new atmega chip, but I want to stick with NerdKit as I can understand what's going on with the actual components I add (I do not want a board all soldered together, I want hands on, like LEGO for geeks). www.nerdful.com |
---|---|
August 05, 2009 by Nerdful_com |
Ok, I notice that the NerdKit atmel chip has firmware with directories like include <avr/io.h>include <avr/interrupt.h>include <avr/sleep.h>include <avr/signal.h>include "../libnerdkits/delay.h"include "../libnerdkits/lcd.h"include "../libnerdkits/uart.h"Obviously libnerdkits is up a directory and has been added by NerdKit team with special "drivers" (or something) for parts that come with the kit. I am assuming that the main AVR directory is standard on all similar atmel chips. QUESTIONS: If I was to find other AVR programmer souce codes that only had includes for AVR directory only could I use them with NerdKit? Like is there a PURE AVR language that would work on any AVR programming kit no matter of the firmware? Do all similar atmel chips have similar root h files in avr directories? I assume anything a kit sellor adds to firmware goes up a directory and leaves the avr directory alone. What are all the h files in the libnerdkits directory? What are all the h files in the AVR directory? What are all the h files in the root directory? PORTING HINTS I JUST FOUND: Arduino to AVR byte = uint8_t Serial.begin(<baud>) = uart_init(<baud>) Serial.print*() = printf() Serial.available() = getchar() pinMode(pin, INPUT) = DDRx &= ~_BV(bit); pinMode(pin, OUTPUT) = DDRx |= _BV(bit); digitalWrite(pin, LOW) = PORTx &= ~_BV(bit); digitalWrite(pin, HIGH) = PORTx |= _BV(bit); digitalRead(pin) = (PINx & _BV(bit)) >> bit; delay(ms) = _delay_ms(ms) delayMicroseconds(us) = _delay_us(us) From http://metalab.at/wiki/Arduino/Arduino2AVR |
August 07, 2009 by Nerdful_com |
I was told to forget a firmware/bootloader, just to use an Mega128 ISP programmer (or get a mega128 developer board with ISP, header, reset switch and other goodies built in) to dump your code on and it should just work. This I have to research more before I can confirm or test. I am not sure even where to find source codes that will work without any custom firmwares and what scripting language to use. When asking these questions I was reffered to site http://tom-itx.dyndns.org:81/~webpage/ by a member of IRC chat channel #AVR on irc.freenode.net, so I guess i have some reading to do tonight. QUESTION: I notice that when programming in C that there are include files, 3 types in fact as you can see below. include <stdio.h> include <avr/io.h> include "../libnerdkits/uart.h" Can any of these be included in the same directory you build your c file to make? Are some of these include files on the actual MCU? I do not find any directory called libnerdkits on my PC, but in the WinARV install, I see io.h and similar, do these get included from WinAVR and added to the chip or are these files supposed to be on the chip first? |
August 07, 2009 by Nerdful_com |
Can I program with AVR Studio (or use source codes) and get it to work on NerdKit? Or does NerdKit firmware disable usage? |
August 07, 2009 by hevans (NerdKits Staff) |
Hi Nerdful_com, We prefer to use a bootloader instead of an ISP programmer because it allows you to program your chip through the serial port. This not only makes it more inexpensive (no ISP programmer to buy), but it also allows you to communicate with the chip over the same cable that you program the chip with. In the end, both ways of doing it get the program onto the chip so it doesn't really matter. The libnerdkits directory holds some utility functions that we wrote to make it easier to get up and running. There is a libnerdkits directory in the Code folder, on the same level as all the rest of the projects. The difference between using "" and <> to do includes just changes whether the compiler bothers to look in the current directory for the file to include or not, check out a good quick explanation in this using includes explanation There is nothing that we do that should prevent you from using AVR Studio, it should probably be a matter of fiddling with the settings and selecting the right Makefile. I do warn you though, there is a big benefit to beginners in doing it the old command line way. The command line is quick and simple and doesn't abstract away anything. If you like AVR Studio as an IDE I recommend typing your source code using AVR Studio, and then switching to the command line to make and upload. Hope this helps. Humberto |
August 07, 2009 by Nerdful_com |
I am getting it now I think. Here is a tested simpler project that helps me to understand controlling a basic item like motor (on/off, not speed), led light, piezo, etc, on and off every timed amount on pin 25 of the MCU (positive goes to rail and grnd goes to pin). I also wanted to do it without files from libnerdit My code:
|
August 07, 2009 by Nerdful_com |
When I first got this kit about 60 hours ago, I thought I was only stuck using the files in libnerdkit which would limit the source codes and samples I could find on the internet, but thankfully I am not limited to only what NerdKits makes on the bootloader or with the include files. I was also falsely believing that these include files were on the MCU itself (but now realize these files are on my PC when I do the make command to compile). I guess I was assuming it was like PC where you can have different operating systems and I was thinking that NerdKit was like some new unknown linux release but I was expecting Windows or something like that. |
Please log in to post a reply.
Did you know that a motor's no-load current at a given voltage is much less than it's resistance would suggest? Learn more...
|