打印
[牛人杂谈]

如何使用LCDView完成Com/Segment LCD 项目

[复制链接]
416|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
CD, COM, LCD, se, vi
NuTool-LCDView 是一款用于辅助 COM/SEG LCD 开发的软件工具,特色是能让开发者在不需要有实体 LCD 屏幕的情况下,即可开发、除错、显示效果。操作步骤使用图形化接口点选设定以及拖拉放的方式,开发者可以依照需求自定义名称、COM/SEG 规划,快速完成 LCD 显示设置,并自动产生对应的定义代码,再结合 BSP 与 API,即可直接于 LCD 上与 PC 上展现设计效果。
本范例代码将示范如何使用 LCDView 软件工具,开发与除错,逐步完成 COM/SEG LCD 项目开发。
1.1 原理
1.1.1 LCDView 功能说明
NuTool-LCDView 的功能可以分为 Create Mode 与 Emulator Mode 两种模式。开发时需要先在Create Mode 下完成 LCD 屏幕的图标配置与 COM/SEG Table 的设定,开发完成并烧录至 MCU后,可以切换到 Emulator Mode 在 NuTool-LCDView 上查看显示效果。LCDView 提供单机版本
与嵌入在 Keil IDE 与 IAR IDE 的版本,让开发者可以在 IDE 环境下配合使用 LCDView 单步调试与侦错。
界面介绍与使用操作,可以参考 NuTool-LCDView 用户手册。
1.1.2 Supported Chips
NuTool-LCDView 目前支持以 Arm® Cortex®-M23 为核心的 M254/M256/M258 系列与M2354 系列,以及 8-bit-8051 的 ML54 系列与 ML56 系列。
1.2 执行步骤
使用 NuTool-LCDView 完成项目的执行步骤可分为四大阶段,第一阶段:准备相关硬件与软件,第二阶段:进入 Create Mode 编辑内容,第三阶段:代码编辑,第四阶段:进入 Emulator Mode 模拟与除错。
以下就各项阶段详细说明执行步骤。
1.2.1 第一阶段:准备相关硬件与软件
在此次范例程序中,会使用到的硬件资源为 NuMaker-M258KG 以及型号 TNLCDSub_M258K的 LCD 上板。
软件工具需要使用三个项目,分别为 NuTool-LCDView,NuTool-PinConfigure,以及 Nu-Link Keil Driver。NuTool-PinConfigure 是提供引脚配置的工具,配置完后可以汇入至 NuToolLCDView,以直接在 COM/SEG table 上显示对应的 Pin Number;Nu-Link Keil Driver 则是作为支持让 NuTool-LCDView 嵌入在 Keil IDE 中,以方便调适与除错。实际使用将于第二阶段:
进入 Create Mode 编辑内容与第四阶段:进入 Emulator Mode 模拟与除错分别说明。


内容是非常的刺激,想了解下载附件吧。
en-us--EC_M258_LCD_View_V1.00.zip (5.4 MB)




使用特权

评论回复
沙发
xuanhuanzi|  楼主 | 2022-12-20 13:04 | 只看该作者
/**************************************************************************//**
* [url=home.php?mod=space&uid=288409]@file[/url]     main.c
* [url=home.php?mod=space&uid=895143]@version[/url]  V3.00
* [url=home.php?mod=space&uid=247401]@brief[/url]    This example code uses NK-M258KG as an example to show how to finish
*                    a COM/SEG LCD project with using NuTool-LCDView and print text on RHE6616TP01(8-COM, 40-SEG, 1/4 Bias) LCD.
*
*
* SPDX-License-Identifier: Apache-2.0
* [url=home.php?mod=space&uid=17282]@CopyRight[/url] (C) 2022 Nuvoton Technology Corp. All rights reserved.
******************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include "NuMicro.h"
#include "lcdlib.h"

/*---------------------------------------------------------------------------------------------------------*/
/* Functions and variables declaration                                                                     */
/*---------------------------------------------------------------------------------------------------------*/

