Interfacing LPC2148 with Graphical LCD ks0108

Discussion in 'The Projects Forum' started by Rachit, Nov 23, 2012.

  1. Rachit

    Thread Starter New Member

    Nov 23, 2012
    1
    0
    Hello!... Actually, I am working on a project "Interfacing Graphical LCD ks0108 with LPC2148". And i have used Proteus to check my program.I just wanna ask that "Does proteus not work on LPC2148" and "Can i run my lpc2148 program in lpc2138 as i have seen proteus has lpc2138 microcontoller chip.



    My lpc2148 source code is-

    Code ( (Unknown Language)):
    1.  
    2. //glcd.c
    3. #include <LPC214X.H>
    4. #include "font.h"
    5.  
    6. unsigned char c;
    7. unsigned char z=0;
    8.  
    9. void ctrloff()
    10. {    
    11.     IOSET1=0x00000000;
    12. }
    13.  
    14. //DELAY FUNCTION
    15. void delay(unsigned int j)
    16. {    
    17.     unsigned int i;    
    18.     for(i=0;i<j;i++);
    19. }
    20.  
    21. void displayon()
    22. {
    23.     ctrloff();
    24.     IOSET1=0x1C3F;
    25.     delay(500);
    26.     IOSET1=0x0C3F;
    27.     delay(500);
    28. }
    29.  
    30. void displayoff()
    31. {    
    32.     ctrloff();
    33.     IOSET1=0x1C3E;
    34.     delay(500);    
    35.     IOSET1=0x0C3E;
    36.     delay(500);
    37. }
    38.  
    39. void setcolumn(unsigned char y)
    40. {    
    41.     if(y<64)    
    42.     {        
    43.         ctrloff();        
    44.         c=y;        
    45.         IOSET1=0x1440 |(y&63);      //0x40 represents Column 0        
    46.         delay(500);
    47.         IOSET1=0x0440 |(y&63);    
    48.         delay(500);
    49.     }    
    50.     else    
    51.     {        
    52.         ctrloff();        
    53.         c=y;        
    54.         IOSET1=0x1840|((y-64)&63);      //0x40 represents Column 0        
    55.         delay(500);        
    56.         IOSET1=0x0840|((y-64)&63);    
    57.         delay(500);
    58.     }
    59. }
    60.  
    61. void setpage(unsigned char x)
    62. {    
    63.     ctrloff();    
    64.     IOSET1= 0x1CB8|x;       //0xb8 represents Page 0    
    65.     delay(500);
    66.     IOSET1= 0x0CB8|x;       //0xb8 represents Page 0    
    67.     delay(500);
    68. }
    69.  
    70. //Function to Scroll Strings
    71. void setstartline(unsigned char z)            
    72. {    
    73.     ctrloff();    
    74.     IOSET1=0x1CC0|z;       //0xc0 represents Line 0    
    75.     delay(500);    
    76.     IOSET1=0x0CC0|z;       //0xc0 represents Line 0                      
    77.     delay(500);
    78. }
    79.  
    80. void lcddata(unsigned char *value,unsigned int limit)
    81. {    
    82.     unsigned int i;
    83.     unsigned char v;
    84.     for(i=0;i<limit;i++)    
    85.     {        
    86.         if(c<64)        
    87.         {            
    88.             v=value[i];    
    89.             IOSET1=0x1500|v;
    90.             delay(500);            
    91.             IOSET1=0x0500|v;        
    92.             delay(500);
    93.             c++;        
    94.         }        
    95.         else        
    96.         {            
    97.             setcolumn(c);            
    98.             IOSET1=0x1600|v;        
    99.             delay(500);            
    100.             IOSET1=0x0600|v;            
    101.             delay(500);
    102.             c++;        
    103.         }        
    104.         if(c>127)          
    105.         return;    
    106.     }
    107. }
    108.  
    109. void lcdputs(unsigned char y,unsigned char x,unsigned char *str)
    110. {    
    111.     unsigned char i;    
    112.     unsigned int a;    
    113.     setcolumn(y);    
    114.     setpage(x);    
    115.     for(i=0;str[i]!=0;i++)    
    116.     {        
    117.         a=(*(str+i)-32);        
    118.         a*=5;        
    119.         lcddata(&font[a],5);    
    120.     }
    121. }
    122.  
    123. void clrlcd()
    124. {    
    125.     unsigned char i,j;    
    126.     for (i=0;i < 8;i++)    
    127.     {    
    128.         setpage(i);    
    129.         setcolumn(0);        
    130.         for (j= 0 ;j < 128; j++)        
    131.         lcddata(&z,1);    
    132.     }
    133. }
    134.  
    135. unsigned char ar0[]="***************  ";
    136. unsigned char ar1[]="ENGINEERSGARAGE";
    137. unsigned char ar2[]="Inspiring Creations   ";                
    138. unsigned char ar3[]="**************  ";
    139.  
    140. int main()
    141. {    
    142.     unsigned char i;    
    143.     clrlcd();    
    144.     displayon();    
    145.     setcolumn(0);    
    146.     setpage(0);    
    147.     lcdputs(0,1,ar0);    
    148.     lcdputs(0,2,ar1);    
    149.     lcdputs(0,3,ar2);    
    150.     lcdputs(0,4,ar3);    
    151.     delay(65000);    
    152.     delay(65000);    
    153.     for(i=0;i<5;i++)    
    154.     {        
    155.         displayoff();        
    156.         delay(65000);        
    157.         displayon();        
    158.         delay(65000);        
    159.         delay(65000);    
    160.     }    
    161.     i=0;    
    162.     while(1)    
    163.     {        
    164.         setstartline(i++);     //Function to Scroll Strings        
    165.         delay(40000);    
    166.     }
    167. }
    168.  
    169.  
    170. //font.h
    171.  
    172. unsigned char font[] = {
    173. 0x00, 0x00, 0x00, 0x00, 0x00,// (space)
    174. 0x00, 0x00, 0x5F, 0x00, 0x00,// !
    175. 0x00, 0x07, 0x00, 0x07, 0x00,// "
    176. 0x14, 0x7F, 0x14, 0x7F, 0x14,// #
    177. 0x24, 0x2A, 0x7F, 0x2A, 0x12,// $
    178. 0x23, 0x13, 0x08, 0x64, 0x62,// %
    179. 0x36, 0x49, 0x55, 0x22, 0x50,// &
    180. 0x00, 0x05, 0x03, 0x00, 0x00,// '
    181. 0x00, 0x1C, 0x22, 0x41, 0x00,// (
    182. 0x00, 0x41, 0x22, 0x1C, 0x00,// )
    183. 0x08, 0x2A, 0x1C, 0x2A, 0x08,// *
    184. 0x08, 0x08, 0x3E, 0x08, 0x08,// +
    185. 0x00, 0x50, 0x30, 0x00, 0x00,// ,
    186. 0x08, 0x08, 0x08, 0x08, 0x08,// -
    187. 0x00, 0x30, 0x30, 0x00, 0x00,// .
    188. 0x20, 0x10, 0x08, 0x04, 0x02,// /
    189. 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0
    190. 0x00, 0x42, 0x7F, 0x40, 0x00,// 1
    191. 0x42, 0x61, 0x51, 0x49, 0x46,// 2
    192. 0x21, 0x41, 0x45, 0x4B, 0x31,// 3
    193. 0x18, 0x14, 0x12, 0x7F, 0x10,// 4
    194. 0x27, 0x45, 0x45, 0x45, 0x39,// 5
    195. 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6
    196. 0x01, 0x71, 0x09, 0x05, 0x03,// 7
    197. 0x36, 0x49, 0x49, 0x49, 0x36,// 8
    198. 0x06, 0x49, 0x49, 0x29, 0x1E,// 9
    199. 0x00, 0x36, 0x36, 0x00, 0x00,// :
    200. 0x00, 0x56, 0x36, 0x00, 0x00,// ;
    201. 0x00, 0x08, 0x14, 0x22, 0x41,// <
    202. 0x14, 0x14, 0x14, 0x14, 0x14,// =
    203. 0x41, 0x22, 0x14, 0x08, 0x00,// >
    204. 0x02, 0x01, 0x51, 0x09, 0x06,// ?
    205. 0x32, 0x49, 0x79, 0x41, 0x3E,// @
    206. 0x7E, 0x11, 0x11, 0x11, 0x7E,// A
    207. 0x7F, 0x49, 0x49, 0x49, 0x36,// B
    208. 0x3E, 0x41, 0x41, 0x41, 0x22,// C
    209. 0x7F, 0x41, 0x41, 0x22, 0x1C,// D
    210. 0x7F, 0x49, 0x49, 0x49, 0x41,// E
    211. 0x7F, 0x09, 0x09, 0x01, 0x01,// F
    212. 0x3E, 0x41, 0x41, 0x51, 0x32,// G
    213. 0x7F, 0x08, 0x08, 0x08, 0x7F,// H
    214. 0x00, 0x41, 0x7F, 0x41, 0x00,// I
    215. 0x20, 0x40, 0x41, 0x3F, 0x01,// J
    216. 0x7F, 0x08, 0x14, 0x22, 0x41,// K
    217. 0x7F, 0x40, 0x40, 0x40, 0x40,// L
    218. 0x7F, 0x02, 0x04, 0x02, 0x7F,// M
    219. 0x7F, 0x04, 0x08, 0x10, 0x7F,// N
    220. 0x3E, 0x41, 0x41, 0x41, 0x3E,// O
    221. 0x7F, 0x09, 0x09, 0x09, 0x06,// P
    222. 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q
    223. 0x7F, 0x09, 0x19, 0x29, 0x46,// R
    224. 0x46, 0x49, 0x49, 0x49, 0x31,// S
    225. 0x01, 0x01, 0x7F, 0x01, 0x01,// T
    226. 0x3F, 0x40, 0x40, 0x40, 0x3F,// U
    227. 0x1F, 0x20, 0x40, 0x20, 0x1F,// V
    228. 0x7F, 0x20, 0x18, 0x20, 0x7F,// W
    229. 0x63, 0x14, 0x08, 0x14, 0x63,// X
    230. 0x03, 0x04, 0x78, 0x04, 0x03,// Y
    231. 0x61, 0x51, 0x49, 0x45, 0x43,// Z
    232. 0x00, 0x00, 0x7F, 0x41, 0x41,// [
    233. 0x02, 0x04, 0x08, 0x10, 0x20,// "\"
    234. 0x41, 0x41, 0x7F, 0x00, 0x00,// ]
    235. 0x04, 0x02, 0x01, 0x02, 0x04,// ^
    236. 0x40, 0x40, 0x40, 0x40, 0x40,// _
    237. 0x00, 0x01, 0x02, 0x04, 0x00,// `
    238. 0x20, 0x54, 0x54, 0x54, 0x78,// a
    239. 0x7F, 0x48, 0x44, 0x44, 0x38,// b
    240. 0x38, 0x44, 0x44, 0x44, 0x20,// c
    241. 0x38, 0x44, 0x44, 0x48, 0x7F,// d
    242. 0x38, 0x54, 0x54, 0x54, 0x18,// e
    243. 0x08, 0x7E, 0x09, 0x01, 0x02,// f
    244. 0x08, 0x14, 0x54, 0x54, 0x3C,// g
    245. 0x7F, 0x08, 0x04, 0x04, 0x78,// h
    246. 0x00, 0x44, 0x7D, 0x40, 0x00,// i
    247. 0x20, 0x40, 0x44, 0x3D, 0x00,// j
    248. 0x00, 0x7F, 0x10, 0x28, 0x44,// k
    249. 0x00, 0x41, 0x7F, 0x40, 0x00,// l
    250. 0x7C, 0x04, 0x18, 0x04, 0x78,// m
    251. 0x7C, 0x08, 0x04, 0x04, 0x78,// n
    252. 0x38, 0x44, 0x44, 0x44, 0x38,// o
    253. 0x7C, 0x14, 0x14, 0x14, 0x08,// p
    254. 0x08, 0x14, 0x14, 0x18, 0x7C,// q
    255. 0x7C, 0x08, 0x04, 0x04, 0x08,// r
    256. 0x48, 0x54, 0x54, 0x54, 0x20,// s
    257. 0x04, 0x3F, 0x44, 0x40, 0x20,// t
    258. 0x3C, 0x40, 0x40, 0x20, 0x7C,// u
    259. 0x1C, 0x20, 0x40, 0x20, 0x1C,// v
    260. 0x3C, 0x40, 0x30, 0x40, 0x3C,// w
    261. 0x44, 0x28, 0x10, 0x28, 0x44,// x
    262. 0x0C, 0x50, 0x50, 0x50, 0x3C,// y
    263. 0x44, 0x64, 0x54, 0x4C, 0x44,// z
    264. 0x00, 0x08, 0x36, 0x41, 0x00,// {
    265. 0x00, 0x00, 0x7F, 0x00, 0x00,// |
    266. 0x00, 0x41, 0x36, 0x08, 0x00,// }
    267. };
    268. [/i][/i]


    If you find anything wrong plzzzz comment
    Thank you in advance.... plzzzzz reply
     
    Last edited by a moderator: Nov 24, 2012
Loading...