Bug with I2C

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

Moderator: Benj

Post Reply
Pascal_2016
Posts: 89
Joined: Wed Aug 31, 2016 4:48 pm
Been thanked: 4 times

Bug with I2C

Post by Pascal_2016 »

Hello

CPU 32MS150

My config settings are as follows:

#pragma config FNOSC = FRCPLL
#pragma config FPLLIDIV = DIV_2
#pragma config FPLLMUL = MUL_20
#pragma config FPLLODIV = DIV_2
#pragma config FPBDIV = DIV_1

#pragma config DEBUG = OFF

#define GetSystemClock() (40000000ul)
#define GetPeripheralClock() (GetSystemClock())

#include <plib.h>

I have a EEPROM wiht I2C Bus. In this EEPROM I will write or read from.

With the programme in the annex, I want to write in the EEPROM or read from the EEPROM. I could read and write to the EEPROM in Flowcode 6

The same program was not run in Flowcode 7. What should I do so I can get the same result in Flowcode 7.
Attachments
TestI2C_Bug_Report.fcfx
(72.75 KiB) Downloaded 335 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: Bug with I2C

Post by QMESAR »

Hello;

I do not know of any 32MS150 devices however assuming you use a MX150 then according to the datasheet if you are using the FRC with communications such as SPI,I2C which requires as certain accuracy you should adjust the OSCTUN regsiter ,I myself never use FRC's but it may be worthwhile to check this out from your-side

I did not check your Flowchart so if you are doing this then I apologize for saying it :D
Attachments
1.JPG
1.JPG (32.15 KiB) Viewed 9053 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: Bug with I2C

Post by QMESAR »

Hi I looked at you flowchart and I am just asking what is the reason/ benefit that you use the standard #pragma directives to initialize your clock settings and not the provided Config tab in FC as you set your frequency in C code but in FC Config you have Clock setting of 20Mhz that in my opinion once you use Components that rely on this value to setup the modules / components will be incorrect as the mcu is running one speed and you are telling FC it running another speed you should setup the basics in FC correctly before saying there is a bug :D

Your Config seems to be for 40 MHZ you tell FC it is 20 MHZ this way you are doing it seems to me away to allow errors to creep in which can cause you to loose a lot of time
just my opinion :D
Attachments
2.JPG
2.JPG (82.46 KiB) Viewed 9037 times
1.JPG
1.JPG (58.77 KiB) Viewed 9037 times

Pascal_2016
Posts: 89
Joined: Wed Aug 31, 2016 4:48 pm
Been thanked: 4 times

Re: Bug with I2C

Post by Pascal_2016 »

Hello,

yes, my Microcontroler is 32MX150.

The matrix configuration I have switched off because I no DIN A5 page warnings will read to detect that the program without error created the hex file.


Why I use 20 MHz, can You read in the entry "32MS150 oscillator failure".

Sorry Your answer was not helpfull

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: Bug with I2C

Post by QMESAR »

Sorry Your answer was not helpfull
I am sorry it did not help you however I still think you are missing what the setting in the config are doing specially the value of the Clock
lets leave it there :D

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: Bug with I2C

Post by Steve »

To determine if the problem is with the clock speed, you could create a simple LED flasher circuit which blinks an LED at a set rate (e.g. each second)

Code: Select all

loop forever
   output on
   delay 500ms
   output off
   delay 500ms
end loop

Pascal_2016
Posts: 89
Joined: Wed Aug 31, 2016 4:48 pm
Been thanked: 4 times

Re: Bug with I2C

Post by Pascal_2016 »

The error has nothing to do with the clock, because as you can see in the flow diagram, I have installed a 1.0 Hz clock. The clock frequency is exactly 1 Hz.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Bug with I2C

Post by Benj »

Hello,

QMESAR is right the comment you have at the top of your Main flowchart doesn't match the values in the Project Options -> Configuration.

Here is some helpful tips to getting things running at the right speed.
http://www.matrixtsl.com/wikiv7/index.p ... ED_flasher

Do you need a delay near the start of your program to allow the I2C slave device time to power on?

Pascal_2016
Posts: 89
Joined: Wed Aug 31, 2016 4:48 pm
Been thanked: 4 times

Re: Bug with I2C

Post by Pascal_2016 »

Hello

If the 32MX150 has clock problems, why can I measure at pin CLKO 40 MHz and why blinking the LEDs in the 1 second intervals? Why did the 1Hz LED flasher circuit blinking at 40 MHz with 0.5 Hz and at 20 MHz with 1,0 Hz?

The microcontroler shows the same behavior in this configuration

#pragma config IOL1WAY = 0
#pragma config FUSBIDIO = 1
#pragma config FVBUSONIO = 0
#pragma config FPLLIDIV = 1
#pragma config FPLLMUL = 5
#pragma config FPLLODIV = 1
#pragma config FNOSC = 1
#pragma config FSOSCEN = 0
#pragma config IESO = 0
#pragma config POSCMOD = 3
#pragma config OSCIOFNC = 1
#pragma config FPBDIV = 0
#pragma config FCKSM = 3
#pragma config WDTPS = 0
#pragma config WINDIS = 0
#pragma config FWDTEN = 0
#pragma config FWDTWINSZ = 0
#pragma config DEBUG = 2
#pragma config JTAGEN = 0
#pragma config ICESEL = 0
#pragma config PWP = 0
#pragma config BWP = 1
#pragma config CP = 1

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: Bug with I2C

Post by LeighM »

20MHz.jpg
20MHz.jpg (30.12 KiB) Viewed 8933 times

Pascal_2016
Posts: 89
Joined: Wed Aug 31, 2016 4:48 pm
Been thanked: 4 times

Re: Bug with I2C

Post by Pascal_2016 »

Hello,

the system clock measured on the CLKO PIN is 20 MHz and the LED clock is 1 Hz. The issue isn't the configuration. The issue is the implementation of I2C. The SDA have only one square wave not more and no signal at SCL PIN.

EtsDriver
Posts: 444
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 345 times
Been thanked: 227 times

Re: Bug with I2C

Post by EtsDriver »

Try this out...
Attachments
TestI2C_Bug_Report.fcfx
40M clock set
(72.77 KiB) Downloaded 271 times
Ill just keep the good work up!

Pascal_2016
Posts: 89
Joined: Wed Aug 31, 2016 4:48 pm
Been thanked: 4 times

Re: Bug with I2C

Post by Pascal_2016 »

Thanks for the example. Unfortunately, this example could not fix the problem.

The frequency on CLKO Pin is 8 MHz.
The Lamp clock is 0.21 Hz


I have adapted my configuration settings on the clock frequency of Flowcode.

FPLLIDIV => 2x Divider --
FPLLMUL => 17x Multiplier | => 34 MHz
FPLLODIV => 1x Divider --

FPBDIV => Sys_Clk/2

Unfortunately is the I2C interface not running also with this setting

Post Reply