Problem with comparison.
/Modules/AVR/Text_Examples/DOC/SRC/img/Text_Examples_QRcode.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/Modules/AVR/Text_Examples/SW/TIMER_DEMO1/BIN/timer_demo1_atmega88.hex
0,0 → 1,15
:1000000019C028C027C026C025C024C023C022C0D4
:1000100021C020C01FC01FC01DC01CC01BC01AC0F3
:1000200019C018C017C016C015C014C013C012C024
:1000300011C010C011241FBECFEFD4E0DEBFCDBF72
:1000400011E0A0E0B1E001C01D92A230B107E1F7DC
:100050002CD03FC0D5CF1F920F920FB60F92112414
:100060008F939F9388B190E1892788B9809100018F
:1000700090910101CB9754F480910001909101017E
:100080000196909301018093000108C01092010134
:100090001092000188B190E2892788B99F918F91D1
:1000A0000F900FBE0F901F9018953C9A3D9A83E8D1
:1000B0009EE19093890080938800809181008C60FC
:1000C0008093810080916F00826080936F007894AC
:0600D000FFCFF894FFCF02
:00000001FF
/Modules/AVR/Text_Examples/SW/TIMER_DEMO1/Makefile
0,0 → 1,36
PROGRAM = timer_demo1
 
MCU = atmega88
 
CC = avr-gcc
OBJCOPY = avr-objcopy
CFLAGS += -Wall -g -Os -mmcu=$(MCU)
LDFLAGS +=
 
OBJS = $(PROGRAM).o
 
all: $(PROGRAM)_$(MCU).hex
 
$(PROGRAM)_$(MCU).elf: $(PROGRAM).o
@printf " LD $(subst $(shell pwd)/,,$(@))\n"
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
 
$(PROGRAM)_$(MCU).hex: $(PROGRAM)_$(MCU).elf
@printf " OBJCOPY $(subst $(shell pwd)/,,$(@))\n"
$(OBJCOPY) -O ihex $< $@
 
%.o: %.c
@printf " CC $(subst $(shell pwd)/,,$(@))\n"
$(CC) $(CFLAGS) -o $@ -c $<
 
flash: $(PROGRAM)_$(MCU).hex
@printf " FLASH $(PROGRAM)_$(MCU).hex\n"
avrdude -c stk500v1 -P usb -p m88 -U flash:w:$(PROGRAM)_$(MCU).hex
 
clean:
@printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
rm -f *.o
@printf " CLEAN $(PROGRAM).elf\n"
rm -f *.elf
@printf " CLEAN $(PROGRAM).hex\n"
rm -f *.hex
/Modules/AVR/Text_Examples/SW/TIMER_DEMO1/timer_demo1.c
0,0 → 1,103
// timer_demo1.c
// -------------
//
// Example file for ATmega88 (and similar AVR chips) demonstrating how to use
// timer interrupt just to blink by LED.
//
// The program uses TIMER1 to generate interrupts and the interrupt routine
// toogles the LED state. Connect LED to ground with apropriate serial resistor
// (value about 330 OHM).
//
// (c) miho 2014 http://www.mlab.cz
//
// History
// 2014 01 29 - First demo
 
 
// System Configuration
#define F_CPU 4000000 // Do not forget to set FUSEs to external XTAL osc with DIV/8 off and connect xtal
 
 
// LED Ports Configuration
#define LED_S_PORT C
#define LED_S_PIN 4
#define LED_M_PORT C
#define LED_M_PIN 5
 
 
// -------------- DO NOT EDIT BELOW THIS LINE --------------
 
 
// Library Headers
#include <avr/interrupt.h>
 
 
// Comaptibility ATmega8 / ATmega88
#ifndef TIMSK
#define TIMSK TIMSK1
#endif
 
 
// Macro for Port (enables to easily define IO signals)
#define GLUE(A,B) A##B
#define DDR(PORT_LETTER) GLUE(DDR, PORT_LETTER) // Makes DDRC from DDR(C)
#define PORT(PORT_LETTER) GLUE(PORT,PORT_LETTER) // Makes PORTC from PORT(C)
#define PIN(PORT_LETTER) GLUE(PIN, PORT_LETTER) // Makes PINC from PIN(C)
 
 
// Global Variable
volatile int Seconds;
 
