Subversion Repositories svnkaklik

Compare Revisions

No changes between revisions

Ignore whitespace Rev 133 → Rev 134

/programy/Atmel_C/Blik/Makefile
0,0 → 1,62
# makefile, written by guido socher
MCU=atmega8
#MCU=at90s4433
CC=avr-gcc
OBJCOPY=avr-objcopy
# optimize for size:
CFLAGS=-g -mmcu=$(MCU) -Wall -Wstrict-prototypes -Os -mcall-prologues
#-------------------
all: avrm8ledtest.hex
#-------------------
help:
@echo "Usage: make all|load|load_pre|rdfuses|wrfuse1mhz|wrfuse4mhz|wrfusecrystal"
@echo "Warning: you will not be able to undo wrfusecrystal unless you connect an"
@echo " external crystal! uC is dead after wrfusecrystal if you do not"
@echo " have an external crystal."
#-------------------
avrm8ledtest.hex : avrm8ledtest.out
$(OBJCOPY) -R .eeprom -O ihex avrm8ledtest.out avrm8ledtest.hex
avrm8ledtest.out : avrm8ledtest.o
$(CC) $(CFLAGS) -o avrm8ledtest.out -Wl,-Map,avrm8ledtest.map avrm8ledtest.o
avrm8ledtest.o : avrm8ledtest.c
$(CC) $(CFLAGS) -Os -c avrm8ledtest.c
#------------------
load: avrm8ledtest.hex
./prg_load_uc avrm8ledtest.hex
# here is a pre-compiled version in case you have trouble with
# your development environment
load_pre: avrm8ledtest_pre.hex
./prg_load_uc avrm8ledtest.hex
#
loaduisp: avrm8ledtest.hex
./prg_load_uc -u avrm8ledtest.hex
# here is a pre-compiled version in case you have trouble with
# your development environment
load_preuisp: avrm8ledtest_pre.hex
./prg_load_uc -u avrm8ledtest.hex
#-------------------
# fuse byte settings:
# Atmel AVR ATmega8
# Fuse Low Byte = 0xe1 (1MHz internal), 0xe3 (4MHz internal), 0xe4 (8MHz internal)
# Fuse High Byte = 0xd9
# Factory default is 0xe1 for low byte and 0xd9 for high byte
# Check this with make rdfuses
rdfuses:
./prg_fusebit_uc -r
# use internal RC oscillator 1 Mhz
wrfuse1mhz:
./prg_fusebit_uc -w 1
# use internal RC oscillator 4 Mhz
wrfuse4mhz:
./prg_fusebit_uc -w 4
# use external 3-8 Mhz crystal
# Warning: you can not reset this to intenal unless you connect a crystal!!
wrfusecrystal:
@echo "Warning: The external crystal setting can not be changed back without a working crystal"
@echo " You have 3 seconds to abort this with crtl-c"
@sleep 3
./prg_fusebit_uc -w 0
#-------------------
clean:
rm -f *.o *.map *.out *t.hex
#-------------------
/programy/Atmel_C/Blik/README.txt
0,0 → 1,63
AVR GCC development environment test software.
See the following article for details:
http://main.linuxfocus.org/English/November2004/article352.shtml
 
To compile type the command:
make
 
Note: You will get some warnings "#warning "This header file is obsolete."
during compilation with avr-libc-1.4.X. This is because this code will
also work with avr-libc-1.2.X
 
Alternative 1: Programming with uisp (dapa programmer):
-------------------------------------------------------
Make sure that you have loaded the following modules in the kernel (for 2.4.x)
before you use the uisp programmer:
> /sbin/lsmod
Module Size Used by
parport_pc 17808 0
ppdev 5312 0 (unused)
parport 25856 0 [parport_pc ppdev]
 
 
To compile and load use:
make loaduisp
 
Alternative 2: Programming with avrusb500 (high speed usb programmer from tuxgraphics):
---------------------------------------------------------------------------------------
Make sure that you have loaded the following modules in the kernel
before you use the uisp programmer:
> /sbin/lsmod
Module Size Used by
ftdi_sio 20568 0
usbcore 57792 1 [ftdi_sio usbserial]
 
 
To compile and load use:
make load
 
Files:
------
avrm8ledtest.c # the c source code for ATmega8
avrm8ledtest_pre.hex # pre-compiled loadable object in case you have
# trouble to compile the software
Makefile # Makefile
README.txt # this file
circuit.gif # schematic as gif image
 
