<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/28332/my-lcd-routine-doesnt-work-simulator-give-correct-answer</link><description> 
#include &amp;lt;LPC214X.H&amp;gt; 

 
//Control lines connected to P0.0, P0.1, P0.2, nad data is
connected to P0.4,P0.5, P0.6, P0.7 
#define LCD_DATA 0x000000FF 
#define LCD_SET IO0SET 
#define LCD_CLR IO0CLR 
//Control lines connected to P0.4, P0.5, P0.6, P0.7</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/151417?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2011 03:39:38 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:726e63e5-98eb-4665-b98e-c52a644b5cc4</guid><dc:creator>Heena Panchal</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thank u sir for your advise..&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/152159?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2011 03:38:39 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:680a9e2b-d373-4462-bf8c-09153d385889</guid><dc:creator>Heena Panchal</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thank u so much sir my LCD is now working fine...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/151399?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2011 02:48:19 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a7d6c5c6-e323-485e-8ca0-17d9336764a4</guid><dc:creator>Jeff Dunn</dc:creator><description>&lt;p&gt;&lt;p&gt;
Look at &lt;a href="http://www.keil.com/forum/14875/"&gt;http://www.keil.com/forum/14875/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
There you will find a good working software delay routine.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/150775?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2011 01:57:01 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7ffde7a4-be29-4e79-ae3a-6a188e5b85fd</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
This has absolutely nothing whatsoever to do with ARM7 - it is
inherent in the very nature of &lt;i&gt;&lt;b&gt;any&lt;/b&gt;&lt;/i&gt; High-Level Language
(HLL)!&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;pls guide me for better delay routine&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
I have already given you a link - &lt;i&gt;&lt;b&gt;twice&lt;/b&gt;&lt;/i&gt; - that
explains the issue!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/145047?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2011 01:29:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:75fcd2df-a44b-4fe9-9c7c-d8de83ddb96c</guid><dc:creator>Heena Panchal</dc:creator><description>&lt;p&gt;&lt;p&gt;
Dear Sir,&lt;/p&gt;

&lt;p&gt;
I am very new to ARM7 programming and i have taken this delay code
from one of my mate, i have not actully count the instruction
cycles...&lt;/p&gt;

&lt;p&gt;
pls guide me for better delay routine...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/142808?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2011 01:06:22 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b302a4d8-ed80-425f-87a2-8d4ad77fed23</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;pre&gt;
   /* At 60Mhz, the below loop introduces
    delay of 10 us */
    for(i=0;i&amp;lt;35;i++);
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
Are you _really_ sure that your look takes 10us? 600 instruction
cycles to count 35 ticks?&lt;/p&gt;

&lt;p&gt;
Now, please inform us exactly how you have validated the above
code. Did you use an oscilloscope or exactly what did you do?&lt;/p&gt;

&lt;p&gt;
Have you also tried to change the optimization settings for the
compiler? How did that change the length of the delay?&lt;/p&gt;

&lt;p&gt;
What was your conclusions from the above tests?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/139804?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2011 00:55:55 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ac1426a7-0190-465e-8ae7-daceb180c987</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
More to the point, you have to toggle the enable bit &lt;i&gt;&lt;b&gt;with
the correct timing&lt;/b&gt;&lt;/i&gt; every time you write data...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/136384?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2011 00:37:49 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3dc52390-9302-4452-8c11-d0c1002b1e39</guid><dc:creator>Heena Panchal</dc:creator><description>&lt;p&gt;&lt;p&gt;
Sir,&lt;/p&gt;

&lt;p&gt;
As i mentioned earlier my code with &lt;b&gt;8 bit&lt;/b&gt; data is working ,
but when i used the same code for nibble mode it is not working,&lt;/p&gt;

&lt;p&gt;
As per LCD datasheet the only difference is that we have to write
command 0x28 instead of 0x38 and the higher nibble is send fisrt and
then lower nibble; and we have to toggle enable bit every time we
write data..&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/116204?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2011 00:32:29 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8131f083-2418-4d45-854c-99f57661543e</guid><dc:creator>Heena Panchal</dc:creator><description>&lt;p&gt;&lt;p&gt;
Sir,&lt;/p&gt;

&lt;p&gt;
The second time which i have mentioned as &amp;quot;read lower nibble&amp;quot; is
after shifting the data.&lt;/p&gt;

&lt;p&gt;
Can u pls help me to write correct delay routine or i should use
timer for delay generation..&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/126610?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2011 00:26:05 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:77bba2c9-ab41-4685-b0d2-1569ee5f56ca</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
because the real LCD depends upon the correct &lt;i&gt;&lt;b&gt;timing&lt;/b&gt;&lt;/i&gt;
- doesn&amp;#39;t it?&lt;/p&gt;

&lt;p&gt;
One of the things that the simulator doesn&amp;#39;t observe is
&lt;i&gt;&lt;b&gt;timing&lt;/b&gt;&lt;/i&gt;.&lt;/p&gt;

