• AVR Freaks

weird i2c bugg on PIC18F26K42

Author
bttt
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2012/01/18 09:44:22
  • Location: 0
  • Status: offline
2019/07/12 04:12:23 (permalink)
0

weird i2c bugg on PIC18F26K42

Hi
I thought my I2C stack (through interruption)  was working well,
but I cannot read two bytes.
The only way to read these bytes through I2C is to add some dummy
declaration before, and I don't know why this helps.
 
It works if I add :
unsigned long LL[20] =  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
 
but it does not work with nothing added or even when adding a static declaration:
static unsigned long LL[20] =  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
 
These are just declarations, the variable is not used.
 
During an error, these flags are set : StartDone, StopDone, NackDetect
but not the flag for reading: I2C1RXIF and sometimes even StopDone
 
When it works (with a dummy declaration before), all the flags are set
and I can read reliably.
 
Any idea ?
Should I change the processor ?
 
PIC18F26K42 rev A001
MPLAB X 4.1 free license
XC8 v1.45
PICKit3
 
Thank you
 
#1

4 Replies Related Threads

    ric
    Super Member
    • Total Posts : 22652
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: weird i2c bugg on PIC18F26K42 2019/07/12 04:20:58 (permalink)
    +1 (1)
    If adding an unused variables helps, it sounds like you have a bad pointer writing to RAM that it shouldn't.
    Very hard to say more without seeing your code.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    bttt
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2012/01/18 09:44:22
    • Location: 0
    • Status: offline
    Re: weird i2c bugg on PIC18F26K42 2019/07/12 11:29:00 (permalink)
    0
    I checked my pointers, it does not seem that I'm writing to RAM by error.
    I'll check again later.
    Thanks for replying
     
    #3
    mbrowning
    Just a Member
    • Total Posts : 1418
    • Reward points : 0
    • Joined: 2005/03/16 14:32:56
    • Location: Melbourne, FL
    • Status: offline
    Re: weird i2c bugg on PIC18F26K42 2019/07/12 13:47:51 (permalink)
    0
    I’ve used I2C extensively on k42 processors 56k42 and 57k42 with no similar issues. I’ve used xc8 1.45 through 2.05 (C90 mostly but I did try C99 out). You most likely have a software error but no one can help you until you share your code.

    Oh well - there's always next year
    #4
    ric
    Super Member
    • Total Posts : 22652
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: weird i2c bugg on PIC18F26K42 2019/07/12 14:36:42 (permalink)
    0
    bttt
    I checked my pointers, it does not seem that I'm writing to RAM by error.

    If that's your attitude then you'll have to find your own problem.
    We can't debug code by telepathy.
     
    post edited by ric - 2019/07/12 14:40:20

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #5
    Jump to:
    © 2019 APG vNext Commercial Version 4.5