I2C command with 16F88


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Jul 2005
    Posts
    5

    Default I2C command with 16F88

    I have a PIC16F88 with port B pin1 as SDA and port B pin 4 as SCL. It runs on 20 Mhz crystal and has SDA only pulled to +5V via 10K resistor. I was using Pic Basic and successfully compiled and ran a program that accessed bytes from a 24LC256 EEprom.

    Then I wanted to experience life after 2K, as they all say.. so I purchased and upgraded to Pic Basic PRO. I made changes throughout the program and got all working except for I2C commands. So here are the essential details of my attempt :

    Line of code in question:
    I2cread portb.1, portb.4, %11010000, EEP_Addr, [EEP_Data]

    I have also tried using "DEFINE I2C SLOW 1", "DEFINE I2SCLOUT 1", adding a pullup resistor to SCL line and using 4Mhz crystal instead of 20Mhz..

    It used to work!! so it must be possible, does anyone have any pointers for me here?

    Thanks!

  2. #2
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    ...It used to work!!
    I doubt it has ever worked with that line of code.

    There are several things:

    1.
    The 24LC256's address (control-byte) (with A0, A1, and A2 tied to GND)
    is: %10100000, NOT %11010000
    (See DataSheet)

    2.
    your variable "EEP_Addr" must be declared as WORD
    (See DataSheet)

    3.
    you should have 4k7 PullUps on both SDA, and SCL
    (10k might be a bit to high)
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  3. #3
    Join Date
    Jul 2005
    Posts
    5


    Did you find this post helpful? Yes | No

    Default ..and it continues to work!

    Thanks Ralph,

    I think you pretty much pin pointed the problem with my code. I've done as you suggested and now it works.. even with the 20 Mhz crystal and no need for any define commands at the beginning of the program.

    cheers,

    Damiko

  4. #4
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Damiko,

    I'm glad to hear you have got it working now!
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



Similar Threads

  1. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 22:31
  2. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  3. Another I2C Slave Routine Problem
    By DanPBP in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th February 2009, 05:50
  4. I2C Master Slave issues.
    By cpayne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2008, 19:33
  5. Please help with i2cslave i2c slave
    By cycle_girl in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st December 2005, 13:55

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts