201310071031


1.prj:

; ************************************************************
; PROJECT:
; AUTHOR:
; ************************************************************

; Micro + software running
; ------------------------------------------------------------
.MICRO "ATmega8"
.TOOLCHAIN "GCC" ;     Bug: 1. use GCC, compile with errors;
                 ;          2. use GENERIC
.GCCPATH   "C:\WinAVR"
.GCCMAKE   AUTO
.TARGET    "1.hex"
;.COFF     "1.cof"
;.BAT      "1.bat"   ; Optional build file
.SOURCE    "1.c"

.TRACE              ; Activate micro trace

; Following lines are optional; if not included
; exactly these values are taken by default
; ------------------------------------------------------------
.POWER VDD=5 VSS=0  ; Power nodes
.CLOCK 1meg         ; Micro clock
.STORE 250m         ; Trace (micro+signals) storage time

; Micro nodes: RESET, AREF, PB0-PB7, PC0-PC6, PD0-PD7, ACO,
;              TIM1OVF, ADC6, ADC7
; Define here the hardware around the micro
; ------------------------------------------------------------

D1 VDD n1
R1 n1 PB0 1k
D2 VDD n2
R2 n2 PB1 1k
D3 VDD n3
R3 n3 PB2 1k
D4 VDD n4
R4 n4 PB3 1k
D5 VDD n5
R5 n5 PB4 1k
D6 VDD n6
R6 n6 PB5 1k
D7 VDD n7
R7 n7 PB6 1k
D8 VDD n8
R8 n8 PB7 1k
.Plot V(PB0) V(n2) V(PB2) V(PB3) V(PB4) V(PB5) V(PB6) V(PB7)


1.c

#include <avr/io.h>
#include <util/delay.h>

unsigned char leds;

void init(void) {
  DDRB=0xFF;
}

// Adjust for simulation purposes

void delay_ms( unsigned short ams) {
  _delay_ms( ams >> 3);
}

int main(void) {
  init();

  while(1)
  {
    PORTB = 0;
    delay_ms(500);
    PORTB = 255;
    delay_ms(500);
  }
  return 0;
}

========================================================================

2.prj

; ************************************************************
; PROJECT:
; AUTHOR:
; ************************************************************

; Micro + software running
; ------------------------------------------------------------
.MICRO "ATmega8"
.TOOLCHAIN "GCC" ; Bug: use rebuild with errors; then build
.GCCPATH   "C:\WinAVR"
.GCCMAKE   AUTO
.TARGET    "2.hex"
; .COFF    "2.cof" No COFF ! Otherwise use workaround in 1.prj
.SOURCE    "2.c"

.TRACE              ; Activate micro trace

; Following lines are optional; if not included
; exactly these values are taken by default
; ------------------------------------------------------------
.POWER VDD=5 VSS=0  ; Power nodes
.CLOCK 1meg         ; Micro clock
.STORE 250m         ; Trace (micro+signals) storage time

; Micro nodes: RESET, AREF, PB0-PB7, PC0-PC6, PD0-PD7, ACO,
;              TIM1OVF, ADC6, ADC7
; Define here the hardware around the micro
D1 VDD w1
R1 w1 PD0 1k
D2 VDD w2
R2 w2 PD1 1k
D3 VDD w3
R3 w3 PD2 1k
D4 VDD w4
R4 w4 PD3 1k
D5 VDD w5
R5 w5 PD4 1k
D6 VDD w6
R6 w6 PD5 1k
D7 VDD w7
R7 w7 PD6 1k
D8 VDD w8
R8 w8 PD7 1k
K0 VSS PB0
K1 VSS PB1
K2 VSS PB2
K3 VSS PB3
K4 VSS PB4
K5 VSS PB5
K6 VSS PB6
K7 VSS PB7


2.c

#include <avr/io.h>

void init( void) {
    DDRD=0xff;
    PORTD=0xff;
    DDRB=0x00;
    PORTB=0xff;
    UCSRB=0x00;
}

int main ( void) {
    init();

    while (1) {
        if (bit_is_clear(PINB, 0)) PORTD = ~0;
        if (bit_is_clear(PINB, 1)) PORTD = ~1;
        if (bit_is_clear(PINB, 2)) PORTD = ~2;
        if (bit_is_clear(PINB, 3)) PORTD = ~3;
        if (bit_is_clear(PINB, 4)) PORTD = ~4;
        if (bit_is_clear(PINB, 5)) PORTD = ~5;
        if (bit_is_clear(PINB, 6)) PORTD = ~6;
        if (bit_is_clear(PINB, 7)) PORTD = ~7;
    }
}

========================================================================

7SEG.prj

; ************************************************************
; PROJECT:
; AUTHOR: https://sites.google.com/site/thvortex/vmlab/led7seg
; ************************************************************

; Micro + software running
; ------------------------------------------------------------
.MICRO "ATmega8"
.TOOLCHAIN "GCC"     ; Bug: 1. erase everything, but 7SEG.c, 7SEG.prj
                     ;      2. use GCC, compile with errors;
                     ;      3. use GENERIC
.GCCPATH   "C:\WinAVR"
.GCCMAKE   AUTO
.TARGET    "7SEG.hex"
.SOURCE    "7SEG.c"

.TRACE              ; Activate micro trace

; Following lines are optional; if not included
; exactly these values are taken by default
; ------------------------------------------------------------
.POWER VDD=5 VSS=0  ; Power nodes
.CLOCK 1meg         ; Micro clock
.STORE 250m         ; Trace (micro+signals) storage time

; Micro nodes: RESET, AREF, PB0-PB7, PC0-PC6, PD0-PD7, ACO, TIM1OVF, ADC6, ADC7
; Define here the hardware around the micro
; ------------------------------------------------------------