static S_LCD_CFG_T g_LCDCfg =
{
    __LIRC,                             /*!< LCD clock source frequency */
    LCD_COM_DUTY_1_8,                   /*!< COM duty */
    LCD_BIAS_LV_1_4,                    /*!< Bias level */
    64,                                 /*!< Operation frame rate */
    LCD_WAVEFORM_TYPE_A_NORMAL,         /*!< Waveform type */
    LCD_DISABLE_ALL_INT,                /*!< Interrupt source */
    LCD_HIGH_DRIVING_OFF_AND_BUF_ON,    /*!< Driving mode */
    LCD_VOLTAGE_SOURCE_CP,              /*!< Voltage source */
};

void LCD_Init(void);
void SYS_Init(void);
void LCD_Start(void);
void M258KG_init_lcd(void);

/*----------------------------------------------------------------------*/
/* M258KG_init_lcd() is generated from NuTool-PinConfigure, which defines multifunction pin of LCD */
/*----------------------------------------------------------------------*/
void M258KG_init_lcd(void)
{
    /*
    Summary of LCD pin usage:
        COM 0~3   : PB.5, PB.4, PB.3, PB.2
        COM 4~5   : PD.11, PD.10
        COM 6~7   : PE.13, PC.8
        SEG 0~1   : PB.0, PB.1
        SEG 2~3   : PC.9, PC.10
        SEG 4~13  : PB.6, PB.7, PB.8, PB.9, PB.10, PB.11, PB.12, PB.13, PB.14, PB.15
        SEG 14    : PC.14
        SEG 15~16 : PE.6, PE.7
        SEG 17~20 : PE.11, PE.10, PE.9, PE.8
        SEG 21~25 : PD.13, PD.0, PD.1, PD.2, PD.3
        SEG 26~31 : PC.0, PC.1, PC.2, PC.3, PC.4, PC.5
        SEG 32~33 : PD.8, PD.9
        SEG 34    : PE.14
        SEG 35    : PF.15
        SEG 36~37 : PA.6, PA.7
        SEG 38~39 : PC.6, PC.7
    */
    SYS->GPA_MFPL &= ~(SYS_GPA_MFPL_PA7MFP_Msk | SYS_GPA_MFPL_PA6MFP_Msk);
    SYS->GPA_MFPL |= (SYS_GPA_MFPL_PA7MFP_LCD_SEG37 | SYS_GPA_MFPL_PA6MFP_LCD_SEG36);
    SYS->GPB_MFPH &= ~(SYS_GPB_MFPH_PB15MFP_Msk | SYS_GPB_MFPH_PB14MFP_Msk | SYS_GPB_MFPH_PB13MFP_Msk | SYS_GPB_MFPH_PB12MFP_Msk | SYS_GPB_MFPH_PB11MFP_Msk | SYS_GPB_MFPH_PB10MFP_Msk |
                       SYS_GPB_MFPH_PB9MFP_Msk | SYS_GPB_MFPH_PB8MFP_Msk);
    SYS->GPB_MFPH |= (SYS_GPB_MFPH_PB15MFP_LCD_SEG13 | SYS_GPB_MFPH_PB14MFP_LCD_SEG12 | SYS_GPB_MFPH_PB13MFP_LCD_SEG11 | SYS_GPB_MFPH_PB12MFP_LCD_SEG10 | SYS_GPB_MFPH_PB11MFP_LCD_SEG9 |
                      SYS_GPB_MFPH_PB10MFP_LCD_SEG8 | SYS_GPB_MFPH_PB9MFP_LCD_SEG7 | SYS_GPB_MFPH_PB8MFP_LCD_SEG6);
    SYS->GPB_MFPL &= ~(SYS_GPB_MFPL_PB7MFP_Msk | SYS_GPB_MFPL_PB6MFP_Msk | SYS_GPB_MFPL_PB5MFP_Msk | SYS_GPB_MFPL_PB4MFP_Msk | SYS_GPB_MFPL_PB3MFP_Msk | SYS_GPB_MFPL_PB2MFP_Msk | SYS_GPB_MFPL_PB1MFP_Msk |
                       SYS_GPB_MFPL_PB0MFP_Msk);
    SYS->GPB_MFPL |= (SYS_GPB_MFPL_PB7MFP_LCD_SEG5 | SYS_GPB_MFPL_PB6MFP_LCD_SEG4 | SYS_GPB_MFPL_PB5MFP_LCD_COM0 | SYS_GPB_MFPL_PB4MFP_LCD_COM1 | SYS_GPB_MFPL_PB3MFP_LCD_COM2 |
                      SYS_GPB_MFPL_PB2MFP_LCD_COM3 | SYS_GPB_MFPL_PB1MFP_LCD_SEG1 | SYS_GPB_MFPL_PB0MFP_LCD_SEG0);
    SYS->GPC_MFPH &= ~(SYS_GPC_MFPH_PC14MFP_Msk | SYS_GPC_MFPH_PC10MFP_Msk | SYS_GPC_MFPH_PC9MFP_Msk | SYS_GPC_MFPH_PC8MFP_Msk);
    SYS->GPC_MFPH |= (SYS_GPC_MFPH_PC14MFP_LCD_SEG14 | SYS_GPC_MFPH_PC10MFP_LCD_SEG3 | SYS_GPC_MFPH_PC9MFP_LCD_SEG2 | SYS_GPC_MFPH_PC8MFP_LCD_COM7);
    SYS->GPC_MFPL &= ~(SYS_GPC_MFPL_PC7MFP_Msk | SYS_GPC_MFPL_PC6MFP_Msk | SYS_GPC_MFPL_PC5MFP_Msk | SYS_GPC_MFPL_PC4MFP_Msk | SYS_GPC_MFPL_PC3MFP_Msk | SYS_GPC_MFPL_PC2MFP_Msk | SYS_GPC_MFPL_PC1MFP_Msk |
                       SYS_GPC_MFPL_PC0MFP_Msk);
    SYS->GPC_MFPL |= (SYS_GPC_MFPL_PC7MFP_LCD_SEG39 | SYS_GPC_MFPL_PC6MFP_LCD_SEG38 | SYS_GPC_MFPL_PC5MFP_LCD_SEG31 | SYS_GPC_MFPL_PC4MFP_LCD_SEG30 | SYS_GPC_MFPL_PC3MFP_LCD_SEG29 |
                      SYS_GPC_MFPL_PC2MFP_LCD_SEG28 | SYS_GPC_MFPL_PC1MFP_LCD_SEG27 | SYS_GPC_MFPL_PC0MFP_LCD_SEG26);
    SYS->GPD_MFPH &= ~(SYS_GPD_MFPH_PD13MFP_Msk | SYS_GPD_MFPH_PD11MFP_Msk | SYS_GPD_MFPH_PD10MFP_Msk | SYS_GPD_MFPH_PD9MFP_Msk | SYS_GPD_MFPH_PD8MFP_Msk);
    SYS->GPD_MFPH |= (SYS_GPD_MFPH_PD13MFP_LCD_SEG21 | SYS_GPD_MFPH_PD11MFP_LCD_COM4 | SYS_GPD_MFPH_PD10MFP_LCD_COM5 | SYS_GPD_MFPH_PD9MFP_LCD_SEG33 | SYS_GPD_MFPH_PD8MFP_LCD_SEG32);
    SYS->GPD_MFPL &= ~(SYS_GPD_MFPL_PD3MFP_Msk | SYS_GPD_MFPL_PD2MFP_Msk | SYS_GPD_MFPL_PD1MFP_Msk | SYS_GPD_MFPL_PD0MFP_Msk);
    SYS->GPD_MFPL |= (SYS_GPD_MFPL_PD3MFP_LCD_SEG25 | SYS_GPD_MFPL_PD2MFP_LCD_SEG24 | SYS_GPD_MFPL_PD1MFP_LCD_SEG23 | SYS_GPD_MFPL_PD0MFP_LCD_SEG22);
    SYS->GPE_MFPH &= ~(SYS_GPE_MFPH_PE14MFP_Msk | SYS_GPE_MFPH_PE13MFP_Msk | SYS_GPE_MFPH_PE11MFP_Msk | SYS_GPE_MFPH_PE10MFP_Msk | SYS_GPE_MFPH_PE9MFP_Msk | SYS_GPE_MFPH_PE8MFP_Msk);
    SYS->GPE_MFPH |= (SYS_GPE_MFPH_PE14MFP_LCD_SEG34 | SYS_GPE_MFPH_PE13MFP_LCD_COM6 | SYS_GPE_MFPH_PE11MFP_LCD_SEG17 | SYS_GPE_MFPH_PE10MFP_LCD_SEG18 | SYS_GPE_MFPH_PE9MFP_LCD_SEG19 |
                      SYS_GPE_MFPH_PE8MFP_LCD_SEG20);
    SYS->GPE_MFPL &= ~(SYS_GPE_MFPL_PE7MFP_Msk | SYS_GPE_MFPL_PE6MFP_Msk);
    SYS->GPE_MFPL |= (SYS_GPE_MFPL_PE7MFP_LCD_SEG16 | SYS_GPE_MFPL_PE6MFP_LCD_SEG15);
    SYS->GPF_MFPH &= ~(SYS_GPF_MFPH_PF15MFP_Msk);
    SYS->GPF_MFPH |= (SYS_GPF_MFPH_PF15MFP_LCD_SEG35);

    return;
}

