Help in lpc2148 lcd program

Discussion in 'Programmer's Corner' started by keertikumar_ws, Oct 13, 2010.

  1. keertikumar_ws

    Thread Starter New Member

    Oct 13, 2010
    1
    0
    I wrote a program to display 'a' in a 2*16 lcd with datalines connected to p0.10 to p0.13 as datalines,p1.22 to p1.24 as control lines of lpc2148.Lcd has to be operated in 4 bit mode.The program is as follows(i use keil's mdk):
    Code ( (Unknown Language)):
    1.  
    2. #include<lpc21xx.h>
    3. #define rs 1<<24
    4. #define rw 1<<23
    5. #define en 1<<22
    6. //#define bzr 1<<25
    7. #define dt (0XF)<<10
    8. void cmd(unsigned char);
    9. void dat(unsigned char);
    10. void delay(void);
    11. int main()
    12. {
    13. IODIR1=rs|rw|en;
    14. IODIR0=dt;
    15. cmd(0X2);
    16. cmd(0X8);
    17. cmd(0X0);
    18. cmd(0XE);
    19. cmd(0X0);
    20. cmd(0X1);
    21. cmd(0X0);
    22. cmd(0X6);
    23. cmd(0X8);
    24. cmd(0X0);
    25. dat(0X4);
    26. dat(0X1);
    27. while(1);
    28. }
    29. void cmd(unsigned char c)
    30. {
    31. IOCLR0=dt;
    32. IOSET0=dt&(c<<10);
    33. IOCLR1=rs|rw;
    34. IOSET1=en;
    35. delay();
    36. IOCLR1=en;
    37. delay();
    38. }
    39. void dat(unsigned char d)
    40. {
    41. IOCLR0=dt;
    42. IOSET0=dt&(d<<10);
    43. IOCLR1=rw;
    44. IOSET1=rs|en;
    45. delay();
    46. IOCLR1=en;
    47. delay();
    48. }
    49. void delay(void)
    50. {
    51. unsigned int i;
    52. for(i=0;i<1000;i++);
    53. }
    54.  
    There is no prob in the kit because i tried a program that one of my frien did and it worked out!!!!i dont know wat is the prob wit my prog......any hlp??????
     
Loading...