// Interrupt Routine for TIMER1 Output Compare A
ISR(TIMER1_COMPA_vect)
{
// LED on/off
PORT(LED_S_PORT) ^= (1<<LED_S_PIN);
if (Seconds<59)
{
Seconds++;
}
else
{
Seconds=0;
// Toogle Minute LED
PORT(LED_M_PORT) ^= (1<<LED_M_PIN);
}
}
 
 
// Main
int main()
{
// Enable LED Output
DDR(LED_S_PORT) |= (1<<LED_S_PIN);
DDR(LED_M_PORT) |= (1<<LED_M_PIN);
 
// Set MAX value for Timer1
OCR1A = F_CPU/256/2-1; // 1/2s
 
// Set Timer1 to CTC with presacaller 1/256
// CTC Mmode counts from 0 to value stored in OCR1A
// and generates interrupt every time it goes back to 0
// CS12 CS11 CS10 Prescaller
// 0 0 1 clkI/O/1 (No prescaling)
// 0 1 0 clkI/O/8 (From prescaler)
// 0 1 1 clkI/O/64 (From prescaler)
// 1 0 0 clkI/O/256 (From prescaler)
// 1 0 1 clkI/O/1024 (From prescaler)
TCCR1B |= (1<<CS12) | (1<<WGM12);
 
// Enable Interrupt for Timer1 OCRA
TIMSK |= (1<<OCIE1A);
 
// Enable Global (CPU) Interrupt
sei();
 
// Main Loop
for(;;)
{
// Do any job here
}
 
return 0;
}
/Modules/AVR/Text_Examples/SW/TIMER_DEMO2/BIN/timer_demo2_atmega88.hex
0,0 → 1,36
:1000000019C033C032C031C030C02FC02EC02DC087
:100010002CC02BC02AC034C028C027C026C025C091
:1000200024C023C022C021C020C01FC01EC01DC0CC
:100030001CC01BC011241FBECFEFD4E0DEBFCDBF5C
:1000400011E0A0E0B1E0E2E1F2E002C005900D9223
:10005000AA30B107D9F711E0AAE0B1E001C01D92C2
:10006000A431B107E1F7BBD0D2C0CACF8A3010F0BB
:1000700080E00895E82FF0E0E050FF4F8081089580
:100080001F920F920FB60F9211242F938F939F936D
:10009000EF93FF9380910E0190910F010196909341
:1000A0000F0180930E0180910E0190910F01845FEA
:1000B000914008F44DC010920F0110920E018091F2
:1000C00012018F5F80931201809112018A3008F42F
:1000D0003FC01092120180910A018F5F80930A0144
:1000E00080910A018630A0F110920A0180911101DD
:1000F0008F5F80931101809111018A3048F1109235
:100100001101809113018F5F80931301809113017E
:100110008630F0F01092130180910B018F5F809375
:100120000B0180911001823041F480910B018430E9
:1001300020F010920B011092100180910B018A3077
:1001400038F010920B01809110018F5F80931001A5
:1001500080910C018F5F80930C0180910D01880FBD
:1001600080930D0180910C01843029F410920C01D0
:1001700081E080930D0180910C01813051F081303C
:1001800028F0823049F0833099F409C0E0911201DF
:1001900008C0E0910A0105C0E091110102C0E091A0
:1001A0001301EA3028F4F0E0E050FF4FE08101C095
:1001B000E0E088B1807F88B98BB1E095EBB998B168
:1001C00080910D018F70892B88B9FF91EF919F91DC
:1001D0008F912F910F900FBE0F901F9018958AB19D
:1001E0008FEF8AB987B18F6087B98CE790E09093E1
:1001F000890080938800809181008B6080938100CA
:1002000080916F00826080936F007894FFCFF894A4
:02021000FFCF1E
:0A0212003F036D6753767E237F776C
:00000001FF
/Modules/AVR/Text_Examples/SW/TIMER_DEMO2/Makefile
0,0 → 1,36
PROGRAM = timer_demo2
 
MCU = atmega88
 
CC = avr-gcc
OBJCOPY = avr-objcopy
CFLAGS += -Wall -g -Os -mmcu=$(MCU)
LDFLAGS +=
 
OBJS = $(PROGRAM).o
 