/*----------------------------------------------------------------------*/
/* Init LCD                                                             */
/*----------------------------------------------------------------------*/
void LCD_Init(void)
{
    uint32_t u32ActiveFPS;
                /* The definition of multifunction pin is generated from NuTool-PinConfigure.*/
    M258KG_init_lcd();       
       
    /* Reset LCD module */
    SYS_ResetModule(LCD_RST);

    /* Output Setting Select */
    LCD_OUTPUT_SET(LCD_OUTPUT_SEL8_TO_COM4 | LCD_OUTPUT_SEL9_TO_COM5 | LCD_OUTPUT_SEL10_TO_SEG20 | LCD_OUTPUT_SEL11_TO_SEG19 |
                   LCD_OUTPUT_SEL12_TO_SEG18 | LCD_OUTPUT_SEL13_TO_SEG17 | LCD_OUTPUT_SEL14_TO_COM6 | LCD_OUTPUT_SEL15_TO_COM7 |
                   LCD_OUTPUT_SEL24_TO_SEG31 | LCD_OUTPUT_SEL25_TO_SEG30 | LCD_OUTPUT_SEL26_TO_SEG29 | LCD_OUTPUT_SEL27_TO_SEG28 |
                   LCD_OUTPUT_SEL28_TO_SEG27 | LCD_OUTPUT_SEL29_TO_SEG26 | LCD_OUTPUT_SEL41_TO_SEG14 | LCD_OUTPUT_SEL42_TO_SEG13 |
                   LCD_OUTPUT_SEL47_TO_SEG8 | LCD_OUTPUT_SEL48_TO_SEG7 | LCD_OUTPUT_SEL49_TO_SEG6);

                /* LCD Initialize and calculate real frame rate */
    u32ActiveFPS = LCD_Open(&g_LCDCfg);

    /* Select output voltage level 9 for 4.8V */
    LCD_SET_CP_VOLTAGE(LCD_CP_VOLTAGE_LV_9);
}