&lt;p&gt;
And, of course, the simulator also won&amp;#39;t be aware of any other
hardware issues on your target...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/126611?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2011 00:23:28 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2fd171ef-b41f-4591-afb6-b3e9ce9deb22</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;data is shifting&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Exactly!&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;shifting&lt;/b&gt; is not the same as &lt;b&gt;rotating&lt;/b&gt; - is it?!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/104532?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2011 00:21:40 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:018e7b2a-aa58-45ce-bde6-60e96d7c4f7e</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
That&amp;#39;s better - wasn&amp;#39;t so hard, was it?&lt;/p&gt;

&lt;p&gt;
But you haven&amp;#39;t checked your code very carefully:&lt;/p&gt;

&lt;pre&gt;
temp1 &amp;amp;= 0x000000f0;                // get higher nibble
&lt;/pre&gt;

&lt;p&gt;
and&lt;/p&gt;

&lt;pre&gt;
temp1 &amp;amp;=0x000000f0;                          // get lower nibble
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
Can&amp;#39;t both be right - can they?!&lt;/p&gt;

&lt;p&gt;
And you still have a software delay loop:&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;you should&lt;/i&gt; &lt;b&gt;never&lt;/b&gt; &lt;i&gt;write delay routines in any
High-Level Language(HLL) - See: &lt;a href="http://www.8052.com/forum/read/162556"&gt;www.8052.com/.../162556&lt;/a&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/116208?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2011 00:20:57 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:39615278-73fb-471e-94f4-0210031321a7</guid><dc:creator>Heena Panchal</dc:creator><description>&lt;p&gt;&lt;p&gt;
Sir,&lt;/p&gt;

&lt;p&gt;
I have checked it while debugging in keil 4, in that it is showing
that data is shifting, and my lower nibble is being read while debug,
i cant understand why it not showing on LCD. i have debug my complete
code and it giving desired value at each step...&lt;/p&gt;

&lt;p&gt;
pls help..&lt;/p&gt;

&lt;p&gt;
Thank u&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/104530?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2011 00:14:16 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:55d1762c-c968-4781-ab9f-041110c43b26</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
Then you are mistaken!&lt;/p&gt;

&lt;p&gt;
That line of code does not &lt;b&gt;&lt;i&gt;rotate&lt;/i&gt;&lt;/b&gt; anything!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/78965?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2011 00:11:07 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f4586a50-99d7-4344-9e9c-3dbee20aa691</guid><dc:creator>Heena Panchal</dc:creator><description>&lt;p&gt;&lt;p&gt;
Sir,&lt;/p&gt;

&lt;p&gt;
I have used this instruction to rotate data and read lower byte,
and yes my comment is wrong.&lt;/p&gt;

&lt;p&gt;
Thank u,&lt;br /&gt;
Heena&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/78969?ContentTypeID=1</link><pubDate>Thu, 20 Jan 2011 00:08:57 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ad86ce1c-3a76-4e51-9312-89e2b50193aa</guid><dc:creator>Heena Panchal</dc:creator><description>&lt;p&gt;&lt;p&gt;
ok sir , i will again send my code , and i have check my LCD
document also the commands are correct and some i have used with 8
bit display also, there it is working nice with same cammand , data
and delay routine.The LCD which i am using is 44780 LCD.&lt;/p&gt;

&lt;p&gt;
Thank u,&lt;br /&gt;
Heena Panchal&lt;/p&gt;

&lt;p&gt;
Below is my source code&lt;/p&gt;

&lt;pre&gt;
#include &amp;lt;LPC214X.H&amp;gt;

//Control lines connected to P0.0, P0.1, P0.2, nad data is connected to P0.4,P0.5, P0.6, P0.7
#define LCD_DATA 0x000000FF
#define LCD_SET IO0SET
#define LCD_CLR IO0CLR
//Control lines connected to P0.4, P0.5, P0.6, P0.7
//#define CTRL 0x000000
//#define CTRL_SET IOSET1
//#define CTRL_CLR IOCLR1

#define RS  0x00000001;         /* Set P0.0 */
#define WR  0x00000002; /* Set P0.1 */
#define EN  0x00000004; /* Set P0.2 */

#define LCDRS              (1 &amp;lt;&amp;lt; 0)
#define LCDRW              (1 &amp;lt;&amp;lt; 1)
#define LCDEN              (1 &amp;lt;&amp;lt; 2)

#define LCD_D4 (1 &amp;lt;&amp;lt; 4)
#define LCD_D5 (1 &amp;lt;&amp;lt; 5)
#define LCD_D6 (1 &amp;lt;&amp;lt; 6)
#define LCD_D7 (1 &amp;lt;&amp;lt; 7)

#define LCD_DATA_MASK  (LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7)
//-------------------fuction declations-----------------------
void LcdInit (void);
void LcdData (unsigned char data);
void LcdCmd (unsigned char cmd);
void delay_lcd(void);
//void DisplayRow (int row, char *str);
void int_port(void);
void delay1(unsigned int);
void delay(int count);
//------------------------------------------------------------------------------