; 8 - digit LED 7 segment display
;
;           7   -   -   -   -   -   -   -
;          | | | 6 | | | | | | 2 | | | | |
;           -   -   -   -   -   -   1   -
;          | | | | | 5 | | 3 | | | | | | |
;           -.  -.  -.  4.  -.  -.  -.  -0

X1 _led7cc VDD GND GND GND GND GND GND GND GND
X2 _led7cc GND VDD GND GND GND GND GND GND GND
X3 _led7cc GND GND VDD GND GND GND GND GND GND
X4 _led7cc GND GND GND VDD GND GND GND GND GND
X5 _led7cc GND GND GND GND VDD GND GND GND GND
X6 _led7cc GND GND GND GND GND VDD GND GND GND
X7 _led7cc GND GND GND GND GND GND VDD GND GND
X8 _led7cc GND GND GND GND GND GND GND VDD GND

; Shows input status

X10 _bitdisp PD7 PD6 PD5 PD4 PD3 PD2 PD1 PD0


7SEG.c

int main(void) {
   while(1) {
   }
}

========================================================================

counter.prj

.MICRO "ATmega8"
;                      Bug: 1. erase everything, but 7SEG.c, 7SEG.prj
;.TOOLCHAIN "GCC"    ;      2. use GCC, compile with errors;
.TOOLCHAIN "GENERIC" ;      3. use GENERIC
.GCCPATH   "C:\WinAVR"
.GCCMAKE   AUTO
.TARGET    "counter.hex"
.SOURCE    "counter.c"

.TRACE              ; Activate micro trace

; Following lines are optional; if not included
; exactly these values are taken by default
; ------------------------------------------------------------
.POWER VDD=5 VSS=0  ; Power nodes
.CLOCK 1meg         ; Micro clock
.STORE 250m         ; Trace (micro+signals) storage time

; Micro nodes: RESET, AREF, PB0-PB7, PC0-PC6, PD0-PD7, ACO, TIM1OVF, ADC6, ADC7
; Define here the hardware around the micro
; ------------------------------------------------------------

; 8 - digit LED 7 segment display
;
;           0   -   -   -   -   -   -   -
;          | | | 1 | | | | | | 5 | | | | |
;           -   -   -   -   -   -   6   -
;          | | | | | 2 | | 4 | | | | | | |
;           -.  -.  -.  3.  -.  -.  -.  -7

X1 _led7cc PD0 PD1 PD2 PD3 PD4 PD5 PD6 PD7 GND

counter.c

#include <avr/io.h>
#include <util/delay.h>

/*
  0        -        0        0        -        0        0        0
 5 1      | 1      | 1      | 1      5 1      5 |      5 |      | 1
  -        -        6        6        6        6        6        -
 4 2      | 2      4 |      | 2      | 2      | 2      3 2      | 2
  3.       -.       3.       3.       -.       3.       3.       -.

 00111111 00000110 01011011 01001111 01100110 01101101 01111101 00000111
 0x3f     0x06     0x5b     0x4f     0x66     0x6d     0x7d     0x07

  0        0        0        -        -        -        0        0
 5 1      5 1      5 1      5 |      | |      | 1      5 |      5 |
  6        6        6        6        6        6        6        6
 4 2      | 2      4 2      4 2      4 |      4 2      4 |      4 |
  3.       3.       -.       3.       3.       3.       3.       -.

 01111111 01101111 01110111 01111100 01011000 01011110 01111001 01110001
 0x7f     0x6f     0x77     0x7c     0x58     0x5e     0x79     0x71
 */

int main(void) {
  int i = 0;
  unsigned char font[] = {
    0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07,
    0x7f, 0x6f, 0x77, 0x7c, 0x58, 0x5e, 0x79, 0x71
  };
  DDRD = 0xff;
  while(1) {
    _delay_ms(50);
    PORTD = font[i++];
    i = (i > 0x0f)? 0 : i;
  }
}

========================================================================

latch.prj

.MICRO "ATmega8"
.TOOLCHAIN "GCC" ; Bug: 1. erase everything, but 7SEG.c, 7SEG.prj
                     ;      2. use GCC, compile with errors;
                     ;      3. use GENERIC
.GCCPATH   "C:\WinAVR"
.GCCMAKE   AUTO
.TARGET    "latch.hex"
.SOURCE    "latch.c"

.TRACE              ; Activate micro trace

; Following lines are optional; if not included
; exactly these values are taken by default
; ------------------------------------------------------------
.POWER VDD=5 VSS=0  ; Power nodes
.CLOCK 1meg         ; Micro clock
.STORE 250m         ; Trace (micro+signals) storage time

; Micro nodes: RESET, AREF, PB0-PB7, PC0-PC6, PD0-PD7, ACO, TIM1OVF, ADC6, ADC7
; Define here the hardware around the micro
; ------------------------------------------------------------

; K0  VSS   N0   LATCHED
; R0  N0    VDD  1K
; K1  VSS   N1   LATCHED
; R1  N1    VDD  1K
; K2  VSS   N2   LATCHED
; R2  N2    VDD  1K
; K3  VSS   N3   LATCHED
; R3  N3    VDD  1K
; K4  VSS   N4   LATCHED
; R4  N4    VDD  1K
; K5  VSS   N5   LATCHED
; R5  N5    VDD  1K
; K6  VSS   N6   LATCHED
; R6  N6    VDD  1K
; K7  VSS   N7    LATCHED
; R7  N7    VDD  1K
; K8  VSS   N8
; R8  N8    VDD  1K
; K9  VSS   N9
; R9  N9    VDD  1K
; KA  VSS   NA
; RA  NA    VDD  1K
; KB  VSS   NB
; RB  NB    VDD  1K
; KC  VSS   NC
; RC  NC    VDD  1K
; KD  VSS   ND
; RD  ND    VDD  1K
; KE  VSS   NE
; RE  NE    VDD  1K
; KF  VSS   NF
; RF  NF    VDD  1K

