Newbie to electronics circuit confused

Discussion in 'General Electronics Chat' started by bakhtal, Aug 13, 2015.

  1. bakhtal

    Thread Starter New Member

    Aug 13, 2015
    9
    1
    hi,

    i am soldering my circuit which has Atemga 162 IC , in circuit diagram there are pin numbers 41,42,43,44 which is confusing part as in original datasheet of IC these pin do not exist.

    i have programed the IC with flash hex file my question is whether pin numbers/sequence can get change from flash or program running inside IC ?

    do i need to follow pin numbers as mentioned in diagram or should i follow function of pin like (PB0... RESET..) as you can see RESET in Diagram is mentioned at pin number 4 while in original datasheet its at pin number 9.

    [​IMG]

    [​IMG]

    sorry for my ignorance am really confuse at this point i am attaching 2 photos please have a look and point me correct pin numbers or functions of pin to solder.
     
  2. DerStrom8

    Well-Known Member

    Feb 20, 2011
    2,428
    1,328
  3. bakhtal

    Thread Starter New Member

    Aug 13, 2015
    9
    1
    Oh my God :(
    In Circuit Diagram ATmega162L-8AI has been used (44 pins just found on net)

    while i have got and soldered ATMEGA162-16PU which has 40 pins 20 on each side.

    i have also programed ATMEGA162-16PU with flash hex file made for ATmega162L-8AI , i am unable to find exact same ATmega162L-8AI IC for my circuit, is it possible i make use of my current IC ATMEGA162-16PU ?

    what if i ignor pin numbers and connect my wires using pin functions like RESET is at pin number 9 in current IC, it wont make any damage right ?
     
    Last edited: Aug 13, 2015
  4. bakhtal

    Thread Starter New Member

    Aug 13, 2015
    9
    1
    Can i use ATMEGA162-16PU instead of ATmega162L-8AI ?

    ATMEGA162-16PU programed with flash hex file that is compiled for ATmega162L-8AI does this make difference ?

    can i solder according pin functionality ? ignoring pin numbers ...?
     
  5. DerStrom8

    Well-Known Member

    Feb 20, 2011
    2,428
    1,328
    Yes, you can go by pin functions rather than pin numbers. However, the programming will probably need to be different. Does the hex code you burned to the 40-pin DIP version work? Have you been able to test it yet? You may need to edit the code before loading it onto the chip.

    The ATMEGA162L-8AI is a surface mount chip that is difficult to prototype with. If you can edit your code to work on the -16PU, then you should be good to go :)

    Matt
     
  6. bakhtal

    Thread Starter New Member

    Aug 13, 2015
    9
    1
    hi,

    i just solder -16PU according to pin functions but its not functioning as correctly, i have source code (for ATMEGA162L-8AI) if you guys can plz edit it for ATMEGA162-16PU i will really appreciate ... soldering 16PU is easy as 8AI got too small pins and i am unable to find it from stores.

    Here is Original Circuit:

    [​IMG]


    Following is the code sorry i am unable to attach as file;


    Code (Text):
    1.  
    2. ;// set AVR M162 fuses SUT1,SUT0,CKSEL3,CKSEL2,CKSEL0 and set BODLevel2
    3. ;// Fast Startup Time - Internal Clock 8MHz and BOD set level for 2.3v
    4. ;// Remember to set fuses = 0
    5. ;// UART 0 is to read CAM data goimg to CARD  Boot ATR is 12100 and Data after is 100 000 BAUD
    6. ;// Data flow is Inverted and Byte is sent MSBit first - also data MUST be checked for FRAME errors
    7.  
    8. ;BAUD rate finding by changing UBBRL
    9. ;ATR= 3F FF 14 25 03 10  80  41 B0 02 69 FF 4A 50 70 80 00 58 38 01 00  14
    10. ;95 = FE FF 18 2B 06 01 FF 81 FF 42 A1 05 62 FE 45 40 61 81 00 51 31 03 00 FF 18
    11. ;92 = FE FF 10 27 02 11 FF 81 FF 40 B1 03 6A FE 49 50 71 81 00 59 39 01 00 FF 14
    12. ;90 = FF FF 14 25 03 10 FF 80 FF 41 B0 02 69 FF 4A 50 70 80 00 58 38 01 00 FF 14
    13. ;89 = FF FF 14 25 03 10 FF 80 FF 41 B0 02 69 FF 4A 50 70 80 00 58 38 01 00 FF 14
    14. ;88 = FF FF 14 25 03 10 FF 80 FF 41 B0 02 69 FF 4A 50 70 80 00 58 38 01 00 FF 14
    15. ;87 = FF FF 14 25 03 10 FF 80 FF 41 B0 02 69 FF 4A 50 70 80 00 58 38 01 00 FF 14
    16. ;86 = FF FF 14 25 03 10 FF 80 FF 41 B0 02 69 FF 4A 50 70 80 00 58 38 01 00 FF 14
    17. ;85 = FF FF 14 25 03 10 FF 80 FF 41 B0 02 69 FF 4A 50 70 80 00 58 38 01 00 FF 14
    18. ;83 = FF FF 14 25 03 10 FF 80 FF 41 B0 02 69 FF 4A 50 70 80 00 58 38 01 00 FF 14
    19. ;82 = FF FF 14 25 03 10 FF 80 FF 41 B0 02 69 FF 4A 50 70 80 00 58 38 01 00 FF 14
    20. ;80 = FF FF 14 24 01 10 3F 80 3F 40 B0 04 40 A6 FF 49 06 00 70 07 06 58 04 C4 00
    21. ;seems best is 87 averaged  now to play with Stop bits and Parity
    22.  
    23. ;// UART 1 is to send out code at 115200 to PC for logging software
    24.  
    25.  
    26.  
    27.  
    28.    .include "m162def.inc"
    29.  
    30.  
    31.  
    32.  
    33. .cseg
    34. .org 0
    35.    jmp   RESET      ; Reset Handler
    36.  
    37.  
    38. RESET:  
    39.    ldi   r16,high(RAMEND); Main program start
    40.    out   SPH,r16    ; Set Stack Pointer to top of RAM
    41.    ldi   r16,low(RAMEND)
    42.    out   SPL,r16
    43.  
    44. ;// Logging CAM Data line
    45. ;// UART must be set using x2 clock for better accuracy
    46. ;// Read Data Line
    47. USART_Init0:       ;CAM UART
    48.    ldi   r16,(1<<U2X0)   ;Set x2
    49.    out   UCSR0A,r16
    50.    ldi   r17,0     ;Set baud rate
    51.    ldi   r16,87     ;ATR is 12100  87  82 @ 8HMZ  164 @ 16MHz
    52.    out   UBRR0H, r17
    53.    out   UBRR0L, r16
    54.    ldi   r16, (1<<RXEN0)|(0<<TXEN0)
    55.    out   UCSR0B,r16   ; Enable receiver and transmitter
    56.    ldi   r16,(1<<URSEL0)|(1<<UPM01)|(0<<UPM00)|(0<<USBS0)|(1<<UCSZ01)|(1<<UCSZ00)  ;8E1
    57.    out   UCSR0C,r16   ; Set frame format: 8data,even Parity, 1stop bit
    58.  
    59. ;// UART must be set using x2 clock for better accuracy
    60. ;// Send to PC @ 115200 error 2,12%
    61. USART_Init1:
    62.    ldi   r16,(1<<U2X0)   ;Set x2
    63.    out   UCSR1A,r16
    64.    ldi   r17,0     ;Set baud rate
    65.    ldi   r16,8     ;115 200  8 @ 8MHz  16 @ 16MHz
    66.    out   UBRR1H, r17
    67.    out   UBRR1L, r16
    68.    ldi   r16, (0<<RXEN1)|(1<<TXEN1)
    69.    out   UCSR1B,r16   ; Enable receiver and transmitter
    70.    ldi   r16,(1<<URSEL1)|(1<<UCSZ11)|(1<<UCSZ10)  ;|(0<<USBS)
    71.    out   UCSR1C,r16   ; Set frame format: 8data, 1stop bit
    72.  
    73.    ; Read 22 bytes ATR
    74. wait_3F:
    75.    ; Wait for data to be received
    76.    sbis    UCSR0A, RXC0
    77.    rjmp    wait_3F
    78.    ; Get and return received data from buffer
    79.    in    r16, UDR0
    80.    ; need to rotate and invert byte
    81.    ; 8 bits rotate
    82.    ldi   r19,8
    83. Rotate1:ror   r16
    84.    rol   r17
    85.    dec   r19
    86.    brne   rotate1
    87.    ; invert byte
    88.    com   r17
    89.    cpi   r17,0x3f
    90.    brne    wait_3F
    91.    ldi   r18,22
    92.    rjmp   stor
    93.  
    94. main_uart:
    95. USART_Receive:
    96.    ; Wait for data to be received
    97.    sbis    UCSR0A, RXC0
    98.    rjmp    USART_Receive
    99.    ; Check for Frame Errors
    100. frame:   sbis   UCSR0A, FE0
    101.    rjmp   read
    102.    in    r16, UDR0     ;DUMMY Read to clear FE Flag
    103.    rjmp   USART_Receive
    104.  
    105.    ; Get and return received data from buffer
    106. read:   in    r16, UDR0
    107.  
    108.    ; need to rotate and invert byte
    109.    ; 8 bits rotate
    110.    ldi   r19,8
    111. Rotate:   ror   r16
    112.    rol   r17
    113.    dec   r19
    114.    brne   rotate
    115.    ; invert byte
    116.    com   r17
    117.  
    118. stor:
    119. USART_Transmit:
    120.    ; Wait for empty transmit buffer
    121.    sbis    UCSR1A,UDRE1
    122.    rjmp    USART_Transmit
    123.    out    UDR1,r17
    124.    dec   r18
    125.    brne   main_uart
    126.  
    127.  
    128.  
    129. // Now to switch to 100 000  BAUD for CAM DATA and byte for byte XMIT
    130. UART0_100:
    131.    ldi   r17,0     ;Set baud rate
    132.    ldi   r16,10     ;Data is 100 000 Baud @ 4.5MHz is 9
    133.    out   UBRR0H, r17
    134.    out   UBRR0L, r16
    135.  
    136.  
    137. new_data:
    138. ; Wait for data to be received
    139.    sbis    UCSR0A, RXC0
    140.    rjmp    new_data
    141.    ; Check for Frame Errors
    142. frame100:
    143.    sbis   UCSR0A, FE0
    144.    rjmp   read100
    145.    in    r16, UDR0     ;DUMMY Read to clear FE Flag
    146.    rjmp   new_data
    147.  
    148.    ; Get and return received data from buffer
    149. read100:
    150.    in    r16, UDR0
    151.  
    152.    ; need to rotate and invert byte
    153.    ; 8 bits rotate
    154.    ldi   r19,8
    155. Rotate_100:
    156.    ror   r16
    157.    rol   r17
    158.    dec   r19
    159.    brne   rotate_100
    160.    ; invert byte
    161.    com   r17
    162.  
    163. ; Wait for empty transmit buffer
    164. xmit_100:
    165.    sbis    UCSR1A,UDRE1
    166.    rjmp    xmit_100
    167.    out    UDR1,r17
    168.  
    169.    rjmp   new_data
    170. [\code]
     
    Last edited: Aug 13, 2015
  7. bakhtal

    Thread Starter New Member

    Aug 13, 2015
    9
    1
    hi,

    Can somebody please edit source code ?

    This source code is written for: ATMEGA162L-8AI

    While i have got ATMEGA162-16PU :( i want to use ATMEGA162-16PU in my circuit as i am unable to find 8AI model IC.
     
  8. DerStrom8

    Well-Known Member

    Feb 20, 2011
    2,428
    1,328
    Why can't you edit it? Did you copy and paste the code from someone else? If you're going to work with microcontrollers, I recommend you learn how to program them yourself. That's part of the process, otherwise you'll frequently find yourself lost, as you seem to be at the moment. It's not fun :p
     
  9. bakhtal

    Thread Starter New Member

    Aug 13, 2015
    9
    1
    hi,

    sorry for my ignorance i am just a hobbyist and newbie to micro-controllers , i did not copy someone else code rather i downloaded it form internet along with circuit , i don't know assembly language that's why i can not find pins and register in this code to modify :(
     
  10. blocco a spirale

    AAC Fanatic!

    Jun 18, 2008
    1,438
    368
    How does "downloaded it from the internet" differ from "copy" ?o_O

    The problem is, there can be quite a lot of work involved in this kind of thing and anyone who gets involved would have to be prepared to bat it back and forth (unless they also build the hardware) until the bugs are fixed and I doubt anyone wants to do that.
     
    DerStrom8 and absf like this.
  11. bakhtal

    Thread Starter New Member

    Aug 13, 2015
    9
    1
    oh ok , i thought it might be minor editing , i though just replace pin number or address in code :?

    anyway thanks for helping and pointing in right direction, i guess i must find exact same type of IC.

    You guys are great , really appreciate your help thanks again.

    have a good day.
     
  12. DerStrom8

    Well-Known Member

    Feb 20, 2011
    2,428
    1,328
    Instead of trying to find the surface mount version of the microcontroller (difficult to prototype with, solder, etc) you should learn Assembly language so that you can program your DIP version.. That was my point--if you're going to work with microcontrollers, you'll need to learn how to program them yourself sooner or later. May as well start now.

    And for the record, copying from the internet = copying someone else's code. They had to put it on the internet themselves, after all.
     
    bakhtal likes this.
  13. bakhtal

    Thread Starter New Member

    Aug 13, 2015
    9
    1
    OK thanks will try to do so ...

    Regards
     
  14. DerStrom8

    Well-Known Member

    Feb 20, 2011
    2,428
    1,328
    Just remember that there are lots of people here who are experienced with Assembly who would be very happy to help you learn. It takes a bit of time, but it's worth it! :)

    Good luck,
    Matt
     
  15. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,494
    2,364
    In all probability it is simple, obtain the reference man for both IC's and also compare the instruction set, I don't use ATMEL μp's but looking at the numbers I would think they are Very close most ways.
    Max.
     
  16. bakhtal

    Thread Starter New Member

    Aug 13, 2015
    9
    1
    OK thanks for suggestions , i start learning assembly basics , code and instructions , will post my findings later.

    Regards
     
    absf likes this.
  17. absf

    Senior Member

    Dec 29, 2010
    1,490
    371
    I like that positive attitude...

    ALlen
     
    DerStrom8 likes this.
Loading...