Atmel AVR AT90S8515-4 Uživatelský manuál Strana 11

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 17
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 10
AN INTRODUCTION INTENDED FOR PEOPLE WITH NO PRIOR AVR KNOWLEDGE - AVRFREAKS.NET
10
In the output view (at the bottom left of the screen) you should get the following
output indicating that the Project compiled correctly without any errors! From this
output window, we can also see that our program consists of 6 words of code (12
bytes).
Congratulations!! You have now successfully written your first AVR program,
and we will now take a closer look at what it does!
Note: If your program does not compile, check your assembly file for typing
errors.If you have placed the include files (8515def.inc) in a different folder than
the default, you may have to enter the complete path to the file in the .include
"c:\complete path\8515def.inc" statement.
When it compiles we will continue explaining and then debugging the code.
Understanding the Source Code
OK so the code compiled without errors. That's great, but let us take a moment to
see what this program does, and maybe get a feeling how we should simulate the
code to verify that it actually performs the way we intended. This is the complete
source code:
Sample Code
;My Very First AVR Project
.include "8515def.inc" ;Includes the 8515 definitions file
.def Temp = R16 ;Gives "Defines" Register R16 the name Temp
.org 0x0000 ;Places the following code from address 0x0000
rjmp RESET ;Take a Relative Jump to the RESET Label
RESET: ;Reset Label
ldi Temp, 0xFF ;Store 255 in R16 (Since we have defined R16 = Temp)
out DDRB, Temp ;Store this value in The PORTB Data direction Register
Loop: ;Loop Label
out PORTB, Temp ;Write all highs (255 decimal) to PORTB
dec Temp ;Decrement R16 (Temp)
rjmp Loop ;Take a relative jump to the Loop label
Now let's take a line-by-line look at what's going on in this code.
Zobrazit stránku 10
1 2 ... 6 7 8 9 10 11 12 13 14 15 16 17

Komentáře k této Příručce

Žádné komentáře