Go Down

Topic: Similar Microcontrollers to Arduino/Atmega?? (Read 5340 times) previous topic - next topic


Joe (and Bruce):

I have never been accused of being diplomatic but I didn't mean to be offensive either.  The original post was so full of misunderstandings / misconceptions that I really didn't know where to start as far as a reply was concerned.  I felt that 'cr0sh' did a good job explaining many of my concerns and that is what I meant to get across.

I would like to address what you mentioned in Reply #7 since no one else has.
I'm looking more for a single DIP IC that I can program and play around with, and then solder the IC into a PCB with whatever else is required for the project and be able to go back and program it, in-curcuit (ICSP), not a platform like the Arduino Board or Freeduino.  -Joe

There is nothing about the Arduino that does not meet this criteria.  I know that some of the current UNO boards are using surface mount chips but this is supposedly a temporary matter.  The Arduino board and most of it's compatible relatives have a six pin ISP (ICSP) programming header.  If worse comes to worse you could always develop your program using one of the surface mount Arduino units and then program the debugged hex file into a DIP package using the ISP header.  (see below).

I think you may be calling the Arduino and the Freeduino a 'platform' because they both include the USB interface.  Several of the software compatible boards, the Bare Bones Board, the Boarduino and the Sippino for example, do not contain this interface which usually is extraneous after you have your program debugged.  All of these boards do have the ISP header and they are inexpensive enough to be considered in place of a board that you design and have built yourself.

Any of these boards along with an external programmer such as the AVRISPMK2 and the free AVR Studio 4 IDE, provide a means to program the ATMega328 in either C or assembly language.  You can always reload the bootloader via the ISP and use the Arduino IDE if you want.  I frequently bounce back and forth.




Here it is in assembly language, just the bare silicon.  It assembles to 60 bytes.

Code: [Select]
;           This is an assembly language version of the Arduino 'Blinky' sketch
.include "m168def.inc"

.equ    fclk                = 16000000      ; system clock frequency

; register usage
.def    temp                = R16           ; temporary storage

.equ    led_port            = PORTB         ; led connection
.equ    led_num             = PORTB5
.equ    led_ddr             = DDRB

; ***************************************************************************
.org    0x0000

; initialize the stack pointer to the highest RAM address
    ldi     temp,low(RAMEND)
    out     SPL,temp
    ldi     temp,high(RAMEND)
    out     SPH,temp

; configure the microprocessor pin for the led
    sbi     lED_ddr, lED_num                ; output

    sbi     led_port, led_num               ; turn LED on

    ldi     YL, low(1000)                   ; keep the led on for 1 second (1000 mS)
    ldi     YH, high(1000)
    call    delayYx1mS

    cbi     led_port, led_num               ; turn LED off

    ldi     YL, low(1000)                   ; keep the led off for 1 second (1000 mS)
    ldi     YH, high(1000)
    call    delayYx1mS

    rjmp    loop

; ============================== Time Delay Subroutines =====================
; this subroutine provides a delay of (YH:YL) x 1 mS
;   the 16-bit register provides for a delay of up to 65.535 Seconds
;   enter with:  (YH:YL) = delay data

    call   delay1mS                         ; delay for 1 mS
    sbiw    YH:YL, 1                        ; update the the delay counter
    brne    delayYx1mS                      ; counter is not zero

; arrive here when delay counter is zero (total delay period is finished)

; ---------------------------------------------------------------------------
; this subroutine provides a delay of 1 mS
;   it chews up fclk/1000 clock cycles (including the 'call')

    push    YL                              ; [2] preserve registers
    push    YH                              ; [2]
    ldi     YL, low (((fclk/1000)-18)/4)    ; [1] delay counter
    ldi     YH, high(((fclk/1000)-18)/4)    ; [1]

    sbiw    YH:YL, 1                        ; [2] update the the delay counter
    brne    delay1mS_01                     ; [2] delay counter is not zero

; arrive here when delay counter is zero
    pop     YH                              ; [2] restore registers
    pop     YL                              ; [2]
    ret                                     ; [4]

; ============================== End of Time Delay Subroutines ==============

This really isn't much different than your C version (aside from having to write the delay routine).

If the instructions in the loop are changed to to toggle the LED, rather than explicitly turn it on and off, it reduces to 50 bytes but you lose the ability to have different on/off times.

Code: [Select]
    sbi     led_pin, led_num                ; toggle led

    ldi     YL, low(1000)                   ; keep the led on or off for 1 second (1000 mS)
    ldi     YH, high(1000)
    call    delayYx1mS

    rjmp    loop


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131