-------------------------------------------
History:
version 0.1: 2004-10-01, first Version
version 0.2: 2004-12-30, corrected fault in delay_ms function
version 0.3: 2005-10-04, new modular programming with the scripts prg_load_uc
and prg_fusebit_uc for easy transition to the new
avrusb500 programmer
version 0.4: 2006-03-02, compiler independent delay loop. The old delay_ms
would behave totally different with the new gcc-4
version.
version 0.5: 2006-03-10, Fault in delay_ms corrected
-------------------------------------------
Copyright: GPL
Written by guido socher <guido at tuxgraphics.org>
-------------------------------------------
 
/programy/Atmel_C/Blik/avrm8ledtest.c
0,0 → 1,76
/*********************************************
* vim: set sw=8 ts=8 si :
* Author: Guido Socher, Copyright: GPL
* This program is to test the led connected to
* PC5.
* See http://linuxfocus.org/English/November2004/
* for details.
* Chip type : ATMEGA8
* Clock frequency : Internal clock 1 Mhz (factory default)
*********************************************/
#include <avr/io.h>
#include <inttypes.h>
#define F_CPU 1000000UL // 1 MHz
#include <avr/delay.h>
 
 
/* compatibilty macros for old style */
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
 
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
 
 
void delay_ms(unsigned int ms)
/* delay for a minimum of <ms> */
{
// we use a calibrated macro. This is more
// accurate and not so much compiler dependent
// as self made code.
while(ms){
_delay_ms(0.96);
ms--;
}
}
 
 
/* new style */
int main(void)
{
/* INITIALIZE */
/* enable PC5 as output */
DDRC|= (1<<DDC5);
 
/* PC5 is 5 (see file include/avr/iom8.h) and 1<<PC5 is 00100000
* This can also be written as _BV(PC5)*/
while (1) {
/* led on, pin=0 */
PORTC &= ~(1<<PC5);
delay_ms(500);
/* set output to 5V, LED off */
PORTC|= (1<<PC5);
delay_ms(500);
}
return(0);
}
 
 
// // old style now depricated:
// int main(void)
// {
// // enable PC5 as output
// sbi(DDRC,PC5);
// while (1) {
// // led on, pin=0
// cbi(PORTC,PC5);
// delay_ms(500);
// // set output to 5V, LED off
// sbi(PORTC,PC5);
// delay_ms(500);
// }
// return(0);
// }
// // end of old style
/programy/Atmel_C/Blik/avrm8ledtest.hex
0,0 → 1,11
:1000000012C02BC02AC029C028C027C026C025C0C6
:1000100024C023C022C021C020C01FC01EC01DC0DC
:100020001CC01BC01AC011241FBECFE5D4E0DEBF28
:10003000CDBF10E0A0E6B0E0E2E9F0E002C005903C
:100040000D92A036B107D9F710E0A0E6B0E001C0EC
:100050001D92A036B107E1F70EC0D2CF9C01E0EFB0
:10006000F0E005C0CF010197F1F721503040211594
:100070003105C1F70895CFE5D4E0DEBFCDBFA59A25
:10008000AD9884EF91E0EADFAD9A84EF91E0E6DF8E
:02009000F7CFA8
:00000001FF
/programy/Atmel_C/Blik/avrm8ledtest.map
0,0 → 1,274
Archive member included because of file (symbol)
 
/usr/lib/gcc/avr/4.1.0/avr4/libgcc.a(_copy_data.o)
avrm8ledtest.o (__do_copy_data)
/usr/lib/gcc/avr/4.1.0/avr4/libgcc.a(_clear_bss.o)
avrm8ledtest.o (__do_clear_bss)
 
Memory Configuration
 
Name Origin Length Attributes
text 0x00000000 0x00002000 xr
data 0x00800060 0x0000ffa0 rw !x
eeprom 0x00810000 0x00010000 rw !x
*default* 0x00000000 0xffffffff
 
Linker script and memory map
 
LOAD /usr/lib/gcc/avr/4.1.0/../../../../avr/lib/avr4/crtm8.o
LOAD avrm8ledtest.o
LOAD /usr/lib/gcc/avr/4.1.0/avr4/libgcc.a
LOAD /usr/lib/gcc/avr/4.1.0/../../../../avr/lib/avr4/libc.a
LOAD /usr/lib/gcc/avr/4.1.0/avr4/libgcc.a
 
.hash
*(.hash)
 
.dynsym
*(.dynsym)
 
.dynstr
*(.dynstr)
 
.gnu.version
*(.gnu.version)
 
.gnu.version_d
*(.gnu.version_d)
 
.gnu.version_r
*(.gnu.version_r)
 
.rel.init
*(.rel.init)
 
