1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Pic 18f45k22 i2c assembler code

Discussion in 'Microcontrollers' started by Emanuele77, Feb 24, 2018.

  1. Emanuele77

    Emanuele77 New Member

    Joined:
    Feb 24, 2018
    Messages:
    4
    Likes:
    0
    Hi to all,
    i need a simple assembler code to send/receive data with i2c module (in master mode) on pic18f45k22 .
    I have see application note AN735 but is old and written for Pic16 (can be ported to a pic18c...).

    Does any of you have a simple working example written in assembler to send and receive data in I2c?


    Thx
     
  2. granddad

    granddad Active Member

    Joined:
    Jan 18, 2015
    Messages:
    837
    Likes:
    89
    Location:
    Worcestershire UK
    Welcome to ETO Emanuele . I am wondering why assembler ? . PIC18 instruction set is optimised for C . The C code gets turned into asm and compiled to HEX . What you need is doable but I see no advantage ...
     
  3. atferrari

    atferrari Well-Known Member

    Joined:
    Oct 8, 2003
    Messages:
    2,901
    Likes:
    127
    Location:
    Buenos Aires - Argentina
    Nigel Goodwin, member here, has published a series of tutorials. One of them is precisely about I2C. It took me little time to implement two PICs linked through I2C.

    Now that I think of it, IIRC, it is done bit-banging style. I think I did it with a 18F as well but not sure.

    Sorry but my PC where all it is buried is defunct. No time to retrieve my data where my test is for the moment.
     
  4. dave miyares

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    2
    Likes:
    -10


     
  5. MaxHeadRoom78

    MaxHeadRoom78 Well-Known Member

    Joined:
    Jun 9, 2015
    Messages:
    1,030
    Likes:
    90
    Location:
    Canada Geog Cen of N.A.
    There is also AN989 for the 18F series.
    I did a version for the P18F2221 in assy.
    Also check out the MAXIM MAX517/518/519 IC spec sheet.
    Max.
     
    • Like Like x 1
  6. Emanuele77

    Emanuele77 New Member

    Joined:
    Feb 24, 2018
    Messages:
    4
    Likes:
    0
    Thanks to all Max Atferrari Granddad ....this site is a precious resource for a designer,
    now i will study on the basis of what you have suggested to me,
    Hi Granddad you're right but i have to modify a program entirely written in assembler and I did not want to redo everything in c.
     
  7. granddad

    granddad Active Member

    Joined:
    Jan 18, 2015
    Messages:
    837
    Likes:
    89
    Location:
    Worcestershire UK
    I see now... best of luck with that . I usually cannot fathom my own previous / old asm ....
     
  8. dave miyares

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    2
    Likes:
    -10


     
  9. Emanuele77

    Emanuele77 New Member

    Joined:
    Feb 24, 2018
    Messages:
    4
    Likes:
    0
    I design machines in esthetics field,
    i tend to use the microcontrollers and the programming modes i already know, already tested even if in assembler.
    I realize that it is wrong but many times there is little time for design and venturing with another processor or programming mode can be risky.
    I am currently trying to learn stm32f429i-disk1 in C \ C ++ maybe i still need your help thanks to all.
     
  10. Emanuele77

    Emanuele77 New Member

    Joined:
    Feb 24, 2018
    Messages:
    4
    Likes:
    0
    Thanks to everyone in particular to Max with the application note 989 i2c bus works correctly.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice