||
利用STM32F417VCT6的FSMC驱动液晶控制器RA8835,自己定义的寄存器,没有采用ST的固件库。
1 STM32F417VCT6与RA8835硬件连接
2 FSMC的初始化
Void InitFsmc(void)
{
/*
PD15、PD14、PD7、PD5、PD4、PD1、PD0设置为AFIO模式,
其余IO设置为输出模式 */
GPIOD->ODR = 0x00000000;
GPIOD->MODER = 0xa5559a5a;
GPIOD->OTYPER = 0x00000000;
GPIOD->OSPEEDR = 0x55555555; /*
IO速度25MHz */
GPIOD->PUPDR = 0x00000000;
/* 无上、下拉电阻
*/
GPIOD->AFR[1] = 0xcc000000;
GPIOD->AFR[0] = 0xc0cc00cc;
/* FSMC复用端口设置为AF12 */
GPIOE->ODR = 0x00000000;
GPIOE->MODER = 0x556a9655;
GPIOE->OTYPER = 0x00000000;
GPIOE->OSPEEDR = 0x55555555;
GPIOE->PUPDR = 0x00000000;
GPIOE->AFR[1] = 0x00000ccc;
GPIOE->AFR[0] = 0xc00c0000;
/* FSMC BANK1设置为模式1,
写允许,8位数据总线,存储器类型为SRAM,地址数据不复用*/
FSMC_Bank1->BCR1 = 0x00001081;
/*根据FSMC的时钟频率和RA8835的工作频率设置
*/
FSMC_Bank1->BTR1 = 0x00081000;
}
3 RA8835初始化
根据硬件连接图,RA8835的地址如下:
/* 写指令地址 */
#define
WriteInstAddr (volatile
unsigned char *)0x60100000
/* 写数据地址 */
#define
WriteDataAddr (volatile
unsigned char *)0x60000000
/* 读状态地址 */
#define
ReadStatusAddr (volatile
unsigned char *)0x60000000
/* 读数据地址 */
#define
ReadDataAddr (volatile
unsigned char *)0x60100000
RA8835的初始化程序如下:
/* 系统设置参数 */
unsigned char SysTab[] =
{0x30,0x07,0x0f,0x27,0x48,0xf0,0x30,0x00};
/* 显示控制参数 */
unsigned char ScrTab[] =
{0x00,0x00,0xf0,0x00,0x40,0xf0,0x00,0x80,0x00,0x00};
Void InitRa8835(void)
{
unsigned char Count;
*WriteInstAddr = 0x40; /* 系统设置 */
for(Count=0;Count<=7;Count++)
{
*WriteDataAddr = SysTab[Count];
}
*WriteInstAddr = 0x44; /* 显示控制 */
for(Count=0;Count<=9;Count++)
{
*WriteDataAddr = ScrTab[Count];
}
*WriteInstAddr = 0x5d;
*WriteDataAddr = 0x07;
*WriteDataAddr = 0x8b;
*WriteInstAddr = 0x5a;
*WriteDataAddr = 0x00;
*WriteInstAddr = 0x5b;
*WriteDataAddr = 0x0c;
*WriteInstAddr = 0x59;
*WriteDataAddr = 0x54;
}