all: $(PROGRAM)_$(MCU).hex
 
$(PROGRAM)_$(MCU).elf: $(PROGRAM).o
@printf " LD $(subst $(shell pwd)/,,$(@))\n"
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
 
$(PROGRAM)_$(MCU).hex: $(PROGRAM)_$(MCU).elf
@printf " OBJCOPY $(subst $(shell pwd)/,,$(@))\n"
$(OBJCOPY) -O ihex $< $@
 
%.o: %.c
@printf " CC $(subst $(shell pwd)/,,$(@))\n"
$(CC) $(CFLAGS) -o $@ -c $<
 
flash: $(PROGRAM)_$(MCU).hex
@printf " FLASH $(PROGRAM)_$(MCU).hex\n"
avrdude -c stk500v1 -P usb -p m88 -U flash:w:$(PROGRAM)_$(MCU).hex
 
clean:
@printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
rm -f *.o
@printf " CLEAN $(PROGRAM).elf\n"
rm -f *.elf
@printf " CLEAN $(PROGRAM).hex\n"
rm -f *.hex
/Modules/AVR/Text_Examples/SW/TIMER_DEMO2/timer_demo2.c
0,0 → 1,209
// timer_demo2.c
// -------------
//
// Example file for ATmega88 (and similar AVR chips) demonstrating how to use
// timer interrupt to realize Clocks with LED display.
//
// The program uses TIMER1 to generate interrupts and the interrupt routine counts
// fragments of second, seconds, tens of seconds etc. In the same interrupt routine
// the display multiplex is done. We use 4 digit 7 segment display.
// Common anodas are connected to LED_DIGITS_PORT and segments are connected
// to LED_SEGMENTS_PORT (use serial rezistors here, cca 100 OHM).
//
// (c) miho 2014 http://www.mlab.cz
//
// History
// 2014 01 31 - First demo
 
 
// System Configuration
#define F_CPU 4000000 // Do not forget to set FUSEs to external XTAL osc with DIV/8 off and connect xtal
 