int main ()
{
        int_port();
        LcdInit();
        LcdData(&amp;#39;A&amp;#39;);
        LcdData(&amp;#39;B&amp;#39;);
    LcdData(&amp;#39;C&amp;#39;);
        while(1);
}
void int_port(void)
{
        PINSEL0=0x00000000;
        PINSEL1=0x00000000;
        IO0DIR = LCD_DATA;
        LCD_SET=(LCDRS | LCDRW | LCDEN);
        LCD_CLR|=LCD_DATA_MASK; //All segments Off
        //CTRL_SET= CTRL;
//      LCD_CLR = LCD_DATA; //All segments Off
}
        //---------------------------------lcd initi--------------------------
void LcdInit (void)
{

        delay1(5);
        delay1(5);
        delay1(5);

        LcdCmd(0x01);  // LCD clear
        LcdCmd(0x03);     // commands from datasheet
        delay1(5);
        LcdCmd(0x03);
        delay1(5);
        LcdCmd(0x03);
        delay(100);
        LcdCmd(0x28);           // Select nibble mode
        LcdCmd(0x06);           //      LCD diaply and cursor ON
        LcdCmd(0x0e);           // cursor diraction and link
  //    LcdCmd(0x10);
        LcdCmd(0x01);           // clear LCD

}
//--------------------------------------------------------------------
void delay1(unsigned int time )    // delay in ms
{
         int i,j;
     for (i=0;i&amp;lt;=time;i++)
         for (j=0;j&amp;lt;=5000;j++);
}
//---------------------------------------------------------------------
void LcdCmd (unsigned char cmd)
{
        int temp1;

        temp1 = cmd;
        temp1 &amp;amp;= 0x000000f0;                // get higher nibble

        LCD_CLR= LCD_DATA;                 // Clear LCD data
        IO0PIN = temp1;                    // Send data on port 0

    LCD_CLR= RS;                           // clear RS pin
        LCD_CLR= WR;                       // clear wr pin

        LCD_SET=EN;                                // set anable pin
        delay(5);
        LCD_CLR=EN;                                // clear enable pin
        delay(10);

        temp1=cmd;
        temp1=temp1&amp;lt;&amp;lt;4;                             // rotate data right
        temp1 &amp;amp;=0x000000f0;                   // get lower nibble

        LCD_CLR= LCD_DATA;                       // Clear LCD data
        IO0PIN = temp1;                          // Send data on port 0

        LCD_CLR= RS;
        LCD_CLR= WR;

        LCD_SET=EN;
        delay(5);
        LCD_CLR=EN;
        delay(10);
}
//---------------------------------------------------------------------------------------------------------------
void LcdData (unsigned char data)
{
        int temp1;

        temp1 = data;
        temp1 &amp;amp;= 0x000000f0;                // get higher nibble

        LCD_CLR= LCD_DATA;                       // Clear LCD data
        IO0PIN = temp1;                         // Send data on port 0

        LCD_SET= RS;                             // set RS pin
        LCD_CLR= WR;                             //set wr pin

        LCD_SET=EN;
        delay(5);
        LCD_CLR=EN;
        delay(10);

        temp1=data;
        temp1=temp1&amp;lt;&amp;lt;4;                                    // rotate data right
        temp1 &amp;amp;=0x000000f0;                          // get lower nibble

        LCD_CLR= LCD_DATA;
        IO0PIN = temp1;

        LCD_SET= RS;
        LCD_CLR= WR;
        LCD_SET=EN;
        delay(5);
        LCD_CLR=EN;
        delay1(5);
}
//------------------------------------------------------------------------------
 void delay_lcd(void)             // small delay
{
 int j;
 for (j=0;j&amp;lt;600;j++);
}

//------------------------------------------------------------------------------------
void delay(int count)
{
  int j=0,i=0;

  for(j=0;j&amp;lt;count;j++)
  {
    /* At 60Mhz, the below loop introduces
    delay of 10 us */
    for(i=0;i&amp;lt;35;i++);
  }
}
//-----------------------------------------------------------------------------------


&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/59085?ContentTypeID=1</link><pubDate>Wed, 19 Jan 2011 23:47:22 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c2016678-b658-49a7-90a5-817233fc5405</guid><dc:creator>IB Shy</dc:creator><description>&lt;p&gt;&lt;p&gt;
Something is obviously wrong here:&lt;/p&gt;

&lt;pre&gt;
temp1=temp1&amp;lt;&amp;lt;4; // rotate data right
&lt;/pre&gt;

&lt;p&gt;
Code or comment?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: My LCD routine doesnt work , simulator give correct answer</title><link>https://community.arm.com/thread/66194?ContentTypeID=1</link><pubDate>Wed, 19 Jan 2011 23:46:24 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a3490bc9-0b8b-4dae-a385-06095d5b1799</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
That&amp;#39;s exactly why you should never write delay routines in any
High-Level Language(HLL) - See: &lt;a href="http://www.8052.com/forum/read/162556"&gt;www.8052.com/.../162556&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
You also missed the clear instructions on how to post source code:
&lt;a href="http://www.danlhenry.com/caps/keil_code.png"&gt;www.danlhenry.com/.../keil_code.png&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
If you can miss something that obvious, then you should also go
back and carefully re-check your processor &amp;amp; LCD documentation to
see if there&amp;#39;s any other important detais that you missed
there...?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>