R0    N0   PD0    10
R1    N1   PD1    10
R2    N2   PD2    10
R3    N3   PD3    10
R4    N4   PD4    10
R5    N5   PD5    10
R6    N6   PD6    10
R7    N7   PD7    10
R8    N8   PB0    10
R9    N9   PB1    10
RA    NA   PB2    10
RB    NB   PB3    10
RC    NC   PB4    10
RD    ND   PB5    10
RE    NE   PB6    10
RF    NF   PB7    10

X001  ND2  N0     NX004  NX001
X002  ND2  NX003  NX004  NX002
X003  ND2  N0     N0     NX003
X004  ND2  N8     N8     NX004
X005  ND2  NX001  Z001   Z000
X006  ND2  NX002  Z000   Z001

X011  ND2  N1     NX014  NX011
X012  ND2  NX013  NX014  NX012
X013  ND2  N1     N1     NX013
X014  ND2  N8     N8     NX014
X015  ND2  NX011  Z011   Z010
X016  ND2  NX012  Z010   Z011

X021  ND2  N2     NX024  NX021
X022  ND2  NX023  NX024  NX022
X023  ND2  N2     N2     NX023
X024  ND2  N8     N8     NX024
X025  ND2  NX021  Z021   Z020
X026  ND2  NX022  Z020   Z021

X031  ND2  N3     NX034  NX031
X032  ND2  NX033  NX034  NX032
X033  ND2  N3     N3     NX033
X034  ND2  N8     N8     NX034
X035  ND2  NX031  Z031   Z030
X036  ND2  NX032  Z030   Z031

X041  ND2  N4     NX044  NX041
X042  ND2  NX043  NX044  NX042
X043  ND2  N4     N4     NX043
X044  ND2  N8     N8     NX044
X045  ND2  NX041  Z041   Z040
X046  ND2  NX042  Z040   Z041

X051  ND2  N5     NX054  NX051
X052  ND2  NX053  NX054  NX052
X053  ND2  N5     N5     NX053
X054  ND2  N8     N8     NX054
X055  ND2  NX051  Z051   Z050
X056  ND2  NX052  Z050   Z051

X061  ND2  N6     NX064  NX061
X062  ND2  NX063  NX064  NX062
X063  ND2  N6     N6     NX063
X064  ND2  N8     N8     NX064
X065  ND2  NX061  Z061   Z060
X066  ND2  NX062  Z060   Z061

X071  ND2  N7     NX074  NX071
X072  ND2  NX073  NX074  NX072
X073  ND2  N7     N7     NX073
X074  ND2  N8     N8     NX074
X075  ND2  NX071  Z071   Z070
X076  ND2  NX072  Z070   Z071

R00  Z000  NX00   1K
R01  Z010  NX01   1K
R02  Z020  NX02   1K
R03  Z030  NX03   1K
R04  Z040  NX04   1K
R05  Z050  NX05   1K
R06  Z060  NX06   1K
R07  Z070  NX07   1K


X101  ND2  N0     NX104  NX101
X102  ND2  NX103  NX104  NX102
X103  ND2  N0     N0     NX103
X104  ND2  N9     N9     NX104
X105  ND2  NX101  Z101   Z100
X106  ND2  NX102  Z100   Z101

X111  ND2  N1     NX114  NX111
X112  ND2  NX113  NX114  NX112
X113  ND2  N1     N1     NX113
X114  ND2  N9     N9     NX114
X115  ND2  NX111  Z111   Z110
X116  ND2  NX112  Z110   Z111

X121  ND2  N2     NX124  NX121
X122  ND2  NX123  NX124  NX122
X123  ND2  N2     N2     NX123
X124  ND2  N9     N9     NX124
X125  ND2  NX121  Z121   Z120
X126  ND2  NX122  Z120   Z121

X131  ND2  N3     NX134  NX131
X132  ND2  NX133  NX134  NX132
X133  ND2  N3     N3     NX133
X134  ND2  N9     N9     NX134
X135  ND2  NX131  Z131   Z130
X136  ND2  NX132  Z130   Z131

X141  ND2  N4     NX144  NX141
X142  ND2  NX143  NX144  NX142
X143  ND2  N4     N4     NX143
X144  ND2  N9     N9     NX144
X145  ND2  NX141  Z141   Z140
X146  ND2  NX142  Z140   Z141

X151  ND2  N5     NX154  NX151
X152  ND2  NX153  NX154  NX152
X153  ND2  N5     N5     NX153
X154  ND2  N9     N9     NX154
X155  ND2  NX151  Z151   Z150
X156  ND2  NX152  Z150   Z151

X161  ND2  N6     NX164  NX161
X162  ND2  NX163  NX164  NX162
X163  ND2  N6     N6     NX163
X164  ND2  N9     N9     NX164
X165  ND2  NX161  Z161   Z160
X166  ND2  NX162  Z160   Z161

X171  ND2  N7     NX174  NX171
X172  ND2  NX173  NX174  NX172
X173  ND2  N7     N7     NX173
X174  ND2  N9     N9     NX174
X175  ND2  NX171  Z171   Z170
X176  ND2  NX172  Z170   Z171

R10  Z100  NX10  1K
R11  Z110  NX11  1K
R12  Z120  NX12  1K
R13  Z130  NX13  1K
R14  Z140  NX14  1K
R15  Z150  NX15  1K
R16  Z160  NX16  1K
R17  Z170  NX17  1K