void SYS_Init(void)
{
    /* Enable all GPIO clock */
    CLK->AHBCLK |= (CLK_AHBCLK_GPACKEN_Msk | CLK_AHBCLK_GPBCKEN_Msk | CLK_AHBCLK_GPCCKEN_Msk | CLK_AHBCLK_GPDCKEN_Msk |
                    CLK_AHBCLK_GPECKEN_Msk | CLK_AHBCLK_GPFCKEN_Msk);

    /*---------------------------------------------------------------------------------------------------------*/
    /* Init System Clock                                                                                       */
    /*---------------------------------------------------------------------------------------------------------*/
    /* Enable HIRC clock */
    CLK_EnableXtalRC(CLK_PWRCTL_HIRCEN_Msk);

    /* Waiting for HIRC clock ready */
    CLK_WaitClockReady(CLK_STATUS_HIRCSTB_Msk);

    /* Enable LIRC clock */
    CLK_EnableXtalRC(CLK_PWRCTL_LIRCEN_Msk);

    /* Waiting for LIRC clock ready */
    CLK_WaitClockReady(CLK_STATUS_LIRCSTB_Msk);

    /* Switch HCLK clock source to HIRC */
    CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_HIRC, CLK_CLKDIV0_HCLK(1));

    /* Set SysTick source to HCLK/2*/
    CLK_SetSysTickClockSrc(CLK_CLKSEL0_STCLKSEL_HCLK_DIV2);

    /* Configure LCD module clock */
    CLK_EnableModuleClock(LCD_MODULE);
    CLK_SetModuleClock(LCD_MODULE, CLK_CLKSEL2_LCDSEL_LIRC, 0);

}