.rela.init
*(.rela.init)
 
.rel.text
*(.rel.text)
*(.rel.text.*)
*(.rel.gnu.linkonce.t*)
 
.rela.text
*(.rela.text)
*(.rela.text.*)
*(.rela.gnu.linkonce.t*)
 
.rel.fini
*(.rel.fini)
 
.rela.fini
*(.rela.fini)
 
.rel.rodata
*(.rel.rodata)
*(.rel.rodata.*)
*(.rel.gnu.linkonce.r*)
 
.rela.rodata
*(.rela.rodata)
*(.rela.rodata.*)
*(.rela.gnu.linkonce.r*)
 
.rel.data
*(.rel.data)
*(.rel.data.*)
*(.rel.gnu.linkonce.d*)
 
.rela.data
*(.rela.data)
*(.rela.data.*)
*(.rela.gnu.linkonce.d*)
 
.rel.ctors
*(.rel.ctors)
 
.rela.ctors
*(.rela.ctors)
 
.rel.dtors
*(.rel.dtors)
 
.rela.dtors
*(.rela.dtors)
 
.rel.got
*(.rel.got)
 
.rela.got
*(.rela.got)
 
.rel.bss
*(.rel.bss)
 
.rela.bss
*(.rela.bss)
 
.rel.plt
*(.rel.plt)
 
.rela.plt
*(.rela.plt)
 
.text 0x00000000 0x92
*(.vectors)
.vectors 0x00000000 0x26 /usr/lib/gcc/avr/4.1.0/../../../../avr/lib/avr4/crtm8.o
0x00000000 __vectors
0x00000000 __vector_default
0x00000026 __ctors_start = .
*(.ctors)
0x00000026 __ctors_end = .
0x00000026 __dtors_start = .
*(.dtors)
0x00000026 __dtors_end = .
*(.progmem.gcc*)
*(.progmem*)
0x00000026 . = ALIGN (0x2)
*(.init0)
*(.init1)
*(.init2)
.init2 0x00000026 0xc /usr/lib/gcc/avr/4.1.0/../../../../avr/lib/avr4/crtm8.o
*(.init3)
*(.init4)
.init4 0x00000032 0x16 /usr/lib/gcc/avr/4.1.0/avr4/libgcc.a(_copy_data.o)
0x00000032 __do_copy_data
.init4 0x00000048 0x10 /usr/lib/gcc/avr/4.1.0/avr4/libgcc.a(_clear_bss.o)
0x00000048 __do_clear_bss
*(.init5)
*(.init6)
*(.init7)
*(.init8)
*(.init9)
.init9 0x00000058 0x2 /usr/lib/gcc/avr/4.1.0/../../../../avr/lib/avr4/crtm8.o
*(.text)
.text 0x0000005a 0x2 /usr/lib/gcc/avr/4.1.0/../../../../avr/lib/avr4/crtm8.o
0x0000005a __vector_1
0x0000005a __vector_12
0x0000005a __bad_interrupt
0x0000005a __vector_6
0x0000005a __vector_3
0x0000005a __vector_11
0x0000005a __vector_13
0x0000005a __vector_17
0x0000005a __vector_7
0x0000005a __vector_5
0x0000005a __vector_4
0x0000005a __vector_9
0x0000005a __vector_2
0x0000005a __vector_15
0x0000005a __vector_8
0x0000005a __vector_14
0x0000005a __vector_10
0x0000005a __vector_16
0x0000005a __vector_18
.text 0x0000005c 0x36 avrm8ledtest.o
0x00000076 main
0x0000005c delay_ms
0x00000092 . = ALIGN (0x2)
*(.text.*)
0x00000092 . = ALIGN (0x2)
*(.fini9)
*(.fini8)
*(.fini7)
*(.fini6)
*(.fini5)
*(.fini4)
*(.fini3)
*(.fini2)
*(.fini1)
*(.fini0)
0x00000092 _etext = .
 
.data 0x00800060 0x0 load address 0x00000092
0x00800060 PROVIDE (__data_start, .)
*(.data)
*(.gnu.linkonce.d*)
0x00800060 . = ALIGN (0x2)
0x00800060 _edata = .
0x00800060 PROVIDE (__data_end, .)
 
.bss 0x00800060 0x0
0x00800060 PROVIDE (__bss_start, .)
*(.bss)
*(COMMON)
0x00800060 PROVIDE (__bss_end, .)
0x00000092 __data_load_start = LOADADDR (.data)
0x00000092 __data_load_end = (__data_load_start + SIZEOF (.data))
 