X201  ND2  N0     NX204  NX201
X202  ND2  NX203  NX204  NX202
X203  ND2  N0     N0     NX203
X204  ND2  NA     NA     NX204
X205  ND2  NX201  Z201   Z200
X206  ND2  NX202  Z200   Z201

X211  ND2  N1     NX214  NX211
X212  ND2  NX213  NX214  NX212
X213  ND2  N1     N1     NX213
X214  ND2  NA     NA     NX214
X215  ND2  NX211  Z211   Z210
X216  ND2  NX212  Z210   Z211

X221  ND2  N2     NX224  NX221
X222  ND2  NX223  NX224  NX222
X223  ND2  N2     N2     NX223
X224  ND2  NA     NA     NX224
X225  ND2  NX221  Z221   Z220
X226  ND2  NX222  Z220   Z221

X231  ND2  N3     NX234  NX231
X232  ND2  NX233  NX234  NX232
X233  ND2  N3     N3     NX233
X234  ND2  NA     NA     NX234
X235  ND2  NX231  Z231   Z230
X236  ND2  NX232  Z230   Z231

X241  ND2  N4     NX244  NX241
X242  ND2  NX243  NX244  NX242
X243  ND2  N4     N4     NX243
X244  ND2  NA     NA     NX244
X245  ND2  NX241  Z241   Z240
X246  ND2  NX242  Z240   Z241

X251  ND2  N5     NX254  NX251
X252  ND2  NX253  NX254  NX252
X253  ND2  N5     N5     NX253
X254  ND2  NA     NA     NX254
X255  ND2  NX251  Z251   Z250
X256  ND2  NX252  Z250   Z251

X261  ND2  N6     NX264  NX261
X262  ND2  NX263  NX264  NX262
X263  ND2  N6     N6     NX263
X264  ND2  NA     NA     NX264
X265  ND2  NX261  Z261   Z260
X266  ND2  NX262  Z260   Z261

X271  ND2  N7     NX274  NX271
X272  ND2  NX273  NX274  NX272
X273  ND2  N7     N7     NX273
X274  ND2  NA     NA     NX274
X275  ND2  NX271  Z271   Z270
X276  ND2  NX272  Z270   Z271

R20  Z200  NX20   1K
R21  Z210  NX21   1K
R22  Z220  NX22   1K
R23  Z230  NX23   1K
R24  Z240  NX24   1K
R25  Z250  NX25   1K
R26  Z260  NX26   1K
R27  Z270  NX27   1K


X301  ND2  N0     NX304  NX301
X302  ND2  NX303  NX304  NX302
X303  ND2  N0     N0     NX303
X304  ND2  NB     NB     NX304
X305  ND2  NX301  Z301   Z300
X306  ND2  NX302  Z300   Z301

X311  ND2  N1     NX314  NX311
X312  ND2  NX313  NX314  NX312
X313  ND2  N1     N1     NX313
X314  ND2  NB     NB     NX314
X315  ND2  NX311  Z311   Z310
X316  ND2  NX312  Z310   Z311

X321  ND2  N2     NX324  NX321
X322  ND2  NX323  NX324  NX322
X323  ND2  N2     N2     NX323
X324  ND2  NB     NB     NX324
X325  ND2  NX321  Z321   Z320
X326  ND2  NX322  Z320   Z321

X331  ND2  N3     NX334  NX331
X332  ND2  NX333  NX334  NX332
X333  ND2  N3     N3     NX333
X334  ND2  NB     NB     NX334
X335  ND2  NX331  Z331   Z330
X336  ND2  NX332  Z330   Z331

X341  ND2  N4     NX344  NX341
X342  ND2  NX343  NX344  NX342
X343  ND2  N4     N4     NX343
X344  ND2  NB     NB     NX344
X345  ND2  NX341  Z341   Z340
X346  ND2  NX342  Z340   Z341

X351  ND2  N5     NX354  NX351
X352  ND2  NX353  NX354  NX352
X353  ND2  N5     N5     NX353
X354  ND2  NB     NB     NX354
X355  ND2  NX351  Z351   Z350
X356  ND2  NX352  Z350   Z351

X361  ND2  N6     NX364  NX361
X362  ND2  NX363  NX364  NX362
X363  ND2  N6     N6     NX363
X364  ND2  NB     NB     NX364
X365  ND2  NX361  Z361   Z360
X366  ND2  NX362  Z360   Z361

X371  ND2  N7     NX374  NX371
X372  ND2  NX373  NX374  NX372
X373  ND2  N7     N7     NX373
X374  ND2  NB     NB     NX374
X375  ND2  NX371  Z371   Z370
X376  ND2  NX372  Z370   Z371

R30  Z300  NX30   1K
R31  Z310  NX31   1K
R32  Z320  NX32   1K
R33  Z330  NX33   1K
R34  Z340  NX34   1K
R35  Z350  NX35   1K
R36  Z360  NX36   1K
R37  Z370  NX37   1K


X401  ND2  N0     NX404  NX401
X402  ND2  NX403  NX404  NX402
X403  ND2  N0     N0     NX403
X404  ND2  NC     NC     NX404
X405  ND2  NX401  Z401   Z400
X406  ND2  NX402  Z400   Z401

X411  ND2  N1     NX414  NX411
X412  ND2  NX413  NX414  NX412
X413  ND2  N1     N1     NX413
X414  ND2  NC     NC     NX414
X415  ND2  NX411  Z411   Z410
X416  ND2  NX412  Z410   Z411

