📄 lcm.lst
字号:
206 {
207 1 uint8 data ucTMP;
208 1
209 1 /*******************************
210 1 *** Switch to ExSRAM ***
211 1 *******************************/
212 1 SFRPAGE = 0x00;
213 1 EMI0CF = 0x27; // 0010_01_11: ALE: 2SYSCLK. SRAM Split Mode.
214 1 EMI0TC = 0xff; // 10_0111_10: AST:2,nWR/nRd:4SYSCLK,AHT:2.
215 1
216 1 SFRPAGE = 0x0f;
217 1 ucTMP = ucP4DATA & 0xC0 | 16; // ExSRAM Page 16;
218 1 P4 = ucTMP; // ExSRAM Page Setting.
219 1 SFRPAGE = 0x00;
220 1 }
221
222
223 /***********************************************************************
224 * 名称:LCD_Reset()
225 * 功能:对LCM复位,对相关I/O口初始化
226 * 入口参数:无
227 * 出口参数:无
228 * 说明:
229 ***********************************************************************/
230 void LCD_Reset(void)
231 {
232 1 LCD_RSTn = 0;
233 1 DmS(200);
234 1 LCD_RSTn = 1;
235 1 }
236
237
238 /***********************************************************************
239 * 名称:LCD_WriteCommand()
240 * 功能:写命令子程序。(发送命令前,不检查液晶模块的状态)
241 * 入口参数:ucCMD (要写入LCM的命令字)
C51 COMPILER V7.06 LCM 09/04/2006 09:56:02 PAGE 5
242 * 出口参数:无
243 * 说明:函数会设置LCM数据总线为输出方式
244 ***********************************************************************/
245 void LCD_WriteCommand(uint8 ucCMD)
246 {
247 1 LCD_COMMAND = ucCMD;
248 1 }
249
250 /***********************************************************************
251 * 名称:LCD_WriteData()
252 * 功能:写数据子程序。(发送数据前,不检查液晶模块的状态)
253 * 入口参数:ucDATA (要写入LCM的数据)
254 * 出口参数:无
255 * 说明:函数会设置LCM数据总线为输出方式
256 ***********************************************************************/
257 void LCD_WriteData(uint8 ucDATA)
258 {
259 1 LCD_DATA = ucDATA;
260 1 }
261
262
263 /***********************************************************************
264 * 名称:LCD_ReadState()
265 * 功能:读取状态字子程序。
266 * 入口参数:无
267 * 出口参数:返回值即为读出的状态字
268 * 说明:函数会设置LCM数据总线为输入方式
269 ***********************************************************************/
270 unsigned char LCD_ReadState(void)
271 {
272 1 return(LCD_STATUS);
273 1 }
274
275
276 /***********************************************************************
277 * 名称:LCD_ReadData()
278 * 功能:读取数据子程序。
279 * 入口参数:无
280 * 出口参数:返回值即为读出的数据
281 * 说明:函数会设置LCM数据总线为输入方式
282 ***********************************************************************/
283 unsigned char LCD_ReadData(void)
284 {
285 1 return(LCD_DATA);
286 1 }
287
288 /***********************************************************************
289 * 名称:LCD_ClearAll()
290 * 功能:LCD填充。以图形方式进行填充,起始地址为0x0000。
291 * 入口参数:ucDATA 要填充的数据
292 * 出口参数:无
293 ***********************************************************************/
294 void LCD_ClearAll(void)
295 {
296 1 uint16 idata i;
297 1 uint8 idata j;
298 1
299 1 LCD_CS(); /* ExSRAM Page 16. */
300 1
301 1 LCD_WriteCommand(0xB0); /* SET PAGE ADDRESS */
302 1 LCD_WriteCommand(0x10); /* SET COLUMN ADDRESS MSB(00000000) */
303 1 LCD_WriteCommand(0x00); /* SET COLUMN ADDRESS LSB(00000000) */
C51 COMPILER V7.06 LCM 09/04/2006 09:56:02 PAGE 6
304 1 LCD_WriteCommand(0x89); /* SET RAM ADDRESS CONTROL */
305 1
306 1 for(i=0; i<3840; i++)
307 1 LCD_WriteData(0x00);
308 1
309 1 for(i=0; i<240; i++)
310 1 {
311 2 for(j=0; j<16; j++)
312 2 {
313 3 LCD_WriteCommand(0xB0 + j ); /* ROW / 8 */
314 3 LCD_WriteCommand(0x10 + i>>4); /* COL'S MSB */
315 3 LCD_WriteCommand( i % 16 ); /* COL'S LSB */
316 3 LCD_WriteData(0x00);
317 3 // DmS(20);
318 3 }
319 2 }
320 1
321 1 ExInSRAM_Select(0); //
322 1 }
323
324 /***********************************************************************
325 * 名称:LCD_Initialize()
326 * 功能:LCM初始化,将LCM初始化为纯图形模式,显示起始地址为0x0000
327 * 入口参数:无
328 * 出口参数:无
329 * 说明:
330 ***********************************************************************/
331 void LCD_Initialize(void)
332 {
333 1 LCD_Reset();
334 1 DmS(100);
335 1
336 1 /****************************
337 1 *** 240128-052W
338 1 ****************************/
339 1 LCD_CS(); /* ExSRAM Page 16. */
340 1
341 1 LCD_WriteCommand(0xE2); /* System reset*/
342 1 DmS(1);
343 1 LCD_WriteCommand(0xEB); /* Set lcd bias ratio: 111010_10 */
344 1 LCD_WriteCommand(0x25); /* Set mux rate and temperature compensation*/
345 1 LCD_WriteCommand(0x81);
346 1 LCD_WriteCommand(0xA5); /* Set gain and potentiometer 1_01_00101 */
347 1 LCD_WriteCommand(0x2F); /* Set power control 00101_1_11 */
348 1 // LCD_WriteCommand(0x30); /* Set Advance Product Configuration 0011000_0 */
349 1 // LCD_WriteCommand(0x16); /* */
350 1 LCD_WriteCommand(0xAF); /* Display Enable: 1010111_1 */
351 1 // LCD_WriteCommand(0xAE); /* Sleep Mode: 1010111_0 */
352 1 // LCD_WriteCommand(0xE3); /* NOP: 11100011 */
353 1 // LCD_WriteCommand(0xEE); /* Reset Cursor Mode: 1110111_0 */
354 1 // LCD_WriteCommand(0xEF); /* Set Cursor Mode: 1110111_1 */
355 1 DmS(10);
356 1
357 1 LCD_WriteCommand(0x40); /* Set start line: 01_000000 */
358 1 LCD_WriteCommand(0xA4); /* Set all pixel on: 1010010_DC[1] */
359 1 LCD_WriteCommand(0xA6); /* Set inverse display: 1010011_DC[0] */
360 1 LCD_WriteCommand(0x89); /* Set ram address control: 10001_001 */
361 1 LCD_WriteCommand(0xC8); /* Set lcd mapping control: 1100_1_0__0 */
362 1
363 1 /****************************
364 1 *** 240128-051
365 1 ****************************/
C51 COMPILER V7.06 LCM 09/04/2006 09:56:02 PAGE 7
366 1 // LCD_WriteCommand(0xE2); /*system reset*/
367 1 // DmS(10);
368 1 // LCD_WriteCommand(0xEA); /*set lcd bias ratio*/
369 1 // LCD_WriteCommand(0x25); /*set mux rate and temperature compensation*/
370 1 // LCD_WriteCommand(0x81);
371 1 // LCD_WriteCommand(0xBF); /*set gain and potentiometer(double-byte command)*/
372 1 // LCD_WriteCommand(0x2F); /*set power control*/
373 1 // LCD_WriteCommand(0xAF); /*set display enable*/
374 1 // DmS(10);
375 1 // LCD_WriteCommand(0x40); /*set start line*/
376 1 // LCD_WriteCommand(0xA4); /*set all-pixel-on*/
377 1 // LCD_WriteCommand(0xA6); /*set inverse display*/
378 1 // LCD_WriteCommand(0x89); /*set ram address control*/
379 1 // LCD_WriteCommand(0xC8); /*set lcd mapping control*/
380 1
381 1 ExInSRAM_Select(0); //
382 1 }
383
384 /****************************************************************************
385 * 名称:LCD_UpdateByte()
386 * 功能:在指定位置上更新8个点。
387 * 入口参数:x 指定点所在列的位置
388 * y 指定点所在行的位置
389 * 出口参数:
390 * 说明:
391 ****************************************************************************/
392 void LCD_UpdateByte(uint8 x, uint8 y, uint8 ucDATA)
393 {
394 1 if( x >= (GUI_LCM_XMAX - 8) ) /* 参数过滤 */
395 1 return;
396 1 if( y >= (GUI_LCM_YMAX - 8) ) /* 参数过滤 */
397 1 return;
398 1
399 1 LCD_CS(); /* ExSRAM Page 16 */
400 1
401 1 LCD_WriteCommand(0xB0 + y>>3); /* ROW / 8 */
402 1 LCD_WriteCommand(0x10 + x>>4); /* COL'S MSB */
403 1 LCD_WriteCommand( x % 16 ); /* COL'S LSB */
404 1
405 1 LCD_WriteData(ucDATA);
406 1 // LCD_WriteData(0xff);
407 1 DmS(20);
408 1
409 1 ExInSRAM_Select(0); /* Switch back to InSRAM */
410 1 }
411
412 /****************************************************************************
413 * 名称:LCD_UpdatePoint()
414 * 功能:在指定位置上画点,刷新某一点。
415 * 入口参数:x 指定点所在列的位置
416 * y 指定点所在行的位置
417 * bCOLOR 0/1 显示/不显示
418 * 出口参数:
419 * 说明:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -