• AVR Freaks

Helpful ReplyHot!MPLAB MCC I2C problems.

Author
Batloid
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2019/02/18 07:41:56
  • Location: 0
  • Status: offline
2020/07/30 13:44:08 (permalink)
0

MPLAB MCC I2C problems.

Hy everyone. I was trying to use I2C, using MCC code.
I'm using PIC24FJ64GA106, this device has 3 I2C modules, and for some security requirements I need to use two.
The first problem is that the Foundation Services Library does not support the use of more than one I2C module. The other module should be used with more basic routines.
However, the biggest problem is a piece of code (there are actually several)
while (I2C_BUSY == i2c_close ()); // sit here until finished.
At that point, if the other device connected to the I2C bus does not respond, or something happens, the microcontroller remains absolutely blocked.
There are several dangerous while in the generated code, including one while (1).
I am grateful for the existence of the MCC tool, and my post is to help you correct these things.
I would suggest (as I've seen in other codes) that they give escape options for time and / or retries, and return a boolean if the routine ended successfully or not.
If I have a display, an RTC and a memory hung on the I2C bus, and the display is disconnected, I can safely continue to work, this should not block my equipment. Furthermore, I should block it if I choose to.
Regards
Alejandro Cabral
 
#1
BobAGI
Super Member
  • Total Posts : 1731
  • Reward points : 0
  • Joined: 2011/03/09 00:04:35
  • Location: Texas and Sweden
  • Status: offline
Re: MPLAB MCC I2C problems. 2020/07/30 15:48:13 (permalink)
0
Batloid
There are several dangerous while in the generated code, including one while (1).
I am grateful for the existence of the MCC tool, and my post is to help you correct these things.

Are you suggesting that you want to help us (the members of this forum) to correct your code while you do not show one single line of it?
Strange request.....

--
Bo B
Sweden & Texas
 
#2
ric
Super Member
  • Total Posts : 28378
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: MPLAB MCC I2C problems. 2020/07/30 16:00:21 (permalink) ☄ Helpfulby Batloid 2020/08/04 12:35:18
0
No, I suspect he thinks he is talking to Microchip.
If you want to interact with Microchip, you need to open a "Support Ticket" via http://support.microchip.com

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!
#3
Batloid
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2019/02/18 07:41:56
  • Location: 0
  • Status: offline
Re: MPLAB MCC I2C problems. 2020/07/30 16:10:33 (permalink)
0
Sorry by my english, as Ric says I was trying to help Microchip correct those details. I think many of us make use of MCC and these forums. I hope it helps.
 
#4
Charlie E
Senior Member
  • Total Posts : 79
  • Reward points : 0
  • Joined: 2009/08/24 14:20:00
  • Location: 0
  • Status: offline
Re: MPLAB MCC I2C problems. 2020/08/03 15:24:17 (permalink) ☄ Helpfulby Batloid 2020/08/04 12:35:26
0
Batloid,
As a victim of trying to use the MCC code for I2C, I have great pity on you.  If you have figured out how to even use this code, you are a better man than I am.  On my present project, I had to go to fully bit banged code to get it to work, and I am only using a single I2C bus and a single device!
 
Good luck, you shall need it.
 
Charlie
#5
ALostCause12
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2019/08/28 13:14:02
  • Location: 0
  • Status: offline
Re: MPLAB MCC I2C problems. 2020/08/04 09:38:33 (permalink) ☄ Helpfulby Batloid 2020/08/04 12:35:29
0
I have similarly ran into this. The bigger issue is not being aware of these pitfalls, and having to manually parse the generated code to find these weak points. If they were pointed out from the get-go, it would at least save some time/frustration.
I like the idea of giving the user a number of times they'd like to attempt a transfer (with a default of say, 3 or 4), followed by a callback routine so you can decide to deal with it however you please.
With regards to the Foundation Services support - the basic driver generated is the i2c1_driver.c file, upon which the other layers are derived (e.g. i2c_master.c / i2c_simple_master.c / i2c_types). You can add this base driver in MCC for another module under left-hand pane Device Resources -> Peripherals -> I2C -> I2Cx [Foundation Services Library....]. You could then just copy most of the functions from the upper layers generated for the first case if you want/can afford that level of abstraction. While you are doing that, implementing the fixes needed as you go. Definitely not ideal, but it's something I guess.. :)
 
Cheers,
#6
Batloid
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2019/02/18 07:41:56
  • Location: 0
  • Status: offline
Re: MPLAB MCC I2C problems. 2020/08/04 12:43:20 (permalink)
0
Hi all, thanks for your replies.
Your comments validated my experience and because of this I opened  a support ticket as Ric suggested. I hope these details are corrected as soon as possible and we enjoy a more satisfying I2c experience.
Regards
#7
Jump to:
© 2020 APG vNext Commercial Version 4.5