[DemoCode下载] ML51单片机的LCD charge pump模式驱动测试

[复制链接]
 楼主| xinxianshi 发表于 2024-2-20 11:45 | 显示全部楼层 |阅读模式
  1. /*---------------------------------------------------------------------------------------------------------*/
  2. /*                                                                                                         */
  3. /* Copyright(c) 2020 Nuvoton Technology Corp. All rights reserved.                                         */
  4. /*                                                                                                         */
  5. /*---------------------------------------------------------------------------------------------------------*/

  6. //***********************************************************************************************************
  7. //  Website: http://www.nuvoton.com
  8. //  E-Mail : MicroC-8bit@nuvoton.com
  9. //  Date   : Apr/29/2020
  10. //***********************************************************************************************************

  11. /***********************************************************************************************************
  12.   File Function: ML51 LCD charge pump mode driving test sample code

  13. *  [url=home.php?mod=space&uid=247401]@brief[/url] LCD connect and LCD module circuit shor test based on charge pump interrupt.
  14. *  @param  u8LCDPowerType  / u8LCDVSource  / u8DrivingType  / u8BiasLevel   / u8ComNum    /u8DrivingVol
  15. *  @param   printftemp value adjust is based on LCD panel status adjust, the largest value is 0x3FF.
  16. *  [url=home.php?mod=space&uid=266161]@return[/url] LCD charge pump counter over 0x20 com/seg.
  17. //***********************************************************************************************************/

  18. #include "ML51.H"

  19. bit lcdintflag;
  20. unsigned int printftemp=0;
  21. unsigned char lcderrorcounter=0;

  22. void LCD_ISR (void) interrupt 31
  23. {
  24. _push_(SFRS);
  25.   SFRS=3;
  26.   printftemp = ((LCDCPCT1<<8)&0xFF00) + LCDCPCT0;
  27.   if (printftemp>0x40)
  28.   {
  29.       lcdintflag = 1;
  30.   }
  31.   EA = 0 ;
  32.   nop;
  33. _pop_(SFRS);
  34. }  

  35. void LCD_IO_Init(void)
  36. {
  37. /*TSLiu */
  38. /* Enable COM pin MFP */
  39.     MFP_P25_LCD_COM0;
  40.     MFP_P24_LCD_COM1;
  41.     MFP_P41_LCD_COM2;
  42.     MFP_P40_LCD_COM3;
  43.     MFP_P45_LCD_COM4;
  44.     MFP_P44_LCD_COM5;
  45.     MFP_P43_LCD_COM6;
  46.     MFP_P42_LCD_COM7;

  47. /* Enable SEG pin MFP */
  48.     MFP_P06_LCD_SEG0;
  49.     MFP_P07_LCD_SEG1;
  50.     MFP_P34_LCD_SEG2;
  51.     MFP_P35_LCD_SEG3;
  52.     MFP_P20_LCD_SEG4;
  53.     MFP_P21_LCD_SEG5;
  54.     MFP_P26_LCD_SEG6;
  55.     MFP_P27_LCD_SEG7;
  56.     MFP_P64_LCD_SEG8;
  57.     MFP_P65_LCD_SEG9;
  58.     MFP_P66_LCD_SEG10;
  59.     MFP_P67_LCD_SEG11;
  60.     MFP_P30_LCD_SEG12;
  61. //    MFP_P31_LCD_SEG13;
  62.     MFP_P32_LCD_SEG14;
  63.     MFP_P33_LCD_SEG15;
  64.     MFP_P47_LCD_SEG16;
  65.     MFP_P46_LCD_SEG17;
  66.     MFP_P17_LCD_SEG18;
  67.     MFP_P16_LCD_SEG19;
  68.     MFP_P15_LCD_SEG20;
  69.     MFP_P14_LCD_SEG21;
  70.     MFP_P60_LCD_SEG22;
  71.     MFP_P61_LCD_SEG23;
  72.     MFP_P62_LCD_SEG24;
  73.     MFP_P63_LCD_SEG25;

  74. /* DH1 DH2 */
  75.     MFP_P11_LCD_DH1;
  76.     MFP_P12_LCD_DH2;
  77. }


  78. //----------------------------------------------------------------------------------------------//
  79. void main (void)
  80. {

  81.   unsigned char i,j;
  82.   Enable_UART0_VCOM_printf();
  83.   ALL_GPIO_QUASI_MODE;
  84.   /* As defaut all multi function define as GPIO */

  85.   LCD_IO_Init();

  86.   LCD_Clock_Setting(LIRC, LCD_FREQ_DIV2);
  87.   LCD_Open(TYPE_A, Internal_VCP, LCD_CPVOL_3_6V, BIAS_1_4, LCD_8COM);
  88.   LCD_Current_Mode(Buffer_Mode,TurnOn_All);

  89.   LCD_PowerDown_Display(LCD_ON);
  90.   LCD_Enable();
  91.   LCD_SetAllPixels(Enable);

  92.   Timer0_Delay(24000000,500,1000);
  93.   LCD_SetAllPixels(Disable);

  94.   /* Enable LCD chargepump interrupt */
  95.   LCD_Interrupt_Initial(Enable, LCD_CPRD_INT,0);
  96.   ENABLE_GLOBAL_INTERRUPT;
  97.   


  98. /* Routine driving each seg to test LCD module */
  99.   SFRS=0; printf(" \n LCD Charge Pump Test Start ... ");
  100.   for (i=0;i<8;i++)
  101.     {
  102.       for (j=0;j<32;j++)
  103.         {
  104.            LCD_SetOnePixel(i,j,Enable);
  105.            if (lcdintflag)
  106.             {
  107.               SFRS=0; printf(" \n LCD pump counter = 0x%x",  printftemp);
  108.               printf(" \n LCD com = %bd",  j);printf("     LCD seg = %bd",  i);
  109.               lcderrorcounter++;
  110.               lcdintflag = 0;
  111.             }
  112.             Timer0_Delay(24000000,100,1000);
  113.             EA = 1;
  114.           }
  115.       SFRS=0; printf(" \n LCD test continue ... COM %bx", i);
  116.     LCD_SetAllPixels(Disable);
  117.     }

  118.     if (lcderrorcounter==0)
  119.     {
  120.        SFRS=0; printf(" \n LCD test all pass ! ");
  121.     }
  122.     else
  123.     {
  124.        SFRS=0; printf(" \n LCD test finish ! Total error = %bd", lcderrorcounter);
  125.     }
  126.     LCD_SetAllPixels(Enable);
  127.     while(1);
  128. }


 楼主| xinxianshi 发表于 2024-2-20 11:46 | 显示全部楼层
