请问大家,我使用的NANO110KE3BN单片机,想要使用c-type驱动LCD显示,按照手册上将V1,V2,V3,VLCD,DH1,DH2,引脚通过0.1uF电容连接到地,但是只有上电的时候会显示,然后电压就逐渐降低到0.6V,在R-TYPE模式下给VLCD引脚电压,显示是正常的。目前现象就是电荷泵电压不稳定,但是也没有发现短路问题.请大家看一下是不是程序方面配制问题或者提供一些测试问题的方式
/**************************************************************************//**
* [url=home.php?mod=space&uid=288409]@file[/url] main.c
* [url=home.php?mod=space&uid=895143]@version[/url] V1.00
* $Revision: 4 $
* $Date: 14/09/11 5:23p $
* [url=home.php?mod=space&uid=247401]@brief[/url] Show how to pixel on and off on LCD panel.
*
* @note
* Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved.
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "Nano100Series.h"
#include "lcd.h"
#include "uart.h"
#include "sys.h"
#include "clk.h"
#include "gpio.h"
#include "LCDLIB.h"
#define LCD_ALPHABET_NUM 7
#define LCD_DIGIT_NUM 4
/*!<Enable LCD for 100/128-Pin Package */
#define MFP_LCD_TYPEA() { \
SYS->PA_L_MFP |= 0x77770000; /* seg 36 ~ 39 */\
SYS->PA_H_MFP |= 0x7777; /* seg 20 ~ 23 */\
SYS->PB_L_MFP = 0x77777777; /* seg 10 ~ 13, 4 ~ 7 */\
SYS->PB_H_MFP = 0x77777777; /* LCD V1 ~ V3, seg 30 ~ 31, 24 ~ 26 */\
SYS->PC_L_MFP |= 0x777777; /* LCD COM3 ~ COM0, DH1/DH2 */\
SYS->PC_H_MFP |= 0x77000000; /* seg 32 ~ 33 */\
SYS->PD_L_MFP |= 0x77770000; /* seg 2 ~ 3, 34 ~ 35 */\
SYS->PD_H_MFP = 0x77777777; /* seg 0 ~ 1, 14 ~ 19 */\
SYS->PE_L_MFP |= 0x70000000; /* seg 8 */\
SYS->PE_H_MFP |= 0x77700007; /* seg 9, 27 ~ 29 */\
}
/*!<Enable LCD for 64-Pin Package */
#define MFP_LCD_TYPEB() { \
SYS->PA_L_MFP |= 0x77777700; /* seg 18 ~ 23 */\
SYS->PA_H_MFP = 0x77777777; /* seg 6 ~ 9, 24 ~ 27 */\
SYS->PB_L_MFP = 0x77777777; /* COM2, COM3, seg 0 ~ 5 */\
SYS->PB_H_MFP = 0x77777777; /* LCD V1 ~ V3, seg 10 ~ 14 */\
SYS->PC_L_MFP |= 0x70007777; /* LCD COM1 ~ COM0, DH1/DH2, seg 17 */\
SYS->PC_H_MFP |= 0x77007777; /* seg 28 ~ 31, 15 ~ 16 */\
}
void SYS_Init(void)
{
/*---------------------------------------------------------------------------------------------------------*/
/* Init System Clock */
/*---------------------------------------------------------------------------------------------------------*/
/* Unlock protected registers *///LIRC默认使用;HIRC默认使能;LXT默认禁止;HXT默认禁止
SYS_UnlockReg();
/* Enable External XTAL (32.768KHz) */
CLK_EnableXtalRC(CLK_PWRCTL_LXT_EN_Msk);
CLK_EnableXtalRC(CLK_PWRCTL_HIRC_EN_Msk);//CLK_DisableXtalRC(CLK_PWRCTL_HIRC_EN_Msk);
/* Waiting for 12MHz clock ready */
CLK_WaitClockReady( CLK_CLKSTATUS_LXT_STB_Msk);//32.768K
CLK_WaitClockReady( CLK_CLKSTATUS_HIRC_STB_Msk);//12M
/* Switch HCLK clock source to HIRC */
CLK_SetHCLK(CLK_CLKSEL0_HCLK_S_HIRC,CLK_HCLK_CLK_DIVIDER(6));//12M HB101 MCLK和SMCLK默认试时钟为1MHz
/* Enable IP clock */
CLK_EnableModuleClock(UART0_MODULE);
CLK_SetModuleClock(UART0_MODULE, CLK_CLKSEL1_UART_S_HIRC, CLK_UART_CLK_DIVIDER(1));
CLK->CLKSEL1 &= ~CLK_CLKSEL1_LCD_S_Msk;
CLK->CLKSEL1 |= (0x0 << CLK_CLKSEL1_LCD_S_LXT);// Clock source from external 12 MHz or 32 KHz crystal clock
CLK_EnableModuleClock(LCD_MODULE);
SystemCoreClockUpdate();
/*---------------------------------------------------------------------------------------------------------*/
/* Init I/O Multi-function */
/*---------------------------------------------------------------------------------------------------------*/
/* Set GPB multi-function pins for UART0 RXD and TXD */
SYS->PA_H_MFP &= ~(SYS_PA_H_MFP_PA14_MFP_Msk|SYS_PA_H_MFP_PA15_MFP_Msk);
SYS->PA_H_MFP |= (SYS_PA_H_MFP_PA14_MFP_UART0_RX|SYS_PA_H_MFP_PA15_MFP_UART0_TX);
/* Select LCD COMs, SEGs, V1 ~ V3, DH1, DH2 */
MFP_LCD_TYPEA();
GPIO_DISABLE_DIGITAL_PATH(PB, BIT9);
GPIO_DISABLE_DIGITAL_PATH(PB, BIT10);
GPIO_DISABLE_DIGITAL_PATH(PB, BIT11);
GPIO_DISABLE_DIGITAL_PATH(PC, BIT0);
GPIO_DISABLE_DIGITAL_PATH(PC, BIT1);
/* Lock protected registers */
SYS_LockReg();
}
void UART0_Init()
{
/*---------------------------------------------------------------------------------------------------------*/
/* Init UART */
/*---------------------------------------------------------------------------------------------------------*/
UART_Open(UART0, 115200);
}
void clk_delay(int16_t num)
{
int16_t a,b;
for(a=0;a<num;a++)
for(b=0;b<1250;b++)
{
;
}
}
static void TestItem (void)
{
printf("\n\n");
printf("+-----------------------------------------------------------+\n");
printf("| LCD Sample Program |\n");
printf("+-----------------------------------------------------------+\n");
printf("| Any Dot Display Test |\n");
printf("+-----------------------------------------------------------+\n");
}
int32_t main(void)
{
int i=0;
int j=0;
SYS_Init();
UART0_Init();
/* LCD Initialize */
LCD_Open(LCD_EXTERNAL_C_TYPE, 4, LCD_BIAS_THIRD, LCD_FREQ_DIV64, LCD_CPVOl_3_3V);
LCD_EnableDisplay();
TestItem();
GPIO_SetMode(PE, BIT6, GPIO_PMD_OUTPUT); // 设置LED开关端口
// 关闭LED
GPIO_SetMode(PA, BIT3, GPIO_PMD_OUTPUT); // 设置LED开关端口
// 关闭LED
GPIO_SetMode(PC, BIT8, GPIO_PMD_OUTPUT); // 设置LED开关端口
// 关闭LED
GPIO_SetMode(PA, BIT12, GPIO_PMD_OUTPUT); // 设置LED开关端口
GPIO_SetMode(PE, BIT3, GPIO_PMD_OUTPUT); // 设置LED开关端口
PE3=0;
PA3=0;
PC8=0;
PA12=1;
LCD_SetPixel(2,4,1);
// for( i=0;i<=4;i++)
// for( j=0;j<=39;j++)
// {
// LCD_SetPixel(i,j,1);
// }
while(1)
{
// LCD_SetAllPixels(1);
PE6=1;
clk_delay(100);
PE6=0;
clk_delay(100);
}
}
/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
|
|