• AVR Freaks

Hot!Writing to I2C EEPROM with MCC Support

Author
Wesley_88
New Member
  • Total Posts : 11
  • Reward points : 0
  • Joined: 2018/11/26 17:19:06
  • Location: 0
  • Status: offline
2019/10/30 12:18:10 (permalink)
0

Writing to I2C EEPROM with MCC Support

HI,

I am using MCC support for writing to an external I2C EEPROM.
Master is PIC18F47K42 and Slave is 24LC024H.
The i2c code generated by MCC is hard to understand
See MCC example code in attachment.
On top of that it seem to have some error on the MCC generated code that doesn't let me compile.  

on the code below, do anybody know what is "I2C_EEPROM_T * eepromInstance" and "ERR_STATUS_T *pstatus" for I am not sure what I should replace them with.

I2Cx_MasterWrite(I2C_EEPROM_T * eepromInstance, uint8_t *data, uint8_t size, uint8_t busAddress, ERR_STATUS_T *pstatus);

Thank you

Attached Image(s)

#1

7 Replies Related Threads

    katela
    Super Member
    • Total Posts : 1468
    • Reward points : 0
    • Joined: 2013/06/11 05:25:18
    • Location: South Africa
    • Status: offline
    Re: Writing to I2C EEPROM with MCC Support 2019/10/31 05:41:15 (permalink)
    +1 (1)
    There are some short descriptions in the I2C.h file how to use those functions. Here is an example: https://mplabxpress.micro...ud/example/details/519

    Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
    YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
    #2
    Mysil
    Super Member
    • Total Posts : 3488
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: Writing to I2C EEPROM with MCC Support 2019/10/31 10:45:28 (permalink)
    +1 (1)
    Duplicate thread, see
    https://www.microchip.com/forums/FindPost/1117059
     
        Mysil
    #3
    Wesley_88
    New Member
    • Total Posts : 11
    • Reward points : 0
    • Joined: 2018/11/26 17:19:06
    • Location: 0
    • Status: offline
    Re: Writing to I2C EEPROM with MCC Support 2019/10/31 12:01:41 (permalink)
    0
    Thank you for the link, but I believe the information is for the slave mode I2C. 
    For my application I need the master mode I2C.
     
    Initially I tried several attempt by using the typical I2C2 code that was generated by MCC for PIC18F47K42 to write to an external I2C EEPROM 24LC024H with the code below but no success
     
    i2c2_write1ByteRegister(uint8_t address, uint8_t reg, uint8_t data)
     
    I contacted the tech support and they told me by using the I2C EEPROM code generate by MCC below will work
     
    I2Cx_MasterWrite(I2C_EEPROM_T * eepromInstance, uint8_t *data, uint8_t size, uint8_t busAddress, ERR_STATUS_T *pstatus);
     
    But once I generate the code, there were 2 error being generated by MCC on the i2c_eeprom_app.c which I have no idea how to correct, and because of the error I was not able to compile the code.
    #4
    du00000001
    Just Some Member
    • Total Posts : 3244
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: online
    Re: Writing to I2C EEPROM with MCC Support 2019/10/31 14:53:48 (permalink)
    +3 (3)
    Would be nice if you provided the error texts instead of only ranting about these.
    post edited by du00000001 - 2019/11/05 12:56:23

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #5
    Wesley_88
    New Member
    • Total Posts : 11
    • Reward points : 0
    • Joined: 2018/11/26 17:19:06
    • Location: 0
    • Status: offline
    Re: Writing to I2C EEPROM with MCC Support 2019/11/05 10:24:49 (permalink)
    0
    What error texts do you want to see ? 
    I actually attached 2 picture showing the error generated by MCC on my original post on top. The errors occur on the i2c_eeprom.t and i2c_eeprom.c file
     
     
    #6
    du00000001
    Just Some Member
    • Total Posts : 3244
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: online
    Re: Writing to I2C EEPROM with MCC Support 2019/11/05 13:04:00 (permalink)
    0
    I would have loved to see some compiler error output, not some fancy hardcopies of MPLAB's screen.
    Anyway: if you did not configues I2C2, i2c2.h will not be available. Including all definitions contained within.
    And if the 2nd I2C isn't denominated I2C2 on the PIC18s, this would be another indication that the i2c_eeprom_app isn't targeting PIC18s.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #7
    Wesley_88
    New Member
    • Total Posts : 11
    • Reward points : 0
    • Joined: 2018/11/26 17:19:06
    • Location: 0
    • Status: offline
    Re: Writing to I2C EEPROM with MCC Support 2019/11/07 16:53:51 (permalink)
    0
    I finally resolve my own issue.
     
    Apparently, it is easier to use the below generic I2C command to write to an external EEPROM
     
    i2c1_write1ByteRegister(uint8_t address, uint8_t reg, uint8_t data);
     
    Previously it did not work because I enter one extra bit for the slave address. Instead of 7 bits, I included the last write bit and make it 8 bits.
     
    Thank you for everyone help. 
    #8
    Jump to:
    © 2019 APG vNext Commercial Version 4.5