#include <avr/io.h>
int main()
{
DDRB = 0xFF;
while (1)
{
PORTB ^=0xFF;
}
}
So this is your file.c and you wana create the binary format of this file use this command:
avr-objcopy -I binary -O ihex file.c file.hex
so that you can see the output in the hexadecimal but it represents the binary values only.
see this for clear understanding:
:10 0000 00 23 69 6E 63 6C 75 64 65 20 3C 61 76 72 2F 69 6F 3D
# i n c l u d e ' ' < a v r / i o
:10 0010 00 2E 68 3E 0D 0A 0D 0A 69 6E 74 50 6D 61 69 6E 28 A6
. h > \r \n \r \n i n t ' ' m a i n (
:10 0020 00 76 6F 69 64 29 20 7B 0D 0A 09 44 44 52 42 20 3D C1
v o i d ) ' ' { \r \n \t D D R B ' ' =
:10 0030 00 20 30 78 46 46 3B 0D 0A 09 77 68 69 6C 65 20 28 B0
' ' 0 x F F ; \r \n \t w h i l e ' ' (
:10 0040 00 31 29 20 7B 0D 0A 09 09 50 4F 52 54 42 20 5E 3D 50
1 ) ' ' { \r \n \t \t P O R T B ' ' ^ =
:10 0050 00 30 78 46 46 3B 0D 0A 09 7D 0D 0A 7D 0D 0A EB
int main()
{
DDRB = 0xFF;
while (1)
{
PORTB ^=0xFF;
}
}
So this is your file.c and you wana create the binary format of this file use this command:
avr-objcopy -I binary -O ihex file.c file.hex
so that you can see the output in the hexadecimal but it represents the binary values only.
see this for clear understanding:
:10 0000 00 23 69 6E 63 6C 75 64 65 20 3C 61 76 72 2F 69 6F 3D
# i n c l u d e ' ' < a v r / i o
:10 0010 00 2E 68 3E 0D 0A 0D 0A 69 6E 74 50 6D 61 69 6E 28 A6
. h > \r \n \r \n i n t ' ' m a i n (
:10 0020 00 76 6F 69 64 29 20 7B 0D 0A 09 44 44 52 42 20 3D C1
v o i d ) ' ' { \r \n \t D D R B ' ' =
:10 0030 00 20 30 78 46 46 3B 0D 0A 09 77 68 69 6C 65 20 28 B0
' ' 0 x F F ; \r \n \t w h i l e ' ' (
:10 0040 00 31 29 20 7B 0D 0A 09 09 50 4F 52 54 42 20 5E 3D 50
1 ) ' ' { \r \n \t \t P O R T B ' ' ^ =
:10 0050 00 30 78 46 46 3B 0D 0A 09 7D 0D 0A 7D 0D 0A EB
No comments:
Post a Comment