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?

More than 3 years have passed since last update.

STM32L010F4P6と液晶、ACM1602K-NLW-BBWでHello Worldを表示3(DigitalOut)

Last updated at Posted at 2021-11-12

x 原因は、わからないが液晶がちらつく場合は、ウェートを調整してね!!

STM32L010F4P6でmbedを使い16文字2行液晶に
Hello Worldを表示するプログラム

74hc164シフトレジスターを使用した。
液晶とのピン数を節約した。信号線10本から
信号線3本に減らした。

1 CLK クロック端子(緑)
2 RSDATA RS端子とデータの共有端子(黄)
3 E 読み込み書き込み同期信号(青)

h_con39.jpg

o_con87.jpg

いろいろキレイにした。





#include "mbed.h"

DigitalOut swdclk(PA_5);
DigitalOut swdio(PA_7);
DigitalOut en(PA_4);

//液晶に一文字送信する
void seg1(int v,int rs)
{
    for(int jj=0;jj<8;jj++){
        if( (v<<jj) & 0x80 ){      
                swdio=1; //ビットが1 
        } else {
                swdio=0; //ビットが0
        }//endif
        swdclk=1;
        swdclk=0; //clk
    }//for
    swdio=rs;
    en=1;wait_ms(1);
    en=0;
}//seg1

//文字列の表示 nana_seg
int ns_printf(char *str1) {
    //文字の中身がゼロか
    while(*str1){
        //一文字出力
        seg1( *str1 ++ , 1  );
    } //while
    //戻り値
    return(0);
}//ns_printf

//液晶の初期化コード
int lcd_int[]={
  0x30,0x30,0x30,0x38,0x08,0x01,0x06,0x08+0x04
};//lcd_init

//メイン関数
int main() {

    //GPIOの初期化
    en=0;

    //液晶の初期化
    for(int ii=0;ii<8;ii++){ 
        seg1( lcd_int[ii] , 0);wait_ms(2);
    }//for

    //seg1(   0x01  , 0  ); wait_ms(1000); //画面クリア

    seg1( 0x80+0x00 , 0  ); //1ライン目にカーソルを移動

    ns_printf("Hello World !"); //表示

    while(1) {} //無限ループ

}//main

//容量削減
void error(const char* format, ...){}



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?