Hi there
I have a PIC18F4685 with a 10MHz crystal and HS-PLL enabled and an I2C LCD.
My program goes like this -
- Set variables to be displayed ie set LCD text to variable and set length of lcd text to variable
- Send command to move the cursor on the LCD to the desired place
- Sent the LCD text out to the LCD.
The code works great it does exactly what it is meant to do. I have setup two macros one to move the cursor and the other to send the text out to the LCD. Each of these macros starts with a START command and finishes with a STOP command. The problem is that even though the macros follow each other immediately with no other tasks being perform no intterupts or other code etc I get a constant 10ms delay between the STOP and the following START command. To see if the problem lay with coming out of and entering macros I have played about and put some I2C activity straight after another lot of I2C data I get the 10ms delay ie START......STOP START.....STOP. This proved that the problem lies between the STOP and START command rather than in entering and leaving macros. I know this does not sound like a lot but it really adds up when you start looping around printing various things out to the LCD. To put this into perspective the average I2C activity length is less than 1ms.
Does anyone know anything about this mystery delay?
David
Strange timing issue
- JonnyW
- Posts: 1230
- Joined: Fri Oct 29, 2010 9:13 am
- Location: Matrix Multimedia Ltd
- Has thanked: 63 times
- Been thanked: 290 times
- Contact:
Re: Strange timing issue
Hello. Could you post your sample program (FCF) and we can have a look at it?
Cheers,
Jonny
Cheers,
Jonny
Re: Strange timing issue
Hi there
I have attached the code I was using to test with. I have also included a screen shot of the program I use to look at the logic levels. FYI the slightly wider set of data on the SDA line is the "Please select mode-" text.
David
I have attached the code I was using to test with. I have also included a screen shot of the program I use to look at the logic levels. FYI the slightly wider set of data on the SDA line is the "Please select mode-" text.
David
- Attachments
-
- i2c example.fcf
- (38.41 KiB) Downloaded 213 times
-
- screenshot.png
- (146.08 KiB) Downloaded 685 times
- 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: Strange timing issue
Hello David,
Yes I know where the delay comes in to it. Basically we added a 10ms delay to the end of the I2C stop routine as on some devices using a smaller delay or no delay causes the I2C hardware to lockup.
You can edit the length of the delay or even remove it altogether by using the code customisation feature.
Select the I2C component on the panel, right click and select custom code. Select the I2C Stop function and edit it. At the bottom of the function is the delay. You can try reducing it or removing it and see if this helps your program.
Let us know how you get on.
Yes I know where the delay comes in to it. Basically we added a 10ms delay to the end of the I2C stop routine as on some devices using a smaller delay or no delay causes the I2C hardware to lockup.
You can edit the length of the delay or even remove it altogether by using the code customisation feature.
Select the I2C component on the panel, right click and select custom code. Select the I2C Stop function and edit it. At the bottom of the function is the delay. You can try reducing it or removing it and see if this helps your program.
Let us know how you get on.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Strange timing issue
Hi
All it says in the custom code for the stop function is -
%a_I2C_Master_Stop();
I got here from the "Customize Component Code" window and then clicking on MI2C_Stop and then clicking on "edit code". I guess I am going to the wrong place.
David
All it says in the custom code for the stop function is -
%a_I2C_Master_Stop();
I got here from the "Customize Component Code" window and then clicking on MI2C_Stop and then clicking on "edit code". I guess I am going to the wrong place.
David
- 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: Strange timing issue
Hello David,
Ok sorry about that looks like the delay has moved from the component C code to the abstraction layer in version 5.
You will need to open the following file into a text editor.
C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_I2C.c
Scroll down to this function...
CALFUNCTION(void, FC_CAL_I2C_Master_Stop_, (void))
And the line you are looking for is right at the end.
delay_ms(10); //Wait before reusing the I2C BUS
Edit the file and save it, you may want to create a backup first. Then re-compile in Flowcode and the new code should be loaded automatically.
Hope this helps.
Ok sorry about that looks like the delay has moved from the component C code to the abstraction layer in version 5.
You will need to open the following file into a text editor.
C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_I2C.c
Scroll down to this function...
CALFUNCTION(void, FC_CAL_I2C_Master_Stop_, (void))
And the line you are looking for is right at the end.
delay_ms(10); //Wait before reusing the I2C BUS
Edit the file and save it, you may want to create a backup first. Then re-compile in Flowcode and the new code should be loaded automatically.
Hope this helps.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel