CodeVision Tutorial
8 pages
Slovak
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
8 pages
Slovak
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres

Description

Contents  About this Tutorial .......................................................................................................................... 2 Important Information .................................................................................................................... 2 Create Codevision Project ............................................................................................................... 3 Include .H and .C files in CodeVision ............................................................................................... 6 Sample .H File .................................................................................................................................. 7 Sample .C File ... 8      SJVE   Page 1 of 8  About this Tutorial  This tutorial will guide you on how to create a project in CodeVision.  Furthermore, it explains how to burn the code onto an Atmega chip using STK500 board and program the microcontroller to output serial data that you can read to and from the microcontroller.  Finally, there is a section that explains how to setup header files in CodeVision Important Information  1. The clock on the STK500 kit is 3.686Mhz The clock on the PCB Kit is 16.000Mhz 2. Do not change the fuse bit settings in CodeVision unless you know what you are doing.  Changing fuse bit setting can disable the Atmega microcontroller   SJVE   ...

Informations

Publié par
Nombre de lectures 412
Langue Slovak

Extrait

Contents 
 
About this Tutorial .......................................................................................................................... 2 
Important Information .................................................................................................................... 2 
Create Codevision Project ............................................................................................................... 3 
Include .H and .C files in CodeVision ............................................................................................... 6 
Sample .H File .................................................................................................................................. 7 
Sample .C File ... 8 
 
 
   
SJVE   Page 1 of 8 
 About this Tutorial 
 
This tutorial will guide you on how to create a project in CodeVision.  Furthermore, it explains how to 
burn the code onto an Atmega chip using STK500 board and program the microcontroller to output 
serial data that you can read to and from the microcontroller.  Finally, there is a section that explains 
how to setup header files in CodeVision 
Important Information 
 
1. The clock on the STK500 kit is 3.686Mhz 
The clock on the PCB Kit is 16.000Mhz 
2. Do not change the fuse bit settings in CodeVision unless you know what you are doing.  
Changing fuse bit setting can disable the Atmega microcontroller 
  
SJVE   Page 2 of 8 
 Æ
Æ
Selecting the chip type lets you choose 
features of the chip.  You must select 
Create Codevision Project  the correct frequency of the Atmega 
  otherwise many functions like UART 
and delay function calls will not work as 
1. Open CodeVision 
intended 
2. Click File   New  
4. In the next figure, user can choose the 
settings for UART.  This will enable the 
use of printf and scanf statements.  
UART enables you to perform 
input/output functions for the Atmega 
microcontroller and it is also useful to 
debug code. 
 
3. After clicking Yes in the previous 
prompt, you can now use CodeVision to 
automatically generate template code 
for Atmega microcontroller. 
 
5. Select File   Generate, Save and Exit  
6. You can now name your project files 
and save them into a project folder. 
7. CodeVision will generate the code and 
now you can burn the code into the 
Atmega, but first, a few settings need to 
be changed. 
 
SJVE   Page 3 of 8 
 Æ
8. Click on Project   Configure and go to 
the C Compiler tab 
9. First, if you wish to display floating 
point numbers using printf(“%f”, 
myfloat); then you need to enable this 
feature.  Do not enable this feature 
unless required because it takes a lot of 
code memory space.  Under the 
(s)printf features, select float,width, 
precision if needed, otherwise leave it 
alone. 
 
Normally, you do not need to Verify the 
code so deslect Verify option.  Program 
Fuse Bit(s) is also not needed because 
this can change the way Atmega starts 
up using various clock options.  
Atmega’s come programmed to use 
external clock, which is exactly what the 
PCB kit and the STK500 uses so do not 
change this unless you know what you 
are doing. 
11. Click OK  
12. Scroll down towards the bottom of the 
 
code and observe that your entire code 
10. Now browse to After Make tab.  Check 
needs to be within the while(1) loop.  
the “Program the Chip” option and 
This is an infinite loop and the 
choose the options described by the 
microcontrollers must have one infinite 
next figure: 
loop otherwise they it execute code 
once and stop working.  Add the 
following code inside the while loop: 
“printf(“test\n”); 
delay_ms(100); 
Adding the delay is necessary otherwise 
the microcontroller outputs data so fast 
that the PC buffer will overflow for the 
incoming serial data and your computer 
may freeze while trying to read the data 
from the serial buffer chip. 
SJVE   Page 4 of 8 
 Æ
13. Go to the top of the code and add this  PD0/PD1 to RX/TX and connect serial 
ndstatement: “#include <delay.h>  cable to the 2  DB9 port. 
14. Go to Settings   Programmer and  21. You should now see the microcontroller 
ensure that the COM port you chose is  outputting data. 
indeed the COM port connected to 
  STK500 programming port (next to the 
DC power jack) 
15. Press Shift+F9 and then select Program 
the Chip option 
16. The code is ready and microcontroller is 
now printing printf statements, now 
you need to connect the serial cable to 
see the output. 
17. Download “Hercules Setup” by 
searching for it in google. 
18. Open up Hercules Setup and go to the 
Serial Tab.  Choose the COM port that is 
available.  This could be the same as the 
Programming COM port if you do not 
ndhave a 2  COM port in your computer.  
Choose the speed in bps, which must be 
the same as the one in step 4.  Click 
OPEN to open the COM port. 
 
19. Nothing should print at this point 
because you need to connect the serial 
cable to which the PCB kit of STk500 is 
outputting data to. 
20. For the PCB kit, read the manual and 
connect RX/TX and serial cable to the 
DB9 connector.  For STK500, connect 
SJVE   Page 5 of 8 
 Æ
Include .H and .C files in CodeVision 
 
Many times,

  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents