0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

SPI液晶 ILI9341をTouchGFXで使おう4~表示テストを行う~

Last updated at Posted at 2024-01-27

SPI液晶 ILI9341をTouchGFXで使おう の補足としてSPI液晶の表示テストを行ってみます。
SPI液晶 ILI9341をTouchGFXで使おう3~キャリブレーションをする~main文 を変更することでも確認可能です。

最初に、SPI液晶 ILI9341をTouchGFXで使おう1 から PWM設定まで を行い Device Configuration Tool code Generate を行います。

プロジェクトを生成する

最初に新規プロジェクトを作ります。
File⇒New⇒STM32 project
image.png
使用するマイコンを選定し OK をクリックします。
image.png
Project Name を入力し、Finish をクリックします。
image.png

デバイス設定をする

最初に クロック の生成と 周波数 を設定します。
Crystal/Ceramic Resonator を選択します。
image.png
次に Clock Configuration をクリックし、周波数を設定します。
今回は 100MHz にするため、HCLK100 を入力します。
Enterを押すと、自動で設定が変更されます。
image.png

SPI設定

次に、使用する SPI の設定を Step3 の通り SPI2ModeFull-Duplex Master に設定します。
image.png
GPIO のピンの名称は以下を参考に設定します。
image.png

image.png
DMASettings にて Add から SPI2__TX を追加します。
image.png
NVIC Settings において SPI2 global Interruptチェック を入れておきます。
image.png

GPIO設定

GPIO Output を 4本追加し、以下設定を行います。
image.png
image.png
GPIO⇒Configuration

image.png

TOUCH_INTの設定

TOUCH_INT用GPIO_EXIT を追加します。
image.png
Interrupt mode において External interrupt-falling edge を選択します。
image.png

PWM設定

バックライトに使用するPWMの設定を行います。
STEP 6 の通り TIM2 TIM_CHANNEL_1にPWM Generation CH1 を選択します。
image.png
prescaler,counter periodYoutube を参考に 10000/100 としました。
image.png
使用するピンの UserLabel を入力します。
image.png
STEP 7 を参考に TIM3InternalClock のチェックを入れておきます。
image.png

Code Generation

Device Configuration Tool code Generate を押すことでハードウェア設定に基づいてコード生成されます。
image.png
続いて、プログラムに進みましょう。
image.png

ファイルの追加

*SPI液晶 ILI9341をTouchGFXで使おう3~キャリブレーションをする~とmain文違いとなります。

1-HOWTO のファイルをすべてダウンロードし IncSrc にファイルを配置し main.hUSER CODE BEGIN Includes を以下に変更します。

image.png

/* USER CODE BEGIN Includes */
#include "fonts.h"
#include "z_displ_ILI9XXX.h"
#include "z_displ_ILI9XXX_test.h"
#include "z_touch_XPT2046.h"
#include "z_touch_XPT2046_test.h"
#include "z_touch_XPT2046_menu.h"
/* USER CODE END Includes */

z_displ_ILI9XXX.hの変更

z_displ_ILI9XXX.h の45行目をコメントアウトします。

    //#define DISPLAY_USING_TOUCHGFX

image.png

STEP 2ILI9488_V1 または ILI9488_V2 など使用するディスプレイに合わせて変更します。
ILI9488_V2 で表示されない場合 ILI9488_V1 にすると表示されることがあります。

/******************    STEP 2    *****************
 * which display are you using?
 *************************************************/
//#define ILI9341
//#define ILI9488_V1
#define ILI9488_V2

main.cの変更

main.c を以下に変更します。

/* USER CODE BEGIN 2 */			// "USER CODE BEGIN 2" is after all system initializations and before entering the main loop. Good place to initialize display
Displ_Init(Displ_Orientat_0);		// initialize the display and set the initial display orientation (here is orientaton: 0°) - THIS FUNCTION MUST PRECEED ANY OTHER DISPLAY FUNCTION CALL.  
Displ_CLS(BLACK);			// after initialization (above) and before turning on backlight (below), you can draw the initial display appearance. (here I'm just clearing display with a black background)
Displ_BackLight('I');  			// initialize backlight and turn it on at init level
/* USER CODE END 2 */
/* USER CODE BEGIN WHILE */
while (1) 			// into the main loop you can add the test functions
{
  // display testing
  Displ_PerfTest();		// shows display graphics and performance
  // touch testing
  Touch_ShowData();		// polls touch device and shows values returned, showing touch interrupt calls also
  Touch_TestDrawing();		// polling touch, converting and drawing position returned
  /* USER CODE END WHILE */

以上でビルドすると画面が表示されると思います。
これで表示されない場合、設定や配線を見直してみてください。

SPI液晶 ILI9341をTouchGFXで使おう5~ILI9488 でも使おう~

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?