+ Reply to Thread
Results 1 to 10 of 10

Thread: I2CRead problem

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,748

    Default I2CRead problem

    Very strange problem.

    Executing an I2CRead command does only I2CWrite as it is shown on the Logic capture.

    This is my test code for an 24C64 EEPROM

    Code:
    DEFINE I2C_SLOW 1
    b1  var byte
    b2  var byte
    addr VAR word
    cont CON %10100000
    data_pin  var porte.0
    clk_pin     var porte.1
    
    addr = 0
    ' Read data at address 0 into B1,B2
    I2CREAD data_pin,clk_pin,cont,addr,[b1,b2]
    stop
    Any ideas?

    Ioannis
    Attached Images Attached Images

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,489

    Default Re: I2CRead problem

    can we see the whole transaction , an i2c read needs to do a write to set address and then a restart to read . you have not shown enough
    This is more entertaining than Free to Air TV

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,748

    Default Re: I2CRead problem

    Thank you Richard. Will do that this evening.

    I tried byte read, word read, page read, Nothing works and all var's are just a zero.

    The chip is a 16F1939 but I am sure this does not matter. Logic analyzer shows I2C activity either way.

    Edit:

    OK, now that is weird. On a 45K22 works just fine. On 1939 not...

    Ioannis
    Last edited by Ioannis; - 18th October 2018 at 13:22.

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,748

    Default Re: I2CRead problem

    I am very embarrassed...

    I forgot completely ANSELD and ANSELE when testing it...

    Ioannis

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    1,489

    Default Re: I2CRead problem

    I forgot completely ANSELD

    Another good reason to migrate to xc8 , mcc gives all pin settings/names and function in one easy to use screen
    Attached Images Attached Images
    This is more entertaining than Free to Air TV

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,748

    Default Re: I2CRead problem

    It is not easy to me. I detest C lanquage. Despite my efforts so far, I did not managed to flip over.

    It looks very cryptic...

    Ioannis

  7. #7
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,157

    Default Re: I2CRead problem

    Using ready-to-use tools to adjust the registers as we need, kills our ability of playing with them, and lowers the understanding of the hardware registers.

    Manual setting as much as possible is a good way of self developing, I think.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    1,489

    Default Re: I2CRead problem

    Using ready-to-use tools to adjust the registers as we need, kills our ability of playing with them, and lowers the understanding of the hardware registers.
    setting pin function is pic 101 stuff , but essential to get correct .not much programming skill in there once a basic understanding is reached

    Manual setting as much as possible is a good way of self developing, I think.

    would you not use dt_ints or PicMultiCalc
    if there's a good tool use it ,I think
    This is more entertaining than Free to Air TV

  9. #9
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,748

    Default Re: I2CRead problem

    Fuses and the like are a pain. So many new options on the recent chips. I hate it as I loose too much time from the programming itself, on figuring out how to set up a new (or older) chip.

    All these settings are getting more and more complex. A tool such as MCC is great but needs C understanding I suppose. Or maybe to that extend to get the fuses and then return to PBP?

    Ioannis

  10. #10
    Join Date
    May 2013
    Location
    australia
    Posts
    1,489

    Default Re: I2CRead problem

    the mcc generated pin file can very easily slot into pbp
    just cut out the comments and the c bits you don't need load replace all the 0x with $

    Code:
    /**
       Generated Pin Manager File
      
       Company:
         Microchip Technology Inc.
      
       File Name:
         pin_manager.c
      
       Summary:
         This is the Pin Manager file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
      
       Description:
         This header file provides implementations for pin APIs for all pins selected in the GUI.
         Generation Information :
             Product Revision  :  PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
             Device            :  PIC18F26K42
             Driver Version    :  2.01
         The generated drivers are tested against the following:
             Compiler          :  XC8 1.45
             MPLAB             :  MPLAB X 4.15
      
         Copyright (c) 2013 - 2015 released Microchip Technology Inc.  All rights reserved.
     */
      
     /*
         (c) 2018 Microchip Technology Inc. and its subsidiaries. 
         
         Subject to your compliance with these terms, you may use Microchip software and any 
         derivatives exclusively with Microchip products. It is your responsibility to comply with third party 
         license terms applicable to your use of third party software (including open source software) that 
         may accompany Microchip software.
         
         THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 
         EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY 
         IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS 
         FOR A PARTICULAR PURPOSE.
         
         IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 
         INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 
         WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP 
         HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO 
         THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL 
         CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT 
         OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS 
         SOFTWARE.
     */
      
     #include <xc.h>
     #include "pin_manager.h"
     #include "stdbool.h"
      
      
      
      
      
     void PIN_MANAGER_Initialize(void)
     {
         /**
         LATx registers
         */
        LATA = 0x00;
        LATB = 0x01;
        LATC = 0x02;
      
         /**
         TRISx registers
         */
         TRISA = 0xFF;
        TRISB = 0xFC;
        TRISC = 0x41;
      
         /**
         ANSELx registers
         */
         ANSELC = 0x01;
        ANSELB = 0xF0;
        ANSELA = 0xFF;
      
         /**
         WPUx registers
         */
         WPUE = 0x00;
        WPUB = 0x00;
        WPUA = 0x00;
        WPUC = 0x00;
      
         /**
         ODx registers
         */
        ODCONA = 0x00;
        ODCONB = 0x00;
        ODCONC = 0x00;
      
      
      
      
      
        
     
    
        SPI1SDIPPSbits.SPI1SDIPPS = 0x16;   //RC6->SPI1:SDI1;    
        RC4PPS = 0x1E;   //RC4->SPI1:SCK1;    
        SPI1SCKPPSbits.SPI1SCKPPS = 0x14;   //RC4->SPI1:SCK1;    
        RC5PPS = 0x1F;   //RC5->SPI1:SDO1;    
     }
       
     void PIN_MANAGER_IOC(void)
     {   
     }
      
     /**
      End of File
     */
    Last edited by richard; - 20th October 2018 at 13:11.
    This is more entertaining than Free to Air TV

Similar Threads

  1. Problem with I2Cread command for an 32 bits ADC
    By Pilou81 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 27th October 2011, 15:32
  2. Need help to get I2CRead woriking
    By w7ami in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 29th November 2007, 17:22
  3. Problem with I2Cread and I2CWRITE function
    By Tony85 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th June 2006, 20:03
  4. Problem with I2Cread and I2CWRITE function
    By Tony85 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th June 2006, 18:32
  5. I2CRead / I2CWrite Problem?
    By koossa in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st October 2005, 19:26

Members who have read this thread : 20

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