• AVR Freaks

PIC18 I2C library

Starting Member
  • Total Posts : 35
  • Reward points : 0
  • Joined: 2006/04/12 21:38:57
  • Location: 0
  • Status: offline
2015/08/11 08:10:26 (permalink)

PIC18 I2C library

There is a PIC18 library with I2C functions, and i2c.h file.
But the documentation in the i2c.h file is very poor.
For example: "void OpenI2C2(  unsigned char sync_mode,  unsigned char slew );" there is no explanation what are the legal values for "sync_mode" and "slew".
And it doesn't say what are the minimum functions that must be used (Open + Write/Read + Close ?).
Is there any documentation that can help?

2 Replies Related Threads

    Jo, alla!
    • Total Posts : 6806
    • Reward points : 0
    • Joined: 2007/10/15 00:51:49
    • Location: Germany
    • Status: offline
    Re: PIC18 I2C library 2015/08/11 08:19:18 (permalink)
    +1 (2)
    Have a look into the docs folder of ?your compilers? installation directory.

    Uffbasse !
    Super Member
    • Total Posts : 3330
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: PIC18 I2C library 2015/08/11 09:31:44 (permalink)
    0 (1)
    The OpenI2C2(...) family of functions are parts of plib peripheral libraries that up until now have been distributed together with XC8 compiler. 
    There are some examples using these functions in some example collections, 
    but most I2C Plib examples shown by Microchip are very simplistic demo code in blocking and standalone configurations without error handling nor recovery.
    There have been several examples and libraries contributed in forum contributions.
    For documentation, there exists a  MPLAB_XC8_peripheral_libraries.pdf in a subdirectory of the compiler installation,
    but it seem to contain a lot of headlines and no real information.
    Comments in source code and header files seem to be the most relevant information.
    For understanding "sync_mode" and "slew" arguments, the most useful approach might be to follow what settings the code do in SFR registers, and study device datasheet for the PIC18 device you are actually using, MSSP I2C chapter.
    As I understand, Plib code is going to be separated from compiler distribution in the future, 
    and may be distributed as a separate installation, but may also be retired from further development.
    Instead MCC, Microchip Code Configurator, is more probably the focus of I2C development and support.
    It already contain the makings of a interrupt driven I2C driver that may perform non-blocking operations,
    that work so far for my purpose, but as far as I have seen still have room for improvement.
    post edited by Mysil - 2015/08/11 09:54:20
    Jump to:
    © 2019 APG vNext Commercial Version 4.5