X421  ND2  N2     NX424  NX421
X422  ND2  NX423  NX424  NX422
X423  ND2  N2     N2     NX423
X424  ND2  NC     NC     NX424
X425  ND2  NX421  Z421   Z420
X426  ND2  NX422  Z420   Z421

X431  ND2  N3     NX434  NX431
X432  ND2  NX433  NX434  NX432
X433  ND2  N3     N3     NX433
X434  ND2  NC     NC     NX434
X435  ND2  NX431  Z431   Z430
X436  ND2  NX432  Z430   Z431

X441  ND2  N4     NX444  NX441
X442  ND2  NX443  NX444  NX442
X443  ND2  N4     N4     NX443
X444  ND2  NC     NC     NX444
X445  ND2  NX441  Z441   Z440
X446  ND2  NX442  Z440   Z441

X451  ND2  N5     NX454  NX451
X452  ND2  NX453  NX454  NX452
X453  ND2  N5     N5     NX453
X454  ND2  NC     NC     NX454
X455  ND2  NX451  Z451   Z450
X456  ND2  NX452  Z450   Z451

X461  ND2  N6     NX464  NX461
X462  ND2  NX463  NX464  NX462
X463  ND2  N6     N6     NX463
X464  ND2  NC     NC     NX464
X465  ND2  NX461  Z461   Z460
X466  ND2  NX462  Z460   Z461

X471  ND2  N7     NX474  NX471
X472  ND2  NX473  NX474  NX472
X473  ND2  N7     N7     NX473
X474  ND2  NC     NC     NX474
X475  ND2  NX471  Z471   Z470
X476  ND2  NX472  Z470   Z471

R40  Z400  NX40   1K
R41  Z410  NX41   1K
R42  Z420  NX42   1K
R43  Z430  NX43   1K
R44  Z440  NX44   1K
R45  Z450  NX45   1K
R46  Z460  NX46   1K
R47  Z470  NX47   1K


X501  ND2  N0     NX504  NX501
X502  ND2  NX503  NX504  NX502
X503  ND2  N0     N0     NX503
X504  ND2  ND     ND     NX504
X505  ND2  NX501  Z501   Z500
X506  ND2  NX502  Z500   Z501

X511  ND2  N1     NX514  NX511
X512  ND2  NX513  NX514  NX512
X513  ND2  N1     N1     NX513
X514  ND2  ND     ND     NX514
X515  ND2  NX511  Z511   Z510
X516  ND2  NX512  Z510   Z511

X521  ND2  N2     NX524  NX521
X522  ND2  NX523  NX524  NX522
X523  ND2  N2     N2     NX523
X524  ND2  ND     ND     NX524
X525  ND2  NX521  Z521   Z520
X526  ND2  NX522  Z520   Z521

X531  ND2  N3     NX534  NX531
X532  ND2  NX533  NX534  NX532
X533  ND2  N3     N3     NX533
X534  ND2  ND     ND     NX534
X535  ND2  NX531  Z531   Z530
X536  ND2  NX532  Z530   Z531

X541  ND2  N4     NX544  NX541
X542  ND2  NX543  NX544  NX542
X543  ND2  N4     N4     NX543
X544  ND2  ND     ND     NX544
X545  ND2  NX541  Z541   Z540
X546  ND2  NX542  Z540   Z541

X551  ND2  N5     NX554  NX551
X552  ND2  NX553  NX554  NX552
X553  ND2  N5     N5     NX553
X554  ND2  ND     ND     NX554
X555  ND2  NX551  Z551   Z550
X556  ND2  NX552  Z550   Z551

X561  ND2  N6     NX564  NX561
X562  ND2  NX563  NX564  NX562
X563  ND2  N6     N6     NX563
X564  ND2  ND     ND     NX564
X565  ND2  NX561  Z561   Z560
X566  ND2  NX562  Z560   Z561

X571  ND2  N7     NX574  NX571
X572  ND2  NX573  NX574  NX572
X573  ND2  N7     N7     NX573
X574  ND2  ND     ND     NX574
X575  ND2  NX571  Z571   Z570
X576  ND2  NX572  Z570   Z571

R50  Z500  NX50   1K
R51  Z510  NX51   1K
R52  Z520  NX52   1K
R53  Z530  NX53   1K
R54  Z540  NX54   1K
R55  Z550  NX55   1K
R56  Z560  NX56   1K
R57  Z570  NX57   1K


X601  ND2  N0     NX604  NX601
X602  ND2  NX603  NX604  NX602
X603  ND2  N0     N0     NX603
X604  ND2  NE     NE     NX604
X605  ND2  NX601  Z601   Z600
X606  ND2  NX602  Z600   Z601

X611  ND2  N1     NX614  NX611
X612  ND2  NX613  NX614  NX612
X613  ND2  N1     N1     NX613
X614  ND2  NE     NE     NX614
X615  ND2  NX611  Z611   Z610
X616  ND2  NX612  Z610   Z611

X621  ND2  N2     NX624  NX621
X622  ND2  NX623  NX624  NX622
X623  ND2  N2     N2     NX623
X624  ND2  NE     NE     NX624
X625  ND2  NX621  Z621   Z620
X626  ND2  NX622  Z620   Z621

X631  ND2  N3     NX634  NX631
X632  ND2  NX633  NX634  NX632
X633  ND2  N3     N3     NX633
X634  ND2  NE     NE     NX634
X635  ND2  NX631  Z631   Z630
X636  ND2  NX632  Z630   Z631

X641  ND2  N4     NX644  NX641
X642  ND2  NX643  NX644  NX642
X643  ND2  N4     N4     NX643
X644  ND2  NE     NE     NX644
X645  ND2  NX641  Z641   Z640
X646  ND2  NX642  Z640   Z641

