STM32f4---OLCD display experimental code (01)

Publisher:柳絮轻风Latest update time:2018-09-29 Source: eefocusKeywords:STM32f4 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In this experiment, we created oled.c and oled.h files. These two files are used to store OLED-related driver functions and file declarations.

The code of oled.c is quite long, so we will not post it here. We will only introduce a few important functions. The first is the OLED_Init function. The structure of this function is relatively simple. It starts with the initialization of the IO port. Here we use the macro definition OLED_MODE to determine the IO port to be set. The rest are some initialization sequences. We can do it according to the information provided by the manufacturer. Finally, it should be pointed out that because OLED has no backlight, after initialization, we clear the video memory, so we can't see anything on the screen, just like there is no power. Don't think that this is an initialization failure. The data module will be written to display it. The code of the OLED_Init function is as follows:

// Initialize SSD1306               

void OLED_Init(void)

{            

   GPIO_InitTypeDef  GPIO_InitStructure;

  

  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB

|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE

|RCC_AHB1Periph_GPIOG, ENABLE); //Enable PORTA~E, PORTG clock

#if OLED_MODE==1 //Use 8080 parallel port mode    

  

//GPIO initialization settings

   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 ;

   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; //Normal output mode

   GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //Push-pull output

   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz

   GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉

   GPIO_Init(GPIOA, &GPIO_InitStructure); // Initialization

  

   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7 ;  

GPIO_Init(GPIOB, &GPIO_InitStructure); // Initialization

 

   GPIO_InitStructure.GPIO_Pin =

  GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_11;  

GPIO_Init(GPIOC, &GPIO_InitStructure); // Initialization  

   

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7;  

GPIO_Init(GPIOD, &GPIO_InitStructure); // Initialization  

  

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_5;  

GPIO_Init(GPIOE, &GPIO_InitStructure); // Initialization  

  

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;  

GPIO_Init(GPIOG, &GPIO_InitStructure); // Initialization  

     OLED_WR=1;

OLED_RD=1;  

#else //Use 4-wire SPI serial port mode

 

       GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 ;

       GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; //Normal output mode

       GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //Push-pull output

        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz

       GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉

       GPIO_Init(GPIOB, &GPIO_InitStructure); // Initialization

  

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7;  

  GPIO_Init(GPIOC, &GPIO_InitStructure); // Initialization    

 

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;  

  GPIO_Init(GPIOD, &GPIO_InitStructure); // Initialization    

  

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;  

  GPIO_Init(GPIOG, &GPIO_InitStructure); // Initialize OLED_SDIN=1;

  OLED_SCLK=1;

#endif


Keywords:STM32f4 Reference address:STM32f4---OLCD display experimental code (01)

Previous article:STM32f4---OLCD display experimental code (02)
Next article:STM32f4---capacitive touch button experimental code (02)

Recommended ReadingLatest update time:2024-11-17 00:57

Differences and comparisons of different DMA modes used by STM32F4 ADC module
These details are not explained in the original reference manual of STM32F4, but are listed briefly. I finally figured it out by checking the interface library that ST just released a few days ago, so I dare not keep it to myself! 1. STM32F4 has 3 independent ADC units with powerful performance. They can be used in
[Microcontroller]
STM32F4 three-way ADC simultaneous acquisition
Note that when the three ADCs are configured for DMA transfer, the addresses of ADC1-ADC3 need to be modified: #define ADC1_DR_Addr   ((uint32_t)0x4001204C) #define ADC2_DR_Addr   ((uint32_t)0x4001214C) #define ADC3_DR_Addr   ((uint32_t)0x4001224C)   The address definition above must be followed, otherwise
[Microcontroller]
Differences between STM32F4 and STM32F1
As the largest occupant of the Cortex M3 market, ST launched the STM32F4 series products based on the Cortex M4 core in 2011. Compared with Cortex M3 products such as STM32F1/F2, the biggest advantage of STM32F4 is the addition of hardware FPU unit and DSP instructions. At the same time, the main frequency of STM32F4
[Microcontroller]
STM32F4 Marquee Experiment
Hardware connection: LEDs are connected to PF9 and PF10 pins respectively, and low level lights up the LEDs; Library functions used: head File  The source files all have header files corresponding to them, which need to be added to the project; Source files (lib directory)  misc.c (usually we will not delete this he
[Microcontroller]
STM32F407 study notes - Systick interrupt
#include   GPIO_TypeDef* io_led=GPIOC; const u16 pin_led=GPIO_Pin_1;   static __IO uint32_t TimingDelay;   void Led_Init() { GPIO_InitTypeDef GPIO_init_l; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); GPIO_init_l.GPIO_Pin=GPIO_Pin_1; GPIO_init_l.GPIO_Mode=GPIO_Mode_OUT; GPIO_init_l.GPIO_OType=GPIO_OTyp
[Microcontroller]
STM32F4 timer TIM(1) timer control output
Advanced clock control timer TIM1 & TIM8 introduction: The advanced control timer of STM32F4 contains an automatic reload counter, the input of the counter is a pre-divided system clock. This timer has a variety of uses, including vehicle input signal length (input capture mode) or generating waveform outputs (output
[Microcontroller]
stm32F4 encoder measures speed and prints through serial port --- program source code
1. Use cubeMX software to initialize the ports and resources needed by the program. In order to keep the program simple, only one serial port and one general timer are used here. (1) Pin initialization Note: There is no encoder mode in the pin configuration. I don't know why. The advanced registers are selected by th
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号