7737 views|29 replies

821

Posts

0

Resources
The OP
 

[GD32L233C-START Review] 6. SPI (Hardware SPI Drive OLED) [Copy link]

 

Happy New Year and good luck in the new year!

This experiment uses the SPI communication interface of GD32L233CCT6 to drive a 1.3' OLED display.
1. Experimental resources
1. GD32L233C-START;
2. Keil V5.36.0.0;
3. 1.3' OLED module (self-made)


2. Knowledge Preparation

GD32L233CCT6 has two SPI communication interfaces (SPI0 and SPI1). The SPI interface supports full-duplex and simplex modes with hardware CRC calculation and verification, and can work in master or slave mode. Only SPI0 supports SPI four-wire master mode.

In SPI applications, attention should be paid to the clock signal level in the idle state and the configuration of the data sampling position. These parameters should be determined in combination with the specific requirements of the operated device.

3. Experimental Content

1. Hardware connection

According to the port situation of the GD32L233C-START development board and the convenience of connecting the OLED module, the SPI1 module was selected.

2. Program implementation

The main controller of the OLED module used in the experiment is "SH1106".

static void spi_config(void)
{
#ifdef SPI_HARDWARE
	spi_parameter_struct  spi_init_struct;
	
	rcu_periph_clock_enable(RCU_GPIOB);
	rcu_periph_clock_enable(RCU_SPI1);

	spi_i2s_deinit(SPI1);
	spi_struct_para_init(&spi_init_struct);
	
	/* 配置OLED引脚: CS/PB10; DC/PB11; RES/PB14 */
	gpio_mode_set(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_10 | GPIO_PIN_11| GPIO_PIN_14);
	gpio_output_options_set(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_10 | GPIO_PIN_11| GPIO_PIN_14);
	
	/* 配置SPI1 SCK/PB13; MOSI/PB15 */
	gpio_af_set(GPIOB, GPIO_AF_6, GPIO_PIN_13 | GPIO_PIN_15);
	gpio_mode_set(GPIOB, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO_PIN_13 | GPIO_PIN_15);
	gpio_output_options_set(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_13 | GPIO_PIN_15);

	spi_init_struct.trans_mode           = SPI_TRANSMODE_BDTRANSMIT;
	spi_init_struct.device_mode          = SPI_MASTER;
	spi_init_struct.frame_size           = SPI_FRAMESIZE_8BIT;
	spi_init_struct.clock_polarity_phase = SPI_CK_PL_LOW_PH_1EDGE; //CKPL=0;CKPH=1 
	//spi_init_struct.clock_polarity_phase = SPI_CK_PL_HIGH_PH_2EDGE;
	spi_init_struct.nss                  = SPI_NSS_SOFT;
	spi_init_struct.prescale             = SPI_PSC_8 ;
	spi_init_struct.endian               = SPI_ENDIAN_MSB;
	
	spi_init(SPI1, &spi_init_struct);

  spi_enable(SPI1);
#else
	rcu_periph_clock_enable(RCU_GPIOB);

	gpio_mode_set(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, OLED_PORT_IS);
	gpio_output_options_set(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, OLED_PORT_IS);
	
#endif
}

The program is compatible with software and hardware working modes. SPI is configured as host transmission and only sends data to OLED.

3. Experimental results

4. Attachments

Attached is the complete project for this experiment, supporting software and hardware SPI.

游客,如果您要查看本帖隐藏内容请回复

This post is from GD32 MCU

Latest reply

.   Details Published on 2024-9-25 23:23
 

174

Posts

1

Resources
2
 

This post is from GD32 MCU
 
 
 

2

Posts

0

Resources
3
 

good

This post is from GD32 MCU
 
 
 

1

Posts

0

Resources
4
 

Is it a complete SPI control program?

This post is from GD32 MCU
 
 
 

1

Posts

0

Resources
5
 

To top

This post is from GD32 MCU
 
 
 

2

Posts

0

Resources
6
 

good

This post is from GD32 MCU
 
 
 

1

Posts

0

Resources
7
 

Learn

This post is from GD32 MCU
 
 
 

538

Posts

1

Resources
8
 
After learning, other chips can also be transplanted.
This post is from GD32 MCU
 
 
 

1

Posts

0

Resources
9
 

11111

This post is from GD32 MCU
 
 
 

7422

Posts

2

Resources
10
 

Thanks for sharing, looking forward to the follow-up.

This post is from GD32 MCU
 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 

1

Posts

0

Resources
11
 

Learn

This post is from GD32 MCU
 
 
 

1

Posts

0

Resources
12
 
Study
This post is from GD32 MCU
 
 
 

1

Posts

0

Resources
13
 

Learn

This post is from GD32 MCU
 
 
 

9

Posts

0

Resources
14
 
Haha, good idea, thank you for your affirmation, good, good, good
This post is from GD32 MCU
 
 
 

2

Posts

0

Resources
15
 
1234
This post is from GD32 MCU
 
 
 

2

Posts

0

Resources
16
 
1234
This post is from GD32 MCU
 
 
 

1

Posts

0

Resources
17
 

Thanks, I'll try it

This post is from GD32 MCU
 
 
 

1

Posts

0

Resources
18
 

good

This post is from GD32 MCU
 
 
 

1462

Posts

0

Resources
19
 
Very good information, worth learning. Thumbs up. Thank you for sharing!!
This post is from GD32 MCU
 
 
 

1

Posts

0

Resources
20
 

Study

This post is from GD32 MCU
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
Studying Things to Gain Knowledge 05: Dimensions and Elementary Functions

What is dimension? It is usually taught in middle school physics courses and again in university physics courses. Howev ...

【McQueen Trial】Comparison of the accuracy of several ultrasonic sensor programs of McQueen

Purpose Compare the test accuracy of several ultrasonic sensors to provide a reference for everyone's use. Methods Write ...

[Project source code] Digital tube companion - binary to BCD

This article and design code were written by FPGA enthusiast Xiao Meige. Without the author's permission, this article ...

Design of real-time image test device based on LVDS technology

Design of real-time image test device based on LVDS technology

C language uses binary tree to parse polynomials and evaluate

It mainly realizes the analysis of polynomial data calculation. If there is a need to make a simple calculator based on ...

LPS27HHTW MEMS Pressure Sensor

The LPS27HHTW MEMS pressure sensor is an ultra-compact piezoresistive absolute pressure sensor that can be used as a dig ...

Raspberry Pi Bluetooth Basics - Use of bluezero library

This post was last edited by lb8820265 on 2021-8-8 22:50 There are many libraries for operating Bluetooth in Linux s ...

CC2500 Migration Instructions

Be applicable : Applicable to TI chip CC2500 full series modules How to transplant ? The parts to be ported are in rf_ ...

Embedded Qt-Make a stopwatch

This post was last edited by DDZZ669 on 2022-8-7 15:55 Previous article: Embedded Qt - Write and run your first ARM-Qt ...

Successfully deployed deep learning gait recognition algorithm on Allwinner V853 platform

Xin Zhe, a student from the Communication Research Group of Beijing Institute of Technology, successfully transplanted t ...

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list