Strange timing issue
Posted: Tue Mar 06, 2012 9:21 am
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
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