Please Help Me!!(PIC18F47Q10_I2C)

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
seokgi
Posts: 164
Joined: Fri Jan 13, 2012 4:21 am
Location: South KOREA
Has thanked: 18 times
Been thanked: 16 times
Contact:

Please Help Me!!(PIC18F47Q10_I2C)

Post 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.
Attachments
I2C_MCP3421_Test.fcfx
(26.4 KiB) Downloaded 156 times

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: Please Help Me!!(PIC18F47Q10_I2C)

Post 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 6058 times

seokgi
Posts: 164
Joined: Fri Jan 13, 2012 4:21 am
Location: South KOREA
Has thanked: 18 times
Been thanked: 16 times
Contact:

Re: Please Help Me!!(PIC18F47Q10_I2C)

Post 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.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: Please Help Me!!(PIC18F47Q10_I2C)

Post 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

seokgi
Posts: 164
Joined: Fri Jan 13, 2012 4:21 am
Location: South KOREA
Has thanked: 18 times
Been thanked: 16 times
Contact:

Re: Please Help Me!!(PIC18F47Q10_I2C)

Post 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.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: Please Help Me!!(PIC18F47Q10_I2C)

Post 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

seokgi
Posts: 164
Joined: Fri Jan 13, 2012 4:21 am
Location: South KOREA
Has thanked: 18 times
Been thanked: 16 times
Contact:

Re: 도와주세요! (PIC18F47Q10_I2C)

Post by seokgi »

The program has been modified again. The timer interrupt works fine.
Attachments
I2C_MCP3421_Test.fcfx
(27.35 KiB) Downloaded 161 times

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: Please Help Me!!(PIC18F47Q10_I2C)

Post by stefan.erni »

ok sorry about the irq. I just saw now how it works.

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: Please Help Me!!(PIC18F47Q10_I2C)

Post by viktor_au »

Hello
Just a question.
Did you do the updates?

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: Please Help Me!!(PIC18F47Q10_I2C)

Post 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?
Attachments
MissingVariables-1.jpg
MissingVariables-1.jpg (28.11 KiB) Viewed 6002 times

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Please Help Me!!(PIC18F47Q10_I2C)

Post by mnf »

Look like a hangover from simulating a previous version.. They don't seem to be defined.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Please Help Me!!(PIC18F47Q10_I2C)

Post 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.
Martin

seokgi
Posts: 164
Joined: Fri Jan 13, 2012 4:21 am
Location: South KOREA
Has thanked: 18 times
Been thanked: 16 times
Contact:

Re: Please Help Me!!(PIC18F47Q10_I2C)

Post 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.
Attachments
I2C_MCP3421_Test2.fcfx
(17.42 KiB) Downloaded 103 times

seokgi
Posts: 164
Joined: Fri Jan 13, 2012 4:21 am
Location: South KOREA
Has thanked: 18 times
Been thanked: 16 times
Contact:

Re: Please Help Me!!(PIC18F47Q10_I2C)

Post 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.
Attachments
I2C_MCP3428_18F26K22.fcfx
(17.92 KiB) Downloaded 95 times

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Please Help Me!!(PIC18F47Q10_I2C)

Post 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

seokgi
Posts: 164
Joined: Fri Jan 13, 2012 4:21 am
Location: South KOREA
Has thanked: 18 times
Been thanked: 16 times
Contact:

Re: Please Help Me!!(PIC18F47Q10_I2C)

Post 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.
Attachments
I2C_MCP3428_18F26K22.fcfx
(18.62 KiB) Downloaded 101 times

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Please Help Me!!(PIC18F47Q10_I2C)

Post by mnf »

Glad to have helped a little...

Martin

Post Reply