X651  ND2  N5     NX654  NX651
X652  ND2  NX653  NX654  NX652
X653  ND2  N5     N5     NX653
X654  ND2  NE     NE     NX654
X655  ND2  NX651  Z651   Z650
X656  ND2  NX652  Z650   Z651

X661  ND2  N6     NX664  NX661
X662  ND2  NX663  NX664  NX662
X663  ND2  N6     N6     NX663
X664  ND2  NE     NE     NX664
X665  ND2  NX661  Z661   Z660
X666  ND2  NX662  Z660   Z661

X671  ND2  N7     NX674  NX671
X672  ND2  NX673  NX674  NX672
X673  ND2  N7     N7     NX673
X674  ND2  NE     NE     NX674
X675  ND2  NX671  Z671   Z670
X676  ND2  NX672  Z670   Z671

R60  Z600  NX60   1K
R61  Z610  NX61   1K
R62  Z620  NX62   1K
R63  Z630  NX63   1K
R64  Z640  NX64   1K
R65  Z650  NX65   1K
R66  Z660  NX66   1K
R67  Z670  NX67   1K


X701  ND2  N0     NX704  NX701
X702  ND2  NX703  NX704  NX702
X703  ND2  N0     N0     NX703
X704  ND2  NF     NF     NX704
X705  ND2  NX701  Z701   Z700
X706  ND2  NX702  Z700   Z701

X711  ND2  N1     NX714  NX711
X712  ND2  NX713  NX714  NX712
X713  ND2  N1     N1     NX713
X714  ND2  NF     NF     NX714
X715  ND2  NX711  Z711   Z710
X716  ND2  NX712  Z710   Z711

X721  ND2  N2     NX724  NX721
X722  ND2  NX723  NX724  NX722
X723  ND2  N2     N2     NX723
X724  ND2  NF     NF     NX724
X725  ND2  NX721  Z721   Z720
X726  ND2  NX722  Z720   Z721

X731  ND2  N3     NX734  NX731
X732  ND2  NX733  NX734  NX732
X733  ND2  N3     N3     NX733
X734  ND2  NF     NF     NX734
X735  ND2  NX731  Z731   Z730
X736  ND2  NX732  Z730   Z731

X741  ND2  N4     NX744  NX741
X742  ND2  NX743  NX744  NX742
X743  ND2  N4     N4     NX743
X744  ND2  NF     NF     NX744
X745  ND2  NX741  Z741   Z740
X746  ND2  NX742  Z740   Z741

X751  ND2  N5     NX754  NX751
X752  ND2  NX753  NX754  NX752
X753  ND2  N5     N5     NX753
X754  ND2  NF     NF     NX754
X755  ND2  NX751  Z751   Z750
X756  ND2  NX752  Z750   Z751

X761  ND2  N6     NX764  NX761
X762  ND2  NX763  NX764  NX762
X763  ND2  N6     N6     NX763
X764  ND2  NF     NF     NX764
X765  ND2  NX761  Z761   Z760
X766  ND2  NX762  Z760   Z761

X771  ND2  N7     NX774  NX771
X772  ND2  NX773  NX774  NX772
X773  ND2  N7     N7     NX773
X774  ND2  NF     NF     NX774
X775  ND2  NX771  Z771   Z770
X776  ND2  NX772  Z770   Z771

R70  Z700  NX70   1K
R71  Z710  NX71   1K
R72  Z720  NX72   1K
R73  Z730  NX73   1K
R74  Z740  NX74   1K
R75  Z750  NX75   1K
R76  Z760  NX76   1K
R77  Z770  NX77   1K

X17 _led7cc NX00 NX01 NX02 NX03 NX04 NX05 NX06 NX07  GND
X18 _led7cc NX10 NX11 NX12 NX13 NX14 NX15 NX16 NX17  GND
X19 _led7cc NX20 NX21 NX22 NX23 NX24 NX25 NX26 NX27  GND
X20 _led7cc NX30 NX31 NX32 NX33 NX34 NX35 NX36 NX37  GND
X21 _led7cc NX40 NX41 NX42 NX43 NX44 NX45 NX46 NX47  GND
X22 _led7cc NX50 NX51 NX52 NX53 NX54 NX55 NX56 NX57  GND
X23 _led7cc NX60 NX61 NX62 NX63 NX64 NX65 NX66 NX67  GND
X24 _led7cc NX70 NX71 NX72 NX73 NX74 NX75 NX76 NX77  GND

X30 _bitdisp Z000 Z010 Z020 Z030 Z040 Z050 Z060 Z070
X31 _bitdisp N0   N1   N2   N3   N4   N5   N6   N7
X32 _bitdisp N008 NC   NC   NC   NC   NC   NC   NC

.Plot V(PB0) V(PB1) V(PB2) V(PB3) V(PB4) V(PB5) V(PB6) V(PB7)


latch.c

#include <avr/io.h>
#include <util/delay.h>
#include <string.h>

