分享一個基于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)
2018-7-25 16:27 上傳
點擊文件名下載附件
stm32的12864顯示程序 下載積分: 黑幣 -5
|