'Select chip and xtal frequency
#chip mega8, 4
'Define ports
#define LED1 PORTD.5
#define LED2 PORTD.6
'Set port directions
dir LED1 out
dir LED2 out
'Main code
'There are 2 LED's connected - let them blink alternating
Do
Set LED1 On
Set LED2 Off
Wait 500 ms
Set LED1 Off
Set LED2 On
Wait 500 ms
Loop
Compile it with Cowbasic in Linux.
(Using wine because of problems running native fbc).
This will run the same way in windows.
PC:/win/CowBasic$ wine gcbasic.exe blink.bas
err:winedevice:ServiceMain driver L"IOPort" failed to load
Great Cow BASIC (0.9 31/5/2012)
avrdude: Device signature = 0x1e9307
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "blink.hex"
avrdude: writing flash (118 bytes):
Example code for simple LED blinking
Compile it with Cowbasic in Linux.
(Using wine because of problems running native fbc).
This will run the same way in windows.
err:winedevice:ServiceMain driver L"IOPort" failed to load
Great Cow BASIC (0.9 31/5/2012)
Compiling blink.bas …
Done
Assembling with Gerd's AVR assembler.
http://www.avr-asm-tutorial.net/gavrasm/index_de.html
+----------------------------------------+
| gavrasm gerd's AVR assembler Version 3.2 (C)2012 by DG4FAC |
+----------------------------------------+
Kompiliere Quelldatei: blink.asm
Durchgang: 1
Zeile: 8
Warnung 009: Include-Datei nicht erforderlich, interne Symbole verwendet!
Datei: blink.asm, Zeile: 8
Quellzeile: .INCLUDE "m8def.inc"
Zeile: 78
k=2, i=1119
Zeile: 802, i=4
k=1, i=1119
137 Zeilen verarbeitet.
Pass 1 ok.
Durchgang: 2
Zeile: 8
Warnung 009: Include-Datei nicht erforderlich, interne Symbole verwendet!
Datei: blink.asm, Zeile: 8
Quellzeile: .INCLUDE "m8def.inc"
Zeile: 78
k=2, i=1119
Zeile: 802, i=4
k=1, i=1119
137 Zeilen verarbeitet.
Warnung 011: C-Stil in Assemblerdatei, Zeilen ignoriert!
Warnung 001: 1 Symbol(e) definiert, aber nicht benutzt!
58 Worte Code, 0 Worte Konstanten, Gesamt=58 = 1.4%
3 Warnungen!
Kompilation fertig, keine Fehler. Auf Wiederlesen …
Programming with avrdude using an USB programmer with fishl.de firmware.
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e9307
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "blink.hex"
avrdude: writing flash (118 bytes):
Writing | ################################################## | 100% 0.07s
avrdude: 118 bytes of flash written
avrdude: verifying flash memory against blink.hex:
avrdude: load data flash data from input file blink.hex:
avrdude: input file blink.hex contains 118 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.04s
avrdude: verifying …
avrdude: 118 bytes of flash verified
avrdude: safemode: Fuses OK
avrdude done. Thank you.