Projects

Atmega8535
iBot
Light_controller
    preAmpli


    Connections

    Source code

    /*************************************************
    * Description     : LED 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>

    #define CRYSTAL      16000000 // Clock frequency
    //#define CRYSTAL      8000000 // Clock frequency
    #define LED_PORT      PORTC     // LCD data port

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

    unsigned char i;

    void init(void){
         DDRC=0xFF;      // set LED_PORT as output
         LED_PORT=0x00; // reset LED_PORT
    }

    void delay_10ms(void){                    /*10 millisec delay*/
         unsigned char test = 1;
         TCCR0=0x05;
         TCNT0=0x63;     //for 16 MHz
         //TCNT0=0xB1; //for 8 MHz
         while (test){
              test = ~TIFR & 0x01;
         }
         TIFR=0x01;
    }

    int main (void){
         init();
         unsigned char i;
         while (1){
              sbi(LED_PORT,0); //LED ON
              for(i=0;i<50;i++) //Wait 500 ms
                   delay_10ms();
              cbi(LED_PORT,0); //LED OFF
              for(i=0;i<50;i++) //Wait 500 ms
                   delay_10ms();
         }
    }

    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