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

PIC16F1847 wont work on crystal oscilator (with I2C)
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Feb 17, 2024 1:20 pm     Reply with quote

The published specs are:
Quote:
Power - 3.3v-5v 18mA Typ.
Resolution - 0.1 Degree
Accuracy - 5°
Signal levels - 3.3v, 5v tolerant
I2C mode - up to 400khz
Serial mode - 9600, 19200, 38400 baud


I take that to mean it tolerates 5V input but puts out 3.3V signals.
_________________
Google and Forum Search are some of your best tools!!!!
temtronic



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

View user's profile Send private message

PostPosted: Sat Feb 17, 2024 1:44 pm     Reply with quote

Yes, I read the electrical specs of the BNO080.... Vout is 90% of VDDIO which means .9* 3.63, so Vhigh is 3.3 volts.
What's unclear is does the 'module' contain additional 'logic level' conversion chip ? Maybe it does ? need to see schematic of the module...

If using PIC's I2C pins, Vhi is .7* VDD so .7*5=3.5

Close, but not 100% .Maybe sensor puts out 3.4, PIC is OK with 3.4, so may work but I wouldn't trust it. Change room temperature, turn on an LED, oopsy... 'it doesn't work'.....

Now that PIC will work at 3 volts,32MHz so that's how I'd design/build the unit.
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PostPosted: Sun Feb 18, 2024 12:49 am     Reply with quote

From the data sheet:
Quote:
Power supply requirements are flexible, you can feed between 3.3 - 5v and the module draws a nominal 18mA
of current. A choice of serial or I2C interfaces can be used for communication.


And no any "ops, don't work". It works flowless. Tested in - 5 degree celsius and + 50 degree celsius
I have 2.2K resistors on SCL and SDA

Also the topic is why works on internal RC oscillator but won't work on crystal oscillator


Best wishes
Joe
temtronic



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

View user's profile Send private message

PostPosted: Sun Feb 18, 2024 6:50 am     Reply with quote

hmm.. since Mr T proved the PIC works fine with intrc and xtal ,using EEPROM and I2C scanner program and you say the compass operates fine.......

....perhaps there's a 'setup' requirement of the compass chip that's met with the internal RC and not the xtal/caps clock ?

maybe code so...

PIC gets power
setup serial and I2C
delay 500ms
blink an LED
reset the I2C bus
send 'reset' the compass
delay 100ms
blink an LED
then execute main()

I suspect the compass is getting 'locked' due to some timing issue or invalid set of pulses to it.
Ttelmah



Joined: 11 Mar 2010
Posts: 19238

View user's profile Send private message

PostPosted: Sun Feb 18, 2024 8:42 am     Reply with quote

Can I suggest you add SMBUS to the I2C setup. This reduces the voltage
the I2C will accept as a high. Safer for a 3.3v device. I was using a 5v
EEPROM for my test.

Also, I'm scared by one erratum on your chip. It has a problem that can
result in the chip not waking with a crystal, if the crystal is slow to start.
Tell us what the actual crystal you have is, how it is wired, and what
loading capacitors you are using. It may be that your crystal is one that
takes too long to start and hence your chip does not run with your crystal.
Any chance you have a different one you could try?.
temtronic



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

View user's profile Send private message

PostPosted: Sun Feb 18, 2024 9:20 am     Reply with quote

read some more stuff of the net and the BNO080 device in the compass module does have some 'power up' specs
The OP does say xtal does the 1Hz LED pgm, so on the surface not a xtal problem.

Since the only hardware change is the PIC clock, my gut says 'timing'. Maybe the compass module gets confused,so that's why I suggested a proper I2C reset,wait a bit, then access the compass.
Ttelmah



Joined: 11 Mar 2010
Posts: 19238

View user's profile Send private message

PostPosted: Sun Feb 18, 2024 12:15 pm     Reply with quote

I have to ask a couple of thingsL
Why not just use software I2C?. You are only running at 100KHz, software
will do that easily. Also using software I2C, you can just use pins with
TTL input levels, and it won't then mind 3.3v signalling.
If you must use hardware, then try using I2C2. It would tell us a lot
about what is actually happening.
Also what is the decoupling on the chip?. The crystal is more fussy about
decoupling than the internal oscillator. I'm wondering if when the chip tries
to signal on the I2C is is causing a glitch on the supply.
temtronic



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

View user's profile Send private message

PostPosted: Sun Feb 18, 2024 1:16 pm     Reply with quote

I'm pretty sure that PIC will run at 3v3, so simple test...run at 3v3 and see what happens ??

I don't know about the 'startup' time difference between using the internal RC vs a real xtal/caps but....
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PostPosted: Mon Feb 19, 2024 4:18 am     Reply with quote

Hi Ttelmah

I am working with this PIC16F1847 for many years but first time with I2C.
I used PIC18F26K22 for the CMPS14 with I2C also I2C for EEPROM to other PIC's (with your help in the past) always 5V with 2.2K resistors on SDA and SCL

I will try to answer one by one:
I have 3 PCB's, 3 PIC16F1847, all have the same problem with I2C.
To use I2C2 will have to make new PCB. Will check if I can use hardware UART on other pins if I use I2C2.
I have other functions working with interrupts, this why I don't want to use the software I2C.
The decoupling on all the chips are 100nF capacitors, good quality.
I check the supply voltage with oscilloscop, found no glich on the power supply
I have powerup timer enabled.
Can you write me how to add SMBUS? never done it

Hi Temtronic

I had no any issue with the CMPS14 get confused. It gives always correct data.
I am waiting 100ms between asking for new message

Best wishes
Joe
Ttelmah



Joined: 11 Mar 2010
Posts: 19238

View user's profile Send private message

PostPosted: Mon Feb 19, 2024 7:36 am     Reply with quote

On I2C, use of interrupts for other interfaces makes no difference. Interrupts
are only used for I2C receive. For transmit, there is no advantage to using
the hardware, except if you are using speeds, above those the software can
do. Since I2C is a master timed interface, if there is a pause in the
transmission, while an interrupt is serviced, it makes no difference at all.

#use I2C(MASTER, SLOW=100000, I2C1, SMBUS, STREAM=I2CPORT)
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PostPosted: Mon Feb 19, 2024 8:13 am     Reply with quote

Thank you for the prompt answer Ttelmah

I am out of office, will test again tomorrow

Best wishes
Joe
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PostPosted: Wed Feb 21, 2024 12:06 am     Reply with quote

Hi

I added to the I2C
Code:
#use I2C(MASTER, SLOW=100000, I2C1,SMBUS, STREAM=I2CPORT)

It didn't help

Best wishes
Joe
Ttelmah



Joined: 11 Mar 2010
Posts: 19238

View user's profile Send private message

PostPosted: Wed Feb 21, 2024 2:29 am     Reply with quote

and what happens when you use software I2C?.

Mys suspicion is that something about the sequencing of the signals on
your board is resulting in the I2C peripheral getting hung when running
off the crystal.
temtronic



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

View user's profile Send private message

PostPosted: Wed Feb 21, 2024 6:19 pm     Reply with quote

hmm...
another test to try...
add a 2nd I2C device, run the I2C Scanner program. does it return BOTH devices ?
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, 3
Page 3 of 3

 
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