void LCD_Start(void)
{

    /* Enable LCD display */
    LCD_ENABLE_DISPLAY();

    /*---------------------------------------------------------------------------------------------------------*/
    /* Set the text to show on LCD. Please refer to the NK-M258KG_EC_LCD.nvt to check the definition of the name.                                                                                        */
    /*---------------------------------------------------------------------------------------------------------*/
    /*Show text on the specific group with using LCDLIB_Printf */
    LCDLIB_Printf(ZONE_MAIN_DIGIT, "M258");  // the "MAIN" group

    /*Show char on the specific position of the group with using LCDLIB_PutChar() */
    LCDLIB_PutChar(ZONE_MAIN_DIGIT, 4, 'K');  // the 5th position of the "MAIN" group
    LCDLIB_PutChar(ZONE_MAIN_DIGIT, 5, 'G');  // the 6th position of the "MAIN" group

    /* Show number on the specific group with using LCDLIB_PrintNumber() */
    LCDLIB_PrintNumber(ZONE_TIME_DIGIT, 1352);   // the "TIME" group
    LCDLIB_PrintNumber(ZONE_NUMICRO_DIGIT, 258); // the "NUMOCRO" group
    LCDLIB_PrintNumber(ZONE_PPM_DIGIT, 123);     // the "ppm" group
    LCDLIB_PrintNumber(ZONE_TEMP_DIGIT, 36);         // the "TEMP" group
    LCDLIB_PrintNumber(ZONE_VER_DIGIT, 105004);  // the "VER" group

    /* Show the specific Symbol with using LCDLIB_SetSymbol() */
    LCDLIB_SetSymbol(SYMBOL_COL_9, 1);      // the dot symbol, which is inter the "TIME" group
    LCDLIB_SetSymbol(SYMBOL_COL_10, 1);     // the dot symbol, which is inter "TIME" group
    LCDLIB_SetSymbol(SYMBOL_NVT_11, 1);   // the "nuvoton" symbol
    LCDLIB_SetSymbol(SYMBOL_WIFI_12, 1);  // the "wifi" symbol
    LCDLIB_SetSymbol(SYMBOL_SOUND_14, 1);   // the "sound" symbol
    LCDLIB_SetSymbol(SYMBOL_BAT_FRAME_13, 1); // the frame of the battery symbol
    LCDLIB_SetSymbol(SYMBOL_BAT_1_13, 1); // the 1st level of the battery symbol
    LCDLIB_SetSymbol(SYMBOL_BAT_2_13, 1); // the 2nd level of the battery stmbol
    LCDLIB_SetSymbol(SYMBOL_BAT_3_13, 0); // the 3rd level of the battery symbol
    LCDLIB_SetSymbol(SYMBOL_NUMICRO_15, 1); // the "NuMicro M" symbol
    LCDLIB_SetSymbol(SYMBOL_PLUS_19, 1);  // the "plus" symbol, which is on the left side of the screen
    LCDLIB_SetSymbol(SYMBOL_COL_69, 1);   // the dot symbol, which is inter the "MAIN" group
    LCDLIB_SetSymbol(SYMBOL_COL_68, 1);     // the dot symbol, which is inter the "MAIN" group
    LCDLIB_SetSymbol(SYMBOL_COL_70, 1);     // the dot symbol, which is inter the "MAIN" group
    LCDLIB_SetSymbol(SYMBOL_COL_71, 1);     // the dot symbol, which is inter the "MAIN" group
    LCDLIB_SetSymbol(SYMBOL_COL_72, 1);     // the dot symbol, which is inter the "MAIN" group
    LCDLIB_SetSymbol(SYMBOL_COL_73, 1);     // the dot symbol, which is inter the "MAIN" group
    LCDLIB_SetSymbol(SYMBOL_COL_74, 1);     // the dot symbol, which is inter the "MAIN" group
    LCDLIB_SetSymbol(SYMBOL_COL_75, 1);     // the dot symbol, which is inter the "MAIN" group
    LCDLIB_SetSymbol(SYMBOL_COL_76, 1);     // the dot symbol, which is inter the "MAIN" group
    LCDLIB_SetSymbol(SYMBOL_COL_77, 1);     // the dot symbol, which is inter the "MAIN" group
    LCDLIB_SetSymbol(SYMBOL_A_29, 1);           // the "A" symbol, which is on the right side of the "MAIN" group
    LCDLIB_SetSymbol(SYMBOL_S01_47, 1);   // the 1st block, which is inter the 5x8 block on the right side of the screen
    LCDLIB_SetSymbol(SYMBOL_S07_47, 1);     // the 7th block, which is inter the 5x8 block on the right side of the screen
    LCDLIB_SetSymbol(SYMBOL_S13_47, 1);     // the 13th block, which is inter the 5x8 block on the right side of the screen
    LCDLIB_SetSymbol(SYMBOL_S19_47, 1);     // the 19th block, which is inter the 5x8 block on the right side of the screen
    LCDLIB_SetSymbol(SYMBOL_S25_47, 1);     // the 25th block, which is inter the 5x8 block on the right side of the screen
    LCDLIB_SetSymbol(SYMBOL_S29_47, 1);     // the 29th block, which is inter the 5x8 block on the right side of the screen
    LCDLIB_SetSymbol(SYMBOL_S33_47, 1);     // the 33th block, which is inter the 5x8 block on the right side of the screen
    LCDLIB_SetSymbol(SYMBOL_S37_47, 1);     // the 37th block, which is inter the 5x8 block on the right side of the screen
    LCDLIB_SetSymbol(SYMBOL_CIRCLE_UP_48, 1);   // the "up-circle" symbol, which is on the bottom left side of the screen
    LCDLIB_SetSymbol(SYMBOL_ARROW_UP_48, 1);    // the "up-arrow" symbol, which is on the bottom left side of the screen
    LCDLIB_SetSymbol(SYMBOL_TEMP_C_57, 1);      // the celsius temeperature symbol
    LCDLIB_SetSymbol(SYMBOL_PPM_53, 1);             // the ppm symbol
    LCDLIB_SetSymbol(SYMBOL_VERSION_59, 1);   // the version symbol
    LCDLIB_SetSymbol(SYMBOL_P_66, 1);           // the dot symbol, which is inter the "version" group
    LCDLIB_SetSymbol(SYMBOL_P_67, 1);           // the dot symbol, which is inter the "version" group
}

/*---------------------------------------------------------------------------------------------------------*/
/*  M258_LCDView MAIN function                                                                                          */
/*---------------------------------------------------------------------------------------------------------*/
int main(void)
{

    /* Unlock protected registers */
    SYS_UnlockReg();

    /* Init System, peripheral clock and multi-function I/O */
    SYS_Init();

    /* Lock protected registers */
    SYS_LockReg();

    /* Init LCD multi-function pins and settings */
    LCD_Init();

    /* Start showing the specific text */
    LCD_Start();

    while (1) {}

}


使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

172

主题

2182

帖子

3

粉丝