Projects

Atmega8535
iBot
Light_controller
    preAmpli


    Connections

    Source code

    /*************************************************
    * Description     : Interrupt Test
    * Last update     : 18 november 2005
    * Crystal     : 8 or 16 MHz
    * Email     : geoffroy@lumay.be
    * OK for avr-libc 1.2 ! (tested)
    *************************************************/


    #include <avr/io.h>
    #include <avr/io8535.h>
    #include <avr/interrupt.h>
    #include <avr/signal.h>

    #define CRYSTAL      16000000 // Clock frequency
                                             //#define CRYSTAL      8000000 // Clock frequency
    #define LED_PORT      PORTC     // LCD data port
    #define INT_PORT      PORTD     // int0 and int1 port

    //We redefine some deprecated functions
    #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
    #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))

    //Global declarations
    unsigned char i;

    void init(void){
         DDRC=0xFF;      // set LED_PORT as output
         DDRD=0x00;      // set INT_PORT as input
         LED_PORT=0x00; // reset LED_PORT
         INT_PORT=0x0C; // set int0 and int1
         GIMSK=(1 << INT1) | (1 << INT0);
         MCUCR=(1 << ISC10) | (1 << ISC11) | (1 << ISC00) | (1 << ISC01);
    }

    int main (void){
         init();
         sei();
         while (1){
         }
    }

    // receive interrupt
    SIGNAL(SIG_INTERRUPT0){
         sbi(LED_PORT,0);
    }

    SIGNAL(SIG_INTERRUPT1){
         cbi(LED_PORT,0);
    }

    MakeFile

    #Makefile writen by Geoffroy Lumay
    #Path for avr-gcc
    AVRPATH=/usr/local/atmel/bin
    MCU=at90s8535
    CC=$(AVRPATH)/avr-gcc
    OBJCOPY=$(AVRPATH)/avr-objcopy
    # optimization
    CFLAGS=-g -mmcu=$(MCU) -Wall -Wstrict-prototypes -Os -mcall-prologues
    #*****************************************************
    all: ProgAtmel.hex
    ProgAtmel.hex : ProgAtmel.out
    $(OBJCOPY) -R .eeprom -O ihex ProgAtmel.out ProgAtmel.hex
    ProgAtmel.out : ProgAtmel.o
    $(CC) $(CFLAGS) -o ProgAtmel.out -Wl,-Map,ProgAtmel.map ProgAtmel.o
    ProgAtmel.o : ProgAtmel.c
    $(CC) $(CFLAGS) -Os -c ProgAtmel.c
    #******************************************************
    load: ProgAtmel.hex
    # erase before loading the program.
    uisp -dlpt=/dev/parport0 --erase -dprog=dapa
    # load (program) the software into the eeprom:
    uisp -dlpt=/dev/parport0 --upload if=ProgAtmel.hex -dprog=dapa -v=3 --hash=32
    #*******************************************************
    clean:
    rm -f *.o *.map *.out
    #*******************************************************
    fuse:
    #fusing the atmega8535 for quartz
    uisp -dlpt=/dev/parport0 -dprog=dapa --wr_fuse_e=0xFF --wr_fuse_l=0xEF --wr_fuse_h=0xC9
    #********************************************************
    readfuse:
    #Read the fuse
    uisp -dlpt=/dev/parport0 -dprog=dapa --rd_fuses


    To compile the project, type make
    To load the hex file in the controler, type (as su) #make load
    To read the fuses, type (as su) #make readfuse
    To change the fuses of the Atmega8535, type (as su) #make fuse