// LED Display - Configuration
#define LED_DIGITS_PORT C // Digits Port (common anodas)
#define LED_DIGITS 4 // Number of display digits (1..8)
#define LED_SEGMENTS_PORT D // Segments Port (catodas)
#define LED_SEGMENTS 8 // Usualy 7 or 8 (bit 0 is A)
#define TICKS_PER_SEC 500 // Number of interrupts per second ( >250 to look steady)
 
 
// -------------- DO NOT EDIT BELOW THIS LINE --------------
 
 
// LED Display - Internal Defs
#define LED_DIGITS_MASK ((1<<LED_DIGITS)-1) // For 4 digits 0x0F=0b00001111
#define LED_SEGMENTS_MASK ((1<<LED_SEGMENTS)-1) // For 7 segments 0x7F=0b01111111
 
 
// LED Display - Verify Configuration
#if (F_CPU / 64 % TICKS_PER_SEC)
#error "TICKS_PER_SEC" should be chosen so that "F_CPU / 64 / TICKS_PER_SEC" is a whole number!
#endif
#if ( (F_CPU / 64 / TICKS_PER_SEC) > 65536)
#error "TICKS_PER_SEC" should be chosen bigger (timer is long 16bit only)!
#endif
 
 
// Library Headers
#include <avr/interrupt.h>
 
 
// Compatibility ATmega8 / ATmega88
#ifndef TIMSK
#define TIMSK TIMSK1
#endif
 
 
// Macro for Port (enables to easily define IO signals)
#define GLUE(A,B) A##B
#define DDR(PORT_LETTER) GLUE(DDR, PORT_LETTER) // Makes DDRC from DDR(C) etc.
#define PORT(PORT_LETTER) GLUE(PORT,PORT_LETTER) // Makes PORTC from PORT(C)
#define PIN(PORT_LETTER) GLUE(PIN, PORT_LETTER) // Makes PINC from PIN(C)
 
 
// 7 Segment Decoder
unsigned char Convert(unsigned char Number)
{
// 7 Segment Decoder Table
const unsigned char Decoder[] =
{
// HGFEDCBA
0b00111111, // 0
0b00000011, // 1
0b01101101, // 2
0b01100111, // 3
0b01010011, // 4
0b01110110, // 5
0b01111110, // 6
0b00100011, // 7
0b01111111, // 8
0b01110111 // 9
};
 
// Decoding Function
if(Number<sizeof(Decoder)) return Decoder[Number]; else return 0;
}
 
 
// Global Variable - Time Counters
volatile unsigned int Fractions; // 1/100s
volatile unsigned char Seconds, Seconds10; // Seconds and tens of seconds
volatile unsigned char Minutes, Minutes10; // Minutes and tens of minutes
volatile unsigned char Hours, Hours10; // Hours and tens of hours
 
 
// Global Variable - Display Multiplex
volatile unsigned char DisplayDigit; // Multiplex state 0 1 2 3 (binary counter)
volatile unsigned char DisplayDigitMask; // Multiplex state 1 2 4 8 (mask 1 from N)
 
 
// Interrupt Routine for TIMER1 Output Compare A
// Activated 500 per second
ISR(TIMER1_COMPA_vect)
{
// Every 1/500s
Fractions++;
if (Fractions>(TICKS_PER_SEC-1))
{
// Every 1s
Fractions=0;
Seconds++;
if (Seconds>9)
{
// Every 10s
Seconds = 0;
Seconds10++;
if (Seconds10>5)
{
// Every 1m
Seconds10=0;
Minutes++;
if (Minutes>9)
{
// Every 10m
Minutes=0;
Minutes10++;
if (Minutes10>5)
{
// Every 1h
Minutes10=0;
Hours++;
if (Hours10==2 && Hours>3)
{
// Every Day
Hours=0;
Hours10=0;
}
if (Hours>9)
{
// At 10 and 20 hours
Hours=0;
Hours10++;
}
}
}
}
}
}
 
// LED display time multiplex - next digit
// 500x per second
DisplayDigit++;
DisplayDigitMask<<=1;
if (DisplayDigit == LED_DIGITS)
{
DisplayDigit = 0;
DisplayDigitMask = 1;
}
 
// Get Segment Combination for Current Digit
unsigned char Segments=0;
switch(DisplayDigit)
{
case 0: Segments = Convert(Seconds);
break;
case 1: Segments = Convert(Seconds10);
break;
case 2: Segments = Convert(Minutes);
break;
case 3: Segments = Convert(Minutes10);
}
 
// LED display update - All digits off
PORT(LED_DIGITS_PORT) &= ~LED_DIGITS_MASK; // common anoda 0=off
// LED display update - New segments combination
PORT(LED_SEGMENTS_PORT) = (PORT(LED_SEGMENTS_PORT) & ~LED_SEGMENTS_MASK) | (~Segments & LED_SEGMENTS_MASK);
// LED display update - One digit on
PORT(LED_DIGITS_PORT) |= (LED_DIGITS_MASK & DisplayDigitMask); // (common anoda 1=on)
}
 
 
// Main
int main()
{
// Enable LED Display Output
DDR(LED_SEGMENTS_PORT) |= LED_SEGMENTS_MASK; // 8 segments 0b11111111
DDR(LED_DIGITS_PORT) |= LED_DIGITS_MASK; // 4 digits 0b00001111
 
// Set MAX value for Timer1
OCR1A = (F_CPU+64/2)/64/TICKS_PER_SEC-1; // 1/500s
 
// Set Timer1 to CTC with presacaller 1/64
// CTC Mmode counts from 0 to value stored in OCR1A
// and generates interrupt every time it goes back to 0
TCCR1B |= (1<<CS11) | (1<<CS10) | (1<<WGM12);
 
// Enable Interrupt for Timer1 OCRA
TIMSK |= (1<<OCIE1A);
 
// Enable Global (CPU) Interrupt
sei();
 
// Main Loop
for(;;)
{
// Do any job here
}
 
return 0;
}
/Modules/AVR/Text_Examples/PrjInfo.txt
0,0 → 1,17
//
// Toto je popisný soubor pro popis obsahu adresáře (příklad)
//
 
[InfoShortDescription.en]
Simple example programs for AVR processors
[InfoShortDescription.cs]
Jednoduché ukázkové programy pro AVR procesory
[InfoLongDescription.en]
Simple Example programs to start with.
 
[InfoLongDescription.cs]
Jednoduché příklady programů pro AVR se kterými se může začít.
 
[End]