Arduino Nano Template

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey guys,

maybe some of you would like to use this Arduino Nano template!:-)

 

Chip: ATmega328P

;    Arduino Nano Pinout
;                                                 ___ISP___
;  TXD, PCINT17, PD1, 31, TX    -|    ooo     |-VIN
;  RXD, PCINT16, PD0, 30, RX    -|    ooo     |-GND
;  PCINT15, PC6, 29, RESET      -|               |-RESET, 29, PC6, PCINT15
;                           GND              -|               |- +5V
;            INT0, PCINT18,PD2,32 -|              |-ADC7, 22
;   INT1,OC2B, PCINT19, PD3, 1-|              |-ADC6, 19
;         XCK,T0, PCINT20, PD4, 2-|      3      |-ADC5, 28, PC5, PCINT13, SCL
;       T1,OC0B PCINT21, PD5, 9-|      2      |-ADC4, 27, PC4, PCINT12, SDA
;AIN0,OC0A, PCINT22, PD6, 10-|      8      |-ADC3, 26, PC3, PCINT11
;          AIN1, PCINT23, PD7, 11-|      P      |-ADC2, 25, PC2, PCINT10
;   ICP1,CLK0, PCINT0, PB0, 12-|              |-ADC1, 24, PC1, PCINT9
;           OC1A, PCINT1, PB1, 13-|              |-ADC0, 23, PC0, PCINT8
;     SS, OC1B, PCINT2, PB2, 14-|              |-AREF, 20
; MOSI, OC2A, PCINT3, PB3, 15-|              |- +3,3V
; MISO, OC1A, PCINT4, PB4, 16-|              |-17, PB5, PCINT5, SCK, In-Board L-LED
;                                                  |  USB   |
;                                                  |-       +|
;
;Builtin Leds:
;    RX(D0, Green) and TX(D1, Red) shine when held low
;    L(PB5, Red) shines when held high

 

.CSEG

.ORG 0x0000
        jmp  RESET_vect        ;Reset-Vektor =RESET_vect                          
        reti  nop         ;External Interrupt Request 0 =INT0_vect
        reti  nop         ;External Interrupt Request 1 =INT1_vect
        reti  nop         ;Pin Change Interrupt Request 0 =PCINT0_vect
        reti  nop         ;Pin Change Interrupt Request 1 =PCINT1_vect
        reti  nop         ;Pin Change Interrupt Request 2 =PCINT2_vect
        reti  nop         ;Watchdog Timer-out Interrupt =WDT_vect
        reti  nop         ;Timer/Counter2 Compare Match A =TIMER2_COMPA_vect
        reti  nop         ;Timer/Counter2 Compare Match B =TIMER2_COMPB_vect     
        reti  nop         ;Timer/Counter2 Overflow =TIMER2_OVF_vect     
        reti  nop         ;Timer/Counter1 Capture Event =TIMER1_CAPT_vect    
        reti  nop         ;Timer/Counter1 Compare Match A =TIMER1_COMPA_vect
        reti  nop         ;Timer/Counter1 Compare Match B =TIMER1_COMPB_vect     
        reti  nop         ;Timer/Counter1 Overflow =TIMER1_OVF_vect
        reti  nop         ;Timer/Counter0 Compare Match A =TIMER0_COMPA_vect
        reti  nop         ;Timer/Counter0 Compare Match B =TIMER0_COMPB_vect
        reti  nop         ;Timer/Counter0 Overflow =TIMER0_OVF_vect
        reti  nop         ;SPI Serial Transfer Complete =SPI_STC_vect
        reti  nop         ;USART Rx Complete =USART_RX_vect
        reti  nop         ;USART Data Register Empty =USART_UDRE_vect    
        reti  nop         ;USART Tx Complete =USART_TX_vect    
        reti  nop         ;ADC Conversion Complete =ADC_vect    
        reti  nop         ;EEPROM Ready =EE_READY_vect
        reti  nop         ;Analog Comparator =ANALOG_COMP_vect
        reti  nop         ;Two-wire Serial Interface     
        reti  nop         ;Store Program Memory Read =SPM_READY_vect

 

RESET_vect:

Last Edited: Wed. Feb 12, 2020 - 09:13 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

See Tip #1 for how to properly post source code - and other formatted text which relies upon a mono-spaced font.

 

(in my signature, below; may not be visible on mobile)

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

hello,

  Your top part looks OK, but it doesn't line up with any font that I select in MS Word.  What font are you using?

 

The bottom part is the interrupt vector table for a ATmega328 {any version} that would be used in assembly language programming.

But it is not right.  Each vector is two 16-bit words in size, so you should use    jmp  Reset_Vector   instead of:   rjmp.   The RJMP instruction has only a limited range, but the JMP accesses the full 64K 16-bit address range of the program memory space.   And you should use:   reti  nop    on the other vector lines because RETI is only one word in size, and the vector is two words.  The NOP instruction is one 16-bit word also.

 

Actuall

Last Edited: Wed. Feb 12, 2020 - 09:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta wrote:
it doesn't line up

Possibly due to use of TABs?

 

OP needs to re-post using the proper format - see #2.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh, thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah it's because of the use of tabs.

 

I don't see how #2 could fix the problem.:]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Have you tried?

 

If you paste your original into the code editor - as described in Tip #1 - does it look OK ?

 

If not, then you're going to have to prepare it first - any decent text editor should be able to translate TABs to spaces - and then post a "code" ...

 

EDIT

 

It doesn't even work in Notepad:

 

So your first step is to get that working ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. Feb 12, 2020 - 09:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Something like this:

 

;                                             _____ISP______
; TXD,            PCINT17, PD1, 31, TX      -|      ooo     |-VIN
; RXD,            PCINT16, PD0, 30, RX      -|      ooo     |-GND
;                 PCINT15, PC6, 29, RESET   -|              |-RESET,    29, PC6, PCINT15
; GND                                       -|              |- +5V
; INT0,           PCINT18, PD2,           32-|              |-ADC7,     22
; INT1,     OC2B, PCINT19, PD3,            1-|              |-ADC6,     19
; XCK, T0,        PCINT20, PD4,            2-|      3       |-ADC5,     28, PC5, PCINT13, SCL
; T1,       OC0B  PCINT21, PD5,            9-|      2       |-ADC4,     27, PC4, PCINT12, SDA
; AIN0,     OC0A, PCINT22, PD6,           10-|      8       |-ADC3,     26, PC3, PCINT11
; AIN1,           PCINT23, PD7,           11-|      P       |-ADC2,     25, PC2, PCINT10
; ICP1,CLK0,      PCINT0,  PB0,           12-|              |-ADC1,     24, PC1, PCINT9
;           OC1A, PCINT1,  PB1,           13-|              |-ADC0,     23, PC0, PCINT8
; SS,       OC1B, PCINT2,  PB2,           14-|              |-AREF,     20
; MOSI,     OC2A, PCINT3,  PB3,           15-|              |- +3,3V
; MISO,     OC1A, PCINT4,  PB4,           16-|              |-17,           PB5, PCINT5, SCK, In-Board L-LED
;                                            |  USB         |
;                                            |-            +|
;

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

.org to the vectors!