#include "ML51.H":包含ML51系列单片机的头文件。

定义了一些全局变量和标志位,如lcdintflag表示LCD充电泵中断标志,printftemp用于存储LCD充电泵计数器的值,lcderrorcounter用于统计LCD测试中的错误次数。

LCD_ISR(void) interrupt 31:LCD的充电泵中断服务程序,当LCD充电泵计数器超过0x40时,设置lcdintflag标志,并禁止全局中断。

LCD_IO_Init(void):LCD的IO初始化函数,配置了LCD的COM和SEG引脚。

main()函数:

启用UART0用于printf输出。
配置所有GPIO为准双向模式。
调用LCD_IO_Init()初始化LCD的COM和SEG引脚。
配置LCD的时钟和开启LCD模块。
执行LCD的充电泵测试:
设置充电泵频率。
打开LCD显示和使能所有像素。
延时一段时间。
关闭所有像素。
开启LCD的充电泵中断,并使能全局中断。
循环测试LCD每个COM和SEG的像素,并检查充电泵计数器是否超过阈值。
若超过阈值,则打印相应的信息并增加错误计数。
继续进行测试直到所有COM和SEG测试完毕。
打印测试结果。
 楼主| xinxianshi 发表于 2024-2-20 11:46 | 显示全部楼层
这段代码的主要功能是通过LCD的充电泵模式进行驱动测试,检测LCD的COM和SEG是否正常工作,并打印测试结果。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

102

主题

1019

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部

102

主题

1019

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部