.noinit 0x00800060 0x0
0x00800060 PROVIDE (__noinit_start, .)
*(.noinit*)
0x00800060 PROVIDE (__noinit_end, .)
0x00800060 _end = .
0x00800060 PROVIDE (__heap_start, .)
 
.eeprom 0x00810000 0x0
*(.eeprom*)
0x00810000 __eeprom_end = .
 
.stab 0x00000000 0x738
*(.stab)
.stab 0x00000000 0x36c /usr/lib/gcc/avr/4.1.0/../../../../avr/lib/avr4/crtm8.o
.stab 0x0000036c 0x3cc avrm8ledtest.o
0x3d8 (size before relaxing)
 
.stabstr 0x00000000 0x763
*(.stabstr)
.stabstr 0x00000000 0x763 /usr/lib/gcc/avr/4.1.0/../../../../avr/lib/avr4/crtm8.o
 
.stab.excl
*(.stab.excl)
 
.stab.exclstr
*(.stab.exclstr)
 
.stab.index
*(.stab.index)
 
.stab.indexstr
*(.stab.indexstr)
 
.comment
*(.comment)
 
.debug
*(.debug)
 
.line
*(.line)
 
.debug_srcinfo
*(.debug_srcinfo)
 
.debug_sfnames
*(.debug_sfnames)
 
.debug_aranges
*(.debug_aranges)
 
.debug_pubnames
*(.debug_pubnames)
 
.debug_info
*(.debug_info)
*(.gnu.linkonce.wi.*)
 
.debug_abbrev
*(.debug_abbrev)
 
.debug_line
*(.debug_line)
 
.debug_frame
*(.debug_frame)
 
.debug_str
*(.debug_str)
 
.debug_loc
*(.debug_loc)
 
.debug_macinfo
*(.debug_macinfo)
OUTPUT(avrm8ledtest.out elf32-avr)
/programy/Atmel_C/Blik/avrm8ledtest.out
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:executable
+*
\ No newline at end of property
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programy/Atmel_C/Blik/avrm8ledtest_pre.hex
0,0 → 1,11
:1000000012C02BC02AC029C028C027C026C025C0C6
:1000100024C023C022C021C020C01FC01EC01DC0DC
:100020001CC01BC01AC011241FBECFE5D4E0DEBF28
:10003000CDBF10E0A0E6B0E0E6E9F0E002C0059038
:100040000D92A036B107D9F710E0A0E6B0E001C0EC
:100050001D92A036B107E1F710C0D2CFAC0120E06D
:1000600030E0E0EFF0E005C0CF010197F1F72F5F3E
:100070003F4F24173507C1F70895CFE5D4E0DEBF21
:10008000CDBFA59AAD9884EF91E0E8DFAD9A84EFFB
:0600900091E0E4DFF7CF70
:00000001FF
/programy/Atmel_C/Blik/prg_fusebit_uc
0,0 → 1,97
#!/bin/sh
prg="adude"
#
help()
{
echo "prg_fusebit_uc -- read and write fuse bits of the atmega8"
echo ""
echo "Usage: prg_fusebit_uc [-hu] -r|-w Freq"
echo ""
echo "OPTIONS: -h this help"
echo " -r read fuse bytes"
echo " -u use uisp instead of avrdude"
echo " avrdude can automatically detect dapa or avrusb500."
echo " uisp can only be used with the parallel port dapa."
echo " -w write fuse bytes such that a given Freq is used"
echo " a frequency of 0 means external crystal. Possible"
echo " values are 0,1,2,4,8"
echo ""
echo "EXAMPLE: program the fuses to 4MHz internal"
echo " prg_fusebit_uc -w 4"
echo ""
echo "Warning: you can not undo the setting \"external crystal\" unless"
echo " you have a crystal that works."
echo "This script can be easily adapted to different programmer types"
exit 0
}
while [ -n "$1" ]; do
case $1 in
-h) help;shift 1;;
-u) prg="uisp";shift 1;;
-r) opt_r="1";shift 1;;
-w) opt_w="1";freq="$2";shift 2;;
-*) echo "error: no such option $1. -h for help";exit 1;;
*) break;;
esac
done
 
if [ -z "$opt_r" -a -z "$opt_w" ];then
# one of those options is mandatory
help
fi
 