/*
  0        -        0        0        -        0        0        0
 5 1      | 1      | 1      | 1      5 1      5 |      5 |      | 1
  -        -        6        6        6        6        6        -
 4 2      | 2      4 |      | 2      | 2      | 2      3 2      | 2
  3.       -.       3.       3.       -.       3.       3.       -.

 00111111 00000110 01011011 01001111 01100110 01101101 01111101 00000111
 0x3f     0x06     0x5b     0x4f     0x66     0x6d     0x7d     0x07

  0        0        0        -        -        -        0        0
 5 1      5 1      5 1      5 |      | |      | 1      5 |      5 |
  6        6        6        6        6        6        6        6
 4 2      | 2      4 2      4 2      4 |      4 2      4 |      4 |
  3.       3.       -.       3.       3.       3.       3.       -.

 01111111 01101111 01110111 01111100 01011000 01011110 01111001 01110001
 0x7f     0x6f     0x77     0x7c     0x58     0x5e     0x79     0x71

  0        -        0        0        -        -        -        -
 5 |      5 |      | |      | |      5 1      5 |      5 1      | |
  -        6        -        -        6        -        -        6
 4 2      4 2      4 |      | 2      4 2      4 |      4 2      4 2
  3.       -.       3.       3.       _.       3.       -.       -.

 00111101 01110100 00011001 00001101 01110110 00111000 00110110 01010100
 0x3d     0x74     0x19     0x0d     0x76     0x38     0x36     0x54

  -        0        0        -        -        -        -        -
 | |      5 1      5 1      | |      5 |      5 |      5 1      | |
  6        6        6        6        6        6        -        -
 4 2      4 |      | 2      4 |      | 2      4 |      4 2      4 2
  3.       -.       -.       -.       3.       3.       3.       3.

 01011100 01110011 01100111 01010000 01101100 01111000 00111110 00011100
 0x5c     0x73     0x67     0x50     0x6c     0x78     0x3e     0x1c

  -        -        -        0        -        -        -        -
 5 1      | |      5 1      | |      | |      | |      | |      | |
  6        -        6        6        -        -        6        6
 4 2      4 2      | 2      | |      | |      | |      | |      | |
  3.       -.       3.       3.       -.       3.       -.       3.

 01111110 00010100 01101110 01001001 00000000 00001000 01000000 01001000
 0x7e     0x14     0x6e     0x49     0x00     0x08     0x40     0x48
 */

unsigned char font[] = {
 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07,
 0x7f, 0x6f, 0x77, 0x7c, 0x58, 0x5e, 0x79, 0x71,
 0x3d, 0x74, 0x19, 0x0d, 0x76, 0x38, 0x36, 0x54,
 0x5c, 0x73, 0x67, 0x50, 0x6c, 0x78, 0x3e, 0x1c,
 0x7e, 0x14, 0x6e, 0x49, 0x00, 0x08, 0x40, 0x48
};

void putat(int a, int i) {
  PORTB=0xff;
  PORTD = font[a];
  _delay_ms(1);
  PORTB = ~(1 << i%8); i++;
  _delay_ms(1);
  PORTB = 0xff;
}

void putstring(char* as) {
  int n = strlen( as);
  int i = 0;
  while (i < n) { putat( *(as+i)+10-'A', i); i++; }
}

int main( void) {
  DDRD = 0xff;
  DDRB = 0xff;

  putstring("HI[WORLD");

  return 0;
}

========================================================================

LCD.prj

.MICRO "ATmega88" "CKDIV8=1"
.TOOLCHAIN "GCC"
.GCCPATH   "C:\WinAVR"
.GCCMAKE   AUTO
.TARGET    "LCD.hex"
.SOURCE    "LCD.c"

.TRACE              ; Activate micro trace

; Following lines are optional; if not included
; exactly these values are taken by default
; ------------------------------------------------------------
.POWER VDD=5 VSS=0  ; Power nodes
.CLOCK 1meg         ; Micro clock
.STORE 250m         ; Trace (micro+signals) storage time

; Micro nodes: RESET, AREF, PB0-PB7, PC0-PC6, PD0-PD7, ACO, TIM1OVF, ADC6, ADC7
; Define here the hardware around the micro
; ------------------------------------------------------------

;                 RS   R/W  E    8-bit Data
;                 ---  ---  ---  -------------------------------
X1 LCD(16 2 250K) PB2  PC4  PC5  PD7 PD6 PD5 PD4 PD3 PD2 PD1 PD0


LCD.c (VMLAB-88)

#include <avr/io.h>
#include <util/delay.h>

#define LCD_DATA_PORT PORTD
#define LCD_DATA_DDR  DDRD

#define LCD_E_PORT    PORTC
#define LCD_E_DDR     DDRC
#define LCD_E         5

#define LCD_RW_PORT   PORTC
#define LCD_RW_DDR    DDRC
#define LCD_RW        4

#define LCD_RS_PORT   PORTB
#define LCD_RS_DDR    DDRB
#define LCD_RS        2

#define PORT_ON( port, pin)  port |= (1<<pin)
#define PORT_OFF( port, pin) port &= ~(1<<pin)

void LCD_byte(unsigned char aByte)
{
    _delay_us(50);
    LCD_DATA_PORT = aByte;
    PORT_ON( LCD_E_PORT, LCD_E);
    _delay_us(50);
    PORT_OFF( LCD_E_PORT, LCD_E);
}

void LCD_command(unsigned char aCommand)
{
    // RS = 0 so it's command
    PORT_OFF( LCD_RS_PORT, LCD_RS);
    LCD_byte(aCommand);
}

void LCD_char(unsigned char aChar)
{
    // RS = 1 so show it
    PORT_ON( LCD_RS_PORT, LCD_RS);
    LCD_byte(aChar);
}

void LCD_row(unsigned char aRow) // row 0, row 1
{
    _delay_ms(5);
    LCD_command(0x80 + 0x40 * aRow);
    _delay_ms(5);
}

void LCD_print(char* aStr) {
    while( *aStr) LCD_char(*aStr++);
}

void LCD_init(void)   // Radioamateur, 2005.6 (Bulgaria)
{
    _delay_ms(15);      // Rain, TTU E44
    LCD_command( 0x08); // Display off
    LCD_command( 0x38); // LCD 8 bit 2 rows
    _delay_ms(50);
    LCD_command( 0x38); // LCD 8 bit 2 rows
      _delay_ms(5);
    LCD_command( 0x38); // LCD 8 bit 2 rows
    LCD_command( 0x38); // LCD 8 bit 2 rows
    LCD_command( 0x01); // Display clear
    _delay_ms(50);
    LCD_command( 0x06); // Write left to right
    LCD_command( 0x0D); // Display on, blinking cursor
}

