PIC16F690 - 24LC08B: they won't talk...


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    First things at first look.

    1. You set your OSC at 8Mhz. This is for your PIC. You must DEFINE OSC speed to the compiler also. Have DEFINE OSC 8.

    2. For PIC16F690, SDA should be RB4 and SCL should be RB6.
    hi.

    why rb4 and rb6? i thought i2cwrite was 'bit banging' and it did not matter on which pin it is used???

    i'm not using hardware i2c support. then is my connexion still wrong?

  2. #2
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default i2cwite not writing... some ideas...

    Sayzer,

    There IS a
    DEFINE OSC 8
    in my program, i just forgot to paste it...

    Here are some things i will have to check/do:

    - solder a 8 pins socket on a protoboard instead of breadboard and solder connexions

    - use 2k wpu only on sda instead of a 4.7k wpu on each scl and sda

    - swap with another pic16f690 in case the one i use is defect

    - swap with another 24lc08b in case the one i use is defect

    - try a huge pause 50 instead of pause 5 after the i2cwrite in case it is a timing problem

    - declare the eeprom address variable as a word instead of as a byte

    - declare "eep_address" instead of "ep_address" (i wonder how i didn't see this typing error!)

    - try to program a specific value in byte 0 of the eeprom using my pic-pg2 programmer and see if i get this value back with an i2cread

    besides this i don't se what i can do...

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xnihilo View Post
    - declare the eeprom address variable as a word instead of as a byte
    See pages 7 and 10 of this datasheet:
    http://ww1.microchip.com/downloads/e...Doc/21710H.pdf

    EDIT: I get the feeling that you're doing a lot of 'thinking out loud' and not a lot of 'doing' (as indicated by the post below).
    Not a good way to go about things...
    Last edited by skimask; - 22nd May 2008 at 14:18.

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xnihilo View Post
    Sayzer,

    There IS a
    DEFINE OSC 8
    in my program, i just forgot to paste it...

    Here are some things i will have to check/do:

    - solder a 8 pins socket on a protoboard instead of breadboard and solder connexions

    - use 2k wpu only on sda instead of a 4.7k wpu on each scl and sda

    - swap with another pic16f690 in case the one i use is defect

    - swap with another 24lc08b in case the one i use is defect

    - try a huge pause 50 instead of pause 5 after the i2cwrite in case it is a timing problem

    - declare the eeprom address variable as a word instead of as a byte

    - declare "eep_address" instead of "ep_address" (i wonder how i didn't see this typing error!)

    - try to program a specific value in byte 0 of the eeprom using my pic-pg2 programmer and see if i get this value back with an i2cread

    besides this i don't se what i can do...

    How did you NOT get an error then?

    Also, when you change your code after you asked some questions about it, it is difficult to follow.

    Paste a new one with your modifications, so that we can see what the difference was.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  5. #5
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    "ep_address" instead of "eep_address" didn't generate an error because it is a paste error only. I selected the block starting from the 2nd chara of the line, so it is alright, the variable name is right.

    I changed slightly the code:

    eep_address VAR WORD
    instead of BYTE

    and:

    I added:

    ADCON0.0 = 0 'turn adcon off


    Things I wanted to do:

    - solder a 8 pins socket on a protoboard instead of breadboard and solder connexions
    -> DONE

    - use 2k wpu only on sda instead of a 4.7k wpu on each scl and sda
    -> DONE, but I used 2K on each of the SCL and SDA pins

    - swap with another pic16f690 in case the one i use is defect
    -> DONE

    - swap with another 24lc08b in case the one i use is defect
    -> DONE

    - try a huge pause 50 instead of pause 5 after the i2cwrite in case it is a timing problem
    -> DONE

    - declare the eeprom address variable as a word instead of as a byte
    ->DONE

    - declare "eep_address" instead of "ep_address" (i wonder how i didn't see this typing error!)
    -> DONE, no error there in fact

    code is:

    Code:
        'routine that checks if the external eeprom (the mag) is connected to the supplier
        'it writes than reads back the test value (33)
        checkwrite = 33
        eep_address = 0     'use storage byte 1 of 255 fo rthe test
        
        LCDOUT $fe,1,"CTRLbyte:",#eep_control
        PAUSE 2000
        
        I2CWRITE PORTC.6,PORTC.7,eep_control,eep_address,[checkwrite]    'store maxitem value in the mag external EEPROM
        PAUSE 50        'hadware dependent
        
        LCDOUT $FE,1,"Wrote:",#checkwrite,"@",#eep_address
        PAUSE 2000
        
        I2CREAD PORTC.6,PORTC.7,eep_control,eep_address,[checkwrite]    'store maxitem value in the mag external EEPROM
        
        LCDOUT $fe,1,"Read:",#checkwrite,"@",#eep_address
        PAUSE 2000
        
        IF (checkwrite != 33) then
            LCDOUT $fe,1,"couldn't write"
            PAUSE 4000
            checkwrite = 0
            GOTO endofroutine
        ENDIF
        checkwrite = 66

    ----------------------


    RESULTS:

    The output on LCD is:

    "wrote:33@0"
    "read:0@0"
    "couldn'twrite"


    So, back to the starting point but this time I have no idea what I could change.
    Is it the wires length? Did I failed to set some registers? ...
    I'm lost... And angry.
    My circuit is useless if I can't write to external eeprom...
    Last edited by xnihilo; - 22nd May 2008 at 20:58.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    And pin 7 on the eeprom is connected to _______________

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    EEP_ADDRESS MUST be a byte... Something change in the ControlByte when you want to access the other EEPROM Page (Banks). Page 6 of the above data sheet

    One more, you haven't disable AN<9:8> yet, and it's your I2C lines... check ANSELH settings.... probably THE MAIN reason why you always have 00 as results. If it was the WP pin of the EEPROM, you would probably have FF all the time. if the device is already blank.
    Last edited by mister_e; - 23rd May 2008 at 00:22.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    EEP_ADDRESS MUST be a byte... Something change in the ControlByte when you want to access the other EEPROM Page (Banks). Page 6 of the above data sheet
    Yep, sure enough... Figured Microchip should know better than to place 'WORD' above those on page 7 and 10...and the 'sheet even shows 8 bit slots in the diagram...

  9. #9
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    And pin 7 on the eeprom is connected to _______________
    to gnd of course. i do not want to write protect the chip.

Similar Threads

  1. PIC16F690 code help please
    By hysteria92 in forum mel PIC BASIC
    Replies: 1
    Last Post: - 24th February 2010, 16:17
  2. PIC16f690 LCD Not Working
    By hhosteam in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 3rd June 2009, 06:26
  3. Replies: 1
    Last Post: - 19th February 2009, 13:35
  4. Replies: 0
    Last Post: - 13th February 2009, 03:34
  5. gps rikaline x5 to pic16f690
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 9th May 2008, 11:21

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