为您提供专业的显示解决
方案
气瓶 现场处置方案 .pdf气瓶 现场处置方案 .doc见习基地管理方案.doc关于群访事件的化解方案建筑工地扬尘治理专项方案下载
www.hotlcd.com
STM32驱动12864液晶屏
#include "stm32f10x_lib.h"
#define uint unsigned int
#define uchar unsigned char
#define RSH GPIO_SetBits(GPIOA,GPIO_Pin_0)
#define RSL GPIO_ResetBits(GPIOA,GPIO_Pin_0)
#define RWH GPIO_SetBits(GPIOA,GPIO_Pin_1)
#define RWL GPIO_ResetBits(GPIOA,GPIO_Pin_1)
#define ENH GPIO_SetBits(GPIOA,GPIO_Pin_2)
#define ENL GPIO_ResetBits(GPIOA,GPIO_Pin_2)
#define CS1H GPIO_SetBits(GPIOA,GPIO_Pin_3)
#define CS1L GPIO_ResetBits(GPIOA,GPIO_Pin_3)
#define CS2H GPIO_SetBits(GPIOA,GPIO_Pin_4)
#define CS2L GPIO_ResetBits(GPIOA,GPIO_Pin_4)
void RCC_Configuration(void);
void NVIC_Configuration(void);
void GPIO_Configuration(void);
void Delay();
uchar table[][16]={
/*-- 文字: 我 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x20,0x20,0x22,0x22,0xFE,0x21,0x21,0x20,0x20,0xFF,0x20,0x22,0xAC,0x20,0x20,0x00 ,
0x04,0x04,0x42,0x82,0x7F,0x01,0x01,0x10,0x10,0x08,0x07,0x1A,0x21,0x40,0xF0,0x00 ,/*-- 文字: 爸 --*/
/*-- 文字: 一 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xC0,0x80,0x00 ,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,
/*-- 文字: 天 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x40,0x42,0x42,0x42,0x42,0x42,0xFE,0x42,0x42,0x42,0x42,0x42,0x42,0x40,0x00 ,
0x00,0x80,0x40,0x20,0x10,0x08,0x06,0x01,0x02,0x04,0x08,0x10,0x30,0x60,0x20,0x00 ,
/*-- 文字: 的 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xF8,0x8C,0x8B,0x88,0xF8,0x40,0x30,0x8F,0x08,0x08,0x08,0x08,0xF8,0x00,0x00 ,
0x00,0x7F,0x10,0x10,0x10,0x3F,0x00,0x00,0x00,0x03,0x26,0x40,0x20,0x1F,0x00,0x00 ,
/*-- 文字: 成 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0xF8,0x48,0x48,0x48,0xC8,0x08,0xFF,0x08,0x09,0x0A,0xC8,0x88,0x08,0x00 ,
0x40,0x30,0x0F,0x00,0x08,0x50,0x4F,0x20,0x10,0x0B,0x0C,0x12,0x21,0x40,0xF0,0x00 ,
/*-- 文字: 果 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x3E,0x2A,0x2A,0x2A,0xFE,0x2A,0x2A,0x2A,0x3E,0x00,0x00,0x00,0x00 ,
0x21,0x21,0x11,0x11,0x09,0x05,0x03,0xFF,0x03,0x05,0x09,0x09,0x11,0x31,0x11,0x00 ,
};
void Write_cmd_left(uchar cmd) {
RSL;
RWL;
CS1H;
GPIO_Write(GPIOF,cmd);
ENL;
Delay(50);
ENH;
Delay(50);
ENL;
Delay(50);
CS1L;
}
void Write_cmd_right(uchar cmd) {
RSL;
RWL;
CS2H;
GPIO_Write(GPIOF,cmd);
ENL;
Delay(50);
ENH;
Delay(50);
ENL;
Delay(50);
CS2L;
}
void Write_data_left(uchar data) {
RSH;
RWL;
CS2L;
CS1H;
GPIO_Write(GPIOF,data);
ENL;
Delay(50);
ENH;
Delay(50);
ENL;
Delay(50);
CS1L;
}
void Write_data_right(uchar data) {
RSH;
RWL;
CS1L;
CS2H;
GPIO_Write(GPIOF,data);
ENL;
Delay(50);
ENH;
Delay(50);
ENL;
Delay(50);
CS2L;
}
void led_disp(uchar *p,uchar lr) {
uchar i,cl,cr;
if(lr=='L')
{
for(i=0;i<16;i++)
{
cl=*p;
p++;
Write_data_left(cl);
}
}
if(lr=='R')
{
for(i=0;i<16;i++)
{
cr=*p;
p++;
Write_data_right(cr);
}
}
}
void clear()
{
uchar i,j,disp_page;
for(i=0;i<8;i++)
{
disp_page=0xb8+i;
Write_cmd_left(disp_page);
Write_cmd_left(0x40);
for(j=0;j<64;j++)
Write_data_left(0x00);
}
for(i=0;i<8;i++)
{
disp_page=0xb8+i;
Write_cmd_right(disp_page);
Write_cmd_right(0x40);
for(j=0;j<64;j++)
Write_data_right(0x00);
}
}
void init()
{
Write_cmd_left(0x30);
Delay(10);
Write_cmd_right(0x30);
Delay(10);
Write_cmd_left(0x3f);
Delay(10);
Write_cmd_right(0x3f);
Delay(10);
Write_cmd_left(0xc0);
Delay(10);
Write_cmd_right(0xc0);
}
int main(void)
{
/* Infinite loop */
RCC_Configuration();
NVIC_Configuration();
GPIO_Configuration();
clear();
Delay(10);
init();
Delay(10);
uchar i;
while(1)
{
Write_cmd_left(0xb8);
Write_cmd_left(0x40);
for(i=0;i<4;i++)
led_disp(table[2*i],'L');
Write_cmd_left(0xb8+1);
Write_cmd_left(0x40);
for(i=0;i<4;i++)
led_disp(table[2*i+1],'L');
Write_cmd_right(0xb8);
Write_cmd_right(0x40);
for(i=0;i<2;i++)
led_disp(table[2*i+8],'R');
Write_cmd_right(0xb8+1);
Write_cmd_right(0x40);
for(i=0;i<2;i++)
led_disp(table[2*i+9],'R');
}
}
/******************************************************************************
*Function Name :RCC_Configuration.
*Descriprion :configures the different system clocks.
*Input :None
*Output :None
*Return :None
******************************************************************************* /
void RCC_Configuration(void)
{
ErrorStatus HSEStartUpStatus;
/*RCC system reset(for debug purpose)*/
RCC_DeInit();
/*Enable HSE 打开外部时钟*/
RCC_HSEConfig(RCC_HSE_ON);
/*Wait till HSE is read */
HSEStartUpStatus = RCC_WaitForHSEStartUp();
if(HSEStartUpStatus==SUCCESS)//起振成功
{
/*Enable PrefetchBuffer 打开flash的预存储功能*/
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
FLASH_SetLatency(FLASH_Latency_2);//设置代码延时值
/*HCLK=syclk*/
RCC_HCLKConfig(RCC_SYSCLK_Div1);
/*PCLK2=HCLK*/
RCC_PCLK2Config(RCC_HCLK_Div1);
/*RCLK1=HCLK*/
RCC_PCLK1Config(RCC_HCLK_Div2);
/*PLLCLK=8MHZ*9=72MHZ*/
RCC_PLLConfig(RCC_PLLSource_HSE_Div1,RCC_PLLMul_9);
/*Enable PLL*/
RCC_PLLCmd(ENABLE);
/*Wait till PLL is ready*/
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY)==RESET)
{
}
/*Select PLL as system clock source*/
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
/*Wait till pll used as system clock source*/
while(RCC_GetSYSCLKSource() !=0x80)
{
}
/*打开相应的外部时钟:GPIOF*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); }
else
{
}
}
/******************************************************************************
*Function Name :NVIC_Configuration.
*Descriprion :configures Vector Table base location.
*Input :None
*Output :None
*Return :None
******************************************************************************* /
void NVIC_Configuration(void)
{
#ifdef VECT_TAB_RAM
/*Set the vector table base location at 0x20000000*/
NVIC_SetVectorTable(NVIC_VectTab_RAM,0X0);
#else
/*Set the vector table base location at 0x20000000*/
NVIC_SetVectorTable(NVIC_VectTab_FLASH,0x0);
#endif
}
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_All;
GPIO_InitStructure.GPIO_Mode =
GPIO_Mode_Out_PP;
//设置GPIO的工作状态
GPIO_InitStructure.GPIO_Speed =
GPIO_Speed_50MHz; / /设置GPIO的速度
GPIO_Init(GPIOF,
&GPIO_InitStructure);
GPIO_Init(GPIOA, &GPIO_InitStructure);
}
/******************************************************************************
延时函数
******************************************************************************/
void Delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=100;y>0;y--);
}
以上是鑫洪泰的小编为你带来的液晶屏ST7565R IC驱动程序演示代码介绍,如果你想有更进一步的了解,请您关注我们微信,或者点击我们官网了解我们,也可以在线咨询或者拨打我们的热线电话与我们联系!我们会有专业的工作人员为你实时解答。给您最好的最专业的解答!
深圳市鑫洪泰电子科技有限公司,是一家专业从事LCD和LCM 研发、生产、销售和售后于一体的高科技民营企业。以人为本,以质为纲,以客为尊,是我们至今秉承的经营理念。公司拥有一支经验丰富的研发、销售和生产管理人员,并具备成熟的生产工艺和先进的智能化进口专业生产设备。我们承接各种TN、HTN、STN、FSTN、TAB、COG、CSTN、TFT液晶屏的开发设计、开模定制、单片机开发及LCD 的来料加工。