void LCD_attach( void) {
    PORT_ON( LCD_RS_DDR, LCD_RS);
    PORT_ON( LCD_RW_DDR, LCD_RW);
    PORT_ON( LCD_E_DDR, LCD_E);
    LCD_DATA_DDR = 0xFF;

    PORT_OFF( LCD_RS_PORT, LCD_RS);
    PORT_OFF( LCD_RW_PORT, LCD_RW);
    PORT_OFF( LCD_E_PORT, LCD_E);

    LCD_DATA_PORT = PORTD;
}

int main(void) {
    LCD_attach();
    LCD_init();
    LCD_print("HELLO WORLD !");
    return 0;
}

========================================================================

ADC.prj

; ************************************************************
; PROJECT:
; AUTHOR:
; ************************************************************

; Micro + software running
; ------------------------------------------------------------
.MICRO "ATmega88" "CKDIV8=1"
.TOOLCHAIN "GCC"
.GCCPATH   "C:\WinAVR"
.GCCMAKE   AUTO
.TARGET    "adc.hex"
.SOURCE    "adc.c"

.TRACE              ; Activate micro trace

; Following lines are optional; if not included
; exactly these values are taken by default
; ------------------------------------------------------------
.POWER VDD=5 VSS=0  ; Power nodes
.CLOCK 1meg       ; Micro clock
.STORE 250m         ; Trace (micro+signals) storage time

; Micro nodes: RESET, AREF, PB0-PB7, PC0-PC6, PD0-PD7, ACO, TIM1OVF, ADC6, ADC7
; Define here the hardware around the micro
; ------------------------------------------------------------

VV PC0 VSS SLIDER_1(0 5) ;x: Panel sliders 1 - 3
D1 VDD n1
R1 n1 PD0 1k
D2 VDD n2
R2 n2 PD1 1k
D3 VDD n3
R3 n3 PD2 1k
D4 VDD n4
R4 n4 PD3 1k
D5 VDD n5
R5 n5 PD4 1k
D6 VDD n6
R6 n6 PD5 1k
D7 VDD n7
R7 n7 PD6 1k
D8 VDD n8
R8 n8 PD7 1k


ADC.c

#include  <avr/io.h>

#define  PORT_ON(port,pin) port |= (1<<pin)
#define  PORT_OFF(port,pin) port &=  ~(1<<pin)

int main(void) {
  unsigned int adc_value;
  DDRD=0xff;
  PORTD  = 0x00;

  ADMUX &= 0xf0;            // set channel 0

  PORT_OFF( ADCSRA, ADPS2);
  PORT_ON( ADCSRA, ADPS1);
  PORT_ON( ADCSRA, ADPS0);

  PORT_ON( ADMUX, REFS0);   // Voltage reference from Avcc (5v)
  PORT_ON( ADCSRA, ADEN);   // Turn on ADC
  PORT_ON( ADCSRA, ADSC);   // Do an initial conversion because this
                            // one is the slowest and to ensure that
  while (1) {               // everything is up and running
    // Start conversion
    PORT_ON( ADCSRA, ADSC);
    // wait until conversion  completes; ADSC=0 means Complete
    while (ADCSRA & (1<<ADSC));
    adc_value = ADCW;       //Store ADC result
    if (adc_value < 128)      PORTD = 0x7f;
    else if (adc_value < 256) PORTD = 0x3f;
    else if (adc_value < 384) PORTD = 0x1f;
    else if (adc_value < 512) PORTD = 0x0f;
    else if (adc_value < 640) PORTD = 0x07;
    else if (adc_value < 768) PORTD = 0x03;
    else if (adc_value < 896) PORTD = 0x01;
    else PORTD = 0;
  }
}

========================================================================

default.prj

.MICRO "ATmega88"
.TOOLCHAIN "GCC"
.GCCPATH   "C:\WinAVR"
.GCCMAKE   AUTO
.TARGET    "3.hex"
.SOURCE    "3.c"

.TRACE              ; Activate micro trace

; Following lines are optional; if not included
; exactly these values are taken by default
; ------------------------------------------------------------
.POWER VDD=5 VSS=0  ; Power nodes
.CLOCK 1meg         ; Micro clock
.STORE 250m         ; Trace (micro+signals) storage time

; Micro nodes: RESET, AREF, PB0-PB7, PC0-PC6, PD0-PD7, ACO,
;              TIM1OVF, ADC6, ADC7.
; Define here the hardware around the micro
; ------------------------------------------------------------


default.c

#include <avr\io.h>              // Most basic include files
#include <avr\interrupt.h>       // Add the necessary ones
#include <avr\signal.h>          // here

// Define here the global static variables

int My_global;

// Interrupt handler example for INT0

SIGNAL(SIG_INTERRUPT0) {
}

// It is recommended to use this coding style to
// follow better the mixed C-assembly code in the
// Program Memory window

void my_function(void) {
   asm("nop");          // Inline assembly example
}

int main(void) {
   while(1) {             // Infinite loop; define here the
      my_function();      // system behaviour
   }
}

========================================================================

gcc chain

Making code. Using GCC tool chain
make -f __auto.mak -j 1 clean
make -f __auto.mak -j 1

gcc.bat

@start /MIN /wait cmd /c gcc2.bat %1
@type c:\tempfile
@del c:\tempfile

gcc2.bat

make.exe %1 >c:\tempfile 2>&1
