Page 1 of 1

Please Help Me!!(PIC18F47Q10_I2C)

Posted: Thu Oct 22, 2020 7:16 am
by seokgi
Hello!!
I want to receive data from MCP3421 to I2C using PIC18F47Q10. However, no data is received.
So, I verified it through the oscilloscope and logic analyzer, but there is no response from the MCU pin. No schematic problem. FC8 was also reinstalled. But the result is the same.

Also, please review the touch sensor.

Help.

Re: Please Help Me!!(PIC18F47Q10_I2C)

Posted: Thu Oct 22, 2020 8:32 am
by stefan.erni
Hi Seokgi

Is the counting ok in this way?
Do you have pullup resistor for the I2C bus?
With your oscilloscope did you see the clock and data you are sending?
regards
Stefan
Count.PNG
Count.PNG (24.36 KiB) Viewed 7610 times

Re: Please Help Me!!(PIC18F47Q10_I2C)

Posted: Thu Oct 22, 2020 8:39 am
by seokgi
I pulled up 4.7Kohm resistors on SDA, SCL.
And when viewed with an oscilloscope, the clock is not generated in SCL.
Heart count monitors MCU operation status. Heart count doesn't make sense here, but it works fine.

Re: Please Help Me!!(PIC18F47Q10_I2C)

Posted: Thu Oct 22, 2020 8:59 am
by stefan.erni
Hi Seokgi

You need a clock to send and read I2C
Check if the IRQ is working, Remove for a test the 100ms Delay or make a loop in the main for a simple clocktest.
An with your oscilloscope, the pin is always hi (not low)?

If you never have a clock we have to look at this

DS40002043D-page 8 did you see this? I hope it's not a problem
This is a PPS remappable input signal

Re: Please Help Me!!(PIC18F47Q10_I2C)

Posted: Thu Oct 22, 2020 10:07 am
by seokgi
Cleared the delay timer. And I looked at the datasheet. But I definitely used CH1. I don't know what's the problem.

Re: Please Help Me!!(PIC18F47Q10_I2C)

Posted: Thu Oct 22, 2020 10:31 am
by stefan.erni
I think you are correct with your channel1 and the pins
Maybe there is config problem of the pic.
Can you change to softwaremode for the I2C and
have a look for the clocksignal with the oscilloscope?
Can you also include a Pin or LED in the Irq and test with oscilloscope if there is always an Irq?
And if all of this not help trie to use in softwaremode an another pin just for the clock to test it with the oscilloscope

Re: 도와주세요! (PIC18F47Q10_I2C)

Posted: Thu Oct 22, 2020 10:37 am
by seokgi
The program has been modified again. The timer interrupt works fine.

Re: Please Help Me!!(PIC18F47Q10_I2C)

Posted: Thu Oct 22, 2020 10:54 am
by stefan.erni
ok sorry about the irq. I just saw now how it works.

Re: Please Help Me!!(PIC18F47Q10_I2C)

Posted: Thu Oct 22, 2020 7:41 pm
by viktor_au
Hello
Just a question.
Did you do the updates?

Re: Please Help Me!!(PIC18F47Q10_I2C)

Posted: Thu Oct 22, 2020 7:51 pm
by viktor_au
One more question.
FC8 shows warning.
I am not sure how important it is, but in case:
- what about missing variables in your program?

Re: Please Help Me!!(PIC18F47Q10_I2C)

Posted: Thu Oct 22, 2020 8:06 pm
by mnf
Look like a hangover from simulating a previous version.. They don't seem to be defined.

Re: Please Help Me!!(PIC18F47Q10_I2C)

Posted: Thu Oct 22, 2020 10:42 pm
by medelec35
That would happen for three reasons.
1)Added assigned a new variable, added it to simulator debugger, then deleted variable from flowchart.
2) Renamed a variable.
3) Added a local variable and no longer within the macro where variable is used.
Its not whats happened in your case as missing variables were global.

Re: Please Help Me!!(PIC18F47Q10_I2C)

Posted: Fri Oct 23, 2020 8:54 am
by seokgi
With your help, I2C works fine. Thank you.
However, when reading in 16bit, the first byte comes in and the second byte is fixed at 255. I upload my modified program.

Thanks for your help.

Re: Please Help Me!!(PIC18F47Q10_I2C)

Posted: Mon Oct 26, 2020 8:21 am
by seokgi
I think I am wrong. So, I modified the program using another MCU (PIC18F26K22) and another ADC (MCP3428).

But the result is not good. The first byte value comes in. However, only the value "255" comes in the second byte.

Pullup = 4.7KOhm

Somebody ask for advice.

Re: Please Help Me!!(PIC18F47Q10_I2C)

Posted: Mon Oct 26, 2020 8:34 am
by mnf
When you receive the data you have ReceiveByte(1) for the first data byte. The 1 (or true?) indicates 'last byte' - try using first = ReceiveByte(0) second = ReceiveByte(1).

Martin

Re: Please Help Me!!(PIC18F47Q10_I2C)

Posted: Mon Oct 26, 2020 12:17 pm
by seokgi
It's Solved.

Thank you very much MARTIN.

I post programs for others.

But there are some problems. Values are well read. However, the values measured and measured with an actual multimeter are different.

Using a 10Kohm volume, low voltage was applied to both sides, and the voltage drawn from the middle tap was applied.

If someone knows the cause, I would appreciate any advice.

Thank you to everyone who helped.

Re: Please Help Me!!(PIC18F47Q10_I2C)

Posted: Mon Oct 26, 2020 6:35 pm
by mnf
Glad to have helped a little...

Martin