分享一个基于Keil STM32的12864液晶模块显示程序。
单片机源程序如下:
- #include "stm32f10x.h"
- #include "integer.h"
- #include "lcd12864_chuan.H"
- //12864 STM32驱动程序
- void delay(u32 delaytime);
- void NVIC_Configuration(void);
- void RCC_Configuration(void);
- void GPIO_init(void);
- void delay(u32 delaytime){
- while(delaytime>1)delaytime--;
- }
- void NVIC_Configuration(void){
- #ifdef VECT_TAB_RAM
- /* Set the Vector Table base location at 0x20000000 */
- NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
- #else /* VECT_TAB_FLASH */
- /* Set the Vector Table base location at 0x08000000 */
- NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
- #endif
- /* Configure one bit for preemption priority */
- }
- //配置系统时钟,使能各外设时钟
- void RCC_Configuration(void){
- SystemInit();
- RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA
- |RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC
- |RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE
- | RCC_APB2Periph_AFIO |RCC_APB2Periph_SPI1
- , ENABLE );
- }
- void GPIO_init(void){
- GPIO_InitTypeDef GPIO_InitStructure;
- /* Configure PC13 as input floating (EXTI Line0) */
- // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12;
- // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
- // GPIO_Init(GPIOA, &GPIO_InitStructure);
- // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1;
- // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
- // GPIO_Init(GPIOB, &GPIO_InitStructure);
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_3;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2; //12864控制脚 OD输出
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
- }
- void Init_All_Periph(void){
- RCC_Configuration();
- NVIC_Configuration();
- GPIO_init();
- // SPI_Configuration();
- // SD_Init();
- lcd_init();
- }
-
- int main(void){
- Init_All_Periph();
- while(1)
- {
- Chshow(2,2,"xxxxxx aa");
- delay(10000000);
- Chshow(2,2,"feasfas");
- delay(10000000);
- //Draw_circle(64,32,30)
- // f_mount(0,&fs); //开辟一个新的工作区
- // window();
- // f_mount(0,NULL); //注销工作区
- }
- }
复制代码
所有资料51hei提供下载:
STM32_12864_原创显示程序.rar
(327.87 KB, 下载次数: 58)
|