hf=0xd9
if [ "$opt_w" = "1" ]; then
case $freq in
0) lf=0xee;echo "Make sure you have a crystal otherwise you can not change this!";sleep 2;;
1) lf=0xe1;;
2) lf=0xe2;;
4) lf=0xe3;;
8) lf=0xe4;;
*) echo "error: no such frequency, -h for help";exit 1;;
esac
fi
 
 
if [ "$prg" = "uisp" ]; then
if [ "$opt_r" = "1" ];then
set -x
uisp -dlpt=/dev/parport0 -dprog=dapa --rd_fuses
set +x
echo "Explanation: Fuse Low Byte: 0xe1 (1MHz intern), 0xe3 (4MHz intern), "
echo " 0xe4 (8MHz intern)"
echo " Fuse High Byte should be 0xd9"
exit 0
fi
if [ "$opt_w" = "1" ]; then
set -x
uisp -dlpt=/dev/parport0 -dprog=dapa --wr_fuse_l=$lf
uisp -dlpt=/dev/parport0 -dprog=dapa --wr_fuse_h=$hf
set +x
exit 0
fi
 
fi
if [ "$prg" = "adude" ]; then
if grep "Vendor=0403 ProdID=6001" /proc/bus/usb/devices > /dev/null ; then
prg="avrusb500"
else
prg="dapa"
fi
if [ "$opt_r" = "1" ];then
set -x
avrdude -p m8 -c $prg -v -q
set +x
echo "Explanation: Fuse Low Byte: 0xe1 (1MHz intern), 0xe3 (4MHz intern), "
echo " 0xe4 (8MHz intern)"
echo " Fuse High Byte should be 0xd9"
exit 0
fi
if [ "$opt_w" = "1" ]; then
set -x
avrdude -p m8 -c $prg -u -v -U lfuse:w:$lf:m
avrdude -p m8 -c $prg -u -v -U hfuse:w:$hf:m
set +x
exit 0
fi
fi
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/programy/Atmel_C/Blik/prg_load_uc
0,0 → 1,38
#!/bin/sh
prg="adude"
if [ "$1" = "-u" ]; then
shift;
prg="uisp"
fi
if [ -z "$1" -o "$1" = "-h" -o "$1" = "--help" ]; then
echo "prg_load_uc -- load a .hex file into a atmega8 microcontroller"
echo ""
echo "Usage: prg_load_uc [-hu] File.hex"
echo ""
echo "OPTIONS: -h this help"
echo " -u use uisp instead of avrdude"
echo " avrdude can automatically detect dapa or avrusb500."
echo " uisp can only be used with the parallel port dapa."
echo ""
echo "This script can be easily adapted to different programmer types"
exit 0
fi
pfile="$1"
 
if [ "$prg" = "uisp" ]; then
set -x
uisp -dlpt=/dev/parport0 --erase -dprog=dapa
uisp -dlpt=/dev/parport0 --upload if="$pfile" -dprog=dapa -v=3 --hash=32 --verify
set +x
fi
if [ "$prg" = "adude" ]; then
if grep "Vendor=0403 ProdID=6001" /proc/bus/usb/devices > /dev/null ; then
set -x
avrdude -p m8 -c avrusb500 -e -U flash:w:"$pfile"
set +x
else
set -x
avrdude -p m8 -c dapa -e -U flash:w:"$pfile"
set +x
fi
fi
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/programy/Atmel_C/Blik/prg_read_uc
0,0 → 1,38
#!/bin/sh
prg="adude"
if [ "$1" = "-u" ]; then
shift;
prg="uisp"
fi
if [ -z "$1" -o "$1" = "-h" -o "$1" = "--help" ]; then
echo "prg_read_uc -- read the flahs of an atmega8 microcontroller"
echo ""
echo "Usage: prg_load_uc [-hu] File.hex"
echo ""
echo "OPTIONS: -h this help"
echo " -u use uisp instead of avrdude"
echo " avrdude can automatically detect dapa or avrusb500."
echo " uisp can only be used with the parallel port dapa."
echo ""
echo "This script can be easily adapted to different programmer types"
exit 0
fi
pfile="$1"
 
if [ "$prg" = "uisp" ]; then
set -x
#uisp -dlpt=/dev/parport0 --erase -dprog=dapa
#uisp -dlpt=/dev/parport0 --upload if="$pfile" -dprog=dapa -v=3 --hash=32 --verify
set +x
fi
if [ "$prg" = "adude" ]; then
if grep "Vendor=0403 ProdID=6001" /proc/bus/usb/devices > /dev/null ; then
set -x
avrdude -v -v -p m8 -c avrusb500 -U flash:r:"$pfile:i"
set +x
else
set -x
avrdude -p m8 -c dapa -U flash:r:"$pfile:i"
set +x
fi
fi
Property changes:
Added: svn:executable
+*
\ No newline at end of property