CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Interfacing MPU-6050 with i2c
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 13, 2019 9:11 am     Reply with quote

He has never told us the Vdd voltage he's using for his 16F887 PIC.

The "board" that he keeps referring to is the GY-521 board. There is
a schematic for it at the end of this PDF file:
http://synacorp.my/v2/en/index.php?controller=attachment&id_attachment=635
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Wed Feb 13, 2019 9:40 am     Reply with quote

Your link refused to work.

The board has an LDO regulator for going from 5v (since this is what the
Arduino provides by default), so one has to assume he is running at
probably 5v. You can run the board off 3.3v, and then the LDO is nearly
a short and the chip runs only a few tenths of a volt below the rail.
Not really ideal.

As you say he has never given the voltage, but assuming he is running
at 5v, the data will not reliably be read unless he switches to using
the SMBUS levels.
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Feb 13, 2019 10:20 am     Reply with quote

There's no mention as to which LDO 3 v reg is on that board BUT it might be possible to run the PIC from the module. I'd remove the onboard LED as he has an LCD module..ooops... THAT may be why the 5 volt supply...now he could use a dickson doubler and be 100% 3 volt....
though SMbus mode seems the easiest solution.

Jay
rfjhh



Joined: 31 Mar 2011
Posts: 51
Location: Mexico

View user's profile Send private message

It works!!!!!!!!
PostPosted: Thu Feb 14, 2019 8:30 am     Reply with quote

PCM programmer

Thanks, your example works well.
At first glance it seems to be the same as what I do, but I think there is some detail to discover.
I think I'll learn a lot by analyzing this code.

Thanks a lot

By the way
PIC VDD = 5V
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Feb 14, 2019 9:10 am     Reply with quote

It works because it changes the HARDWARE within the PIC to alter the thresholds of what will be considered to be a '1'.
You should read the PIC datasheet (electriclal and MSSP sections) very carefully.
The actual 'I2C' driver code is not what has made it worked.

Whenever interfacing 3 volt peripherals (the 'normal' these days) to PICs with a Vdd of 5 volts, you WILL run into this problem. That's why we all suggest either using a 3 volt rated or 'logic level converters' so that the proper '1's and '0's can be sent and read.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Thu Feb 14, 2019 9:15 am     Reply with quote

You are sending the register address before the device address. The device address _must_ be the first byte after the 'start'.

I'd be very surprised if you are getting reasonable values, since the chip
should not be able to give enough voltage to drive your PIC.
If it is working, I wonder if the internal pull-ups are actually to 5v. If so the
chip will be being 'overdriven' when data is written, but it might (just) allow
it to work.
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Feb 14, 2019 10:12 am     Reply with quote

I made the assumption he's got PCM Ps 'SMBUS' in the I2C options.... though it'd be nice to see the current code.
Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Thu Feb 14, 2019 12:17 pm     Reply with quote

Problem is I checked the data sheet, and the 877 he is using doesn't offer
the SMBUS option.
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Feb 14, 2019 12:42 pm     Reply with quote

well you got me thinking,cause that chip is kinda old,like me.. so I looked at my copy ..877c,
DS30292C-page 155... there IS a D044A parameter ! SMBUS
Mind you whether the compiler understands it, is another question.
He may be just lucky, VDD <5 by a little, Vgyro>3.5 a little and it's JUST seeing a '1' , once in awhile...
If I had time, I'd cut/compile/test but currently translating 30 year old BASIC52 code into CCS C.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Thu Feb 14, 2019 1:52 pm     Reply with quote

DS30292C is for the 87x, not the 887. 41291d is the current datasheet from
MicroChip, for the 887. no mention of SMBUS anywhere. Unusual, since
most chips do offer this.
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Feb 14, 2019 3:01 pm     Reply with quote

dang,..getting old sucks..NOW I'm dislexic ! Bad enough I can't type, now numbers get reversed as well.... Sad
wonder what comes next ?
Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Fri Feb 15, 2019 1:53 am     Reply with quote

I read it as 877 the first time I looked at the code.....
Reason is simple. The 877 is so common compared to the 887. Was
surprised to see this later chip being used.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group