Each Prayog board is shipped with a demo program loaded onto it. Just open the box and plug in the power supply. You can use any DC power supply adapter with output range of 7-12V DC to provide power supply to Prayog board. As you plug in the DC power adapter to Prayog, RED Led named POWER should glow at full intensity. It indicates Prayog is getting proper 5V DC voltage for its operation.
The demo program loaded onto Prayog should blink the on board GREEN Led (LED1) at an interval of 1 seconds. This is your first check to see if everything is OK.
Now, you can write your first program using any AVR Programming environment like avr-gcc, AVR Studio, WinAVR, CodeVision AVR, IAR Workbench etc. We recommend use of WinAVR for windows users and avr-gcc for GNU/Linux users. A Tutorial on familiarizing with WinAVR is here, you can learn using AVR Programming on GNU/Linux machine using this tutorial.
Whatever IDE / Compiler / Programmer you are using, the underlying programming method remains almost same (avr-gcc programming method is the standard used by us and most of the people, CodeVision programming syntax is a little bit different still, you can start with any of them and this tutorial is beneficial for both of them)
As given earlier in the Getting started tutorial Prayog board has 2 On Board LEDs. They are connected to PORTD_0 (GREEN LED) and PORTD_1 (RED LED). First program can be to play with these two LEDs. I will show you, how ?
In 8 bit AVRs PORTS can be handled using a set of 3 Registers. The three Registers are PORTx , PINx, and DDRx where 'x' is PORT value something like A,B,C,Dā¦
/* Prayog #1 - Hello World Program Blinking LEDs connected to PORTD_0 and PORTD_1 Compiler: WinAVR (avr-gcc) */ #include <avr/io.h> // Defines the basic AVR Registers #include <util/delay.h> // Including Library for precise delay generation int main(void) { DDRD = 0b00000011; // PORTD_0 and PORTD_1 as Output PORTD= 0b00000000; // Initially LEDs are Off while(1) { PORTD = 0b00000011; // LEDs are ON _delay_ms(1000); // Delay of a second PORTD = 0b00000000; // LEDs are Off _delay_ms(1000); } return 0; }
Save the Code file with some name say main.c, If you are using WinAVR its time to create a Makefile (WinAVR uses Makefile to perform a set of commands). Click here to see How to create a Makefile. Once you have saved Makefile into the same folder as your main.c code. Its time to compile the code and download the hex file onto the flash of Microcontroller on Prayog board. Check this page describing, How to use WinAVR to compile the C code and Program the flash.