瑞萨单片机论坛
直播中

jf_43382582

未满1年用户 116经验值
擅长:可编程逻辑 嵌入式技术 EMC/EMI设计 存储技术
私信 关注
[经验]

【RA4L1-SENSOR】+ RA4L1-SENSOR开发板之点亮断码屏显示阿拉伯数字

LCD

拿到RA4L1开发板有很久了,之前已经完成了开箱,点灯,串口打印,JlinkRTT打印,Coremark跑分测试,按键功能,基本功能都差不多写完了,今天就来写下段码LCD屏的点亮操作!!!!

1。打开原理图
image.png

上面就是RA4L1板子上的段码屏接口图,总共有4个COM端,19个SED端。采用交流AC点亮断码屏。

2。断码屏的细节如下:
image.png

image.png

image.png

就是上面3张图中对应的关系,核心是下面
image.png

当我们要电流T1时,只需要同时给COM1和SEG1加高电平导通,就能显示T1,当我们要显示数字3时,可以看到显示3,就是依次点亮最左边的1A,1B,1G,1C,1D这5个片段,如下图红线所示
image.png

显示其它数字和符号原理和我上面是一样的,大家自己模仿我的操作实践即可!!!
*附件:GDC0570S(T)P15V3B.pdf

上面的PDF就是瑞萨RA4L1对应的断码屏,我这里无私分享给大家!!!前面的人也点过断码屏,但是它们都没有分享这个给大家,导致大家看的云里雾里!!!!

好了,开始将重点吧。

我就不重新建立工程了,直接在我之前用的按键LED工程里操作,给大家展示!

3。打开瑞萨的smart 配置工具软件

首先配置好时钟,大家直接对照我的时钟进行配置。
image.png

然后再图形组件里添加这个
image.png

照我的参数配置,不要修改
image.png

下面是4个COM和19个SEG口
image.png

image.png

image.png

然后生成代码

打开KEIL工程,发现已经修改了,需要编译工程
image.png

在主函数里添加如下代码

#include "hal_data.h"

#include "usart9.h"

#include "RTT.h"

#include "led.h"

#include <stdio.h>

#include <stdlib.h>

#include "coremark.h"

#include "ebtn_app.h"

FSP_CPP_HEADER

void R_BSP_WarmStart(bsp_warm_start_event_t event);

FSP_CPP_FOOTER

void coremark_main(void);

volatile uint8_t button_count = 0;

/*******************************************************************************************************************//**

  • main() is generated by the RA Configuration editor and is used to generate threads if an RTOS is used. This function

  • is called by main() when no RTOS is used.

    **********************************************************************************************************************/

    void hal_entry(void)

    {

    /* TODO: add your own code here */

    fsp_err_t err;

    /* Open SLCDC driver */

    err = R_SLCDC_Open(&g_slcdc0_ctrl, &g_slcdc0_cfg);

    /* Handle any errors. This function should be defined by the user. */

    assert(FSP_SUCCESS == err);

    /* When using internal boost mode this delay is required to allow the boost circuit to charge. See RA4M1 User's

    • Manual (R01UH0887EJ0100) 8.2.18 "Segment LCD Source Clock Control Register (SLCDSCKCR)" for details. */

      R_BSP_SoftwareDelay(5, BSP_DELAY_UNITS_MILLISECONDS);

      /* Start SLCDC output */

      err = R_SLCDC_Start(&g_slcdc0_ctrl);

      assert(FSP_SUCCESS == err);

    /* Set Display Area of SLCDC driver.*/

    // err = R_SLCDC_SetDisplayArea(&g_slcdc0_ctrl, SLCDC_DISP_A);

    // assert(FSP_SUCCESS == err);

    //准备并写入段显示数据,第一个数码管显示1

    uint8_t segment_data_num1[] = {

    0x00,0x00,0x00,0x00,0x00,

    0x00,0x00,0x00,0x00,0x00,

    0x00,0x6

    };

    R_SLCDC_Write(&g_slcdc0_ctrl, 0, segment_data_num1, sizeof(segment_data_num1));

    R_BSP_SoftwareDelay (500, BSP_DELAY_UNITS_MILLISECONDS);
    //准备并写入段显示数据,第二个数码管显示2

    uint8_t segment_data_num2[] = {

    0xE,0x3};

    R_SLCDC_Write(&g_slcdc0_ctrl, 15, segment_data_num2, sizeof(segment_data_num2));

    R_BSP_SoftwareDelay (500, BSP_DELAY_UNITS_MILLISECONDS);
    //准备并写入段显示数据,第三个数码管显示3

    R_SLCDC_Modify(&g_slcdc0_ctrl, 22, 0xA, 0xF);

    R_SLCDC_Modify(&g_slcdc0_ctrl, 23, 0x7, 0xF);

    R_BSP_SoftwareDelay (500, BSP_DELAY_UNITS_MILLISECONDS);
    //准备并写入段显示数据,第四个数码管显示4

    R_SLCDC_Modify(&g_slcdc0_ctrl, 24, 0x3, 0xF);

    R_SLCDC_Modify(&g_slcdc0_ctrl, 29, 0x6, 0xF);

    R_BSP_SoftwareDelay (500, BSP_DELAY_UNITS_MILLISECONDS);
    //准备并写入段显示数据,第五个数码管显示5

    R_SLCDC_Modify(&g_slcdc0_ctrl, 30, 0xB, 0xF);

    R_SLCDC_Modify(&g_slcdc0_ctrl, 39, 0x5, 0xF);

    R_BSP_SoftwareDelay (500, BSP_DELAY_UNITS_MILLISECONDS);
    //准备并写入段显示数据,第六个数码管显示6

    R_SLCDC_Modify(&g_slcdc0_ctrl, 40, 0xF, 0xF);

    R_SLCDC_Modify(&g_slcdc0_ctrl, 41, 0x5, 0xF);

    R_BSP_SoftwareDelay (500, BSP_DELAY_UNITS_MILLISECONDS);
    UART9_Init();

    hal_systick_init();

    ebtn_APP_Key_INIT();
    printf("\r\n欢迎来到瑞萨电子\r\n");

    printf("很高兴试用RA4L1开发板********\r\n");

    printf("串口输出打印 波特率115200\r\n\r\n");
    while (1)

    {

    /* USER CODE END WHILE */
    //HAL_Delay(300);

    /* USER CODE BEGIN 3 */

    switch(button_count)

    {

    case 1:

    LED1_LED2_ON();

    printf("LED1 LED2 同时亮\r\n");

    break;
       case 2:
     	 LED1_LED2_1();
     	 printf("LED1先亮200ms 熄灭 然后LED2亮200ms 熄灭 重复\\r\\n");
    
     	 break;
       case 3:
     	 LED1_LED2_2();
     	 printf("LED1 LED2同时亮200ms 熄灭200ms 重复\\r\\n");
    
     	 break;
       case 4:
     	 led_1_flicker();
     	 printf("led1闪烁\\r\\n");
     	 break;
       case 5:
     	 led_2_flicker();
     	 printf("led2闪烁\\r\\n");
     	 break;
       case 6:
     	 led_3_flicker();
     	 printf("led3闪烁\\r\\n");
     	 break;
       default:
          LED1_LED2_OFF();
       //printf("LED1 LED2 同时熄灭\\r\\n");
     	 break;
    

    }

/*

//清空0-41段

uint8_t segment_data_num_off[41+1] ;

for(int i=0;i<=41;i++)

segment_data_num_off[i]=0;

R_SLCDC_Write(&g_slcdc0_ctrl, 0, segment_data_num_off, sizeof(segment_data_num_off));

R_BSP_SoftwareDelay (1000, BSP_DELAY_UNITS_MILLISECONDS);

//全部点亮
uint8_t segment_data_num_on[41+1] ;
for(int i=0;i<=41;i++)
	segment_data_num_on[i]=0xf;
R_SLCDC_Write(&g_slcdc0_ctrl, 0, segment_data_num_on, sizeof(segment_data_num_on));
R_BSP_SoftwareDelay (1000, BSP_DELAY_UNITS_MILLISECONDS);

//准备并写入段显示数据,第一个数码管显示1
R_SLCDC_Modify(&g_slcdc0_ctrl, 3, 0x0, 0xF);
R_SLCDC_Modify(&g_slcdc0_ctrl, 11, 0x6, 0xF);

//准备并写入段显示数据,第二个数码管显示2
R_SLCDC_Modify(&g_slcdc0_ctrl, 15, 0xE, 0xF);
R_SLCDC_Modify(&g_slcdc0_ctrl, 16, 0x3, 0xF);

//准备并写入段显示数据,第三个数码管显示3
R_SLCDC_Modify(&g_slcdc0_ctrl, 22, 0xA, 0xF);
R_SLCDC_Modify(&g_slcdc0_ctrl, 23, 0x7, 0xF);

//准备并写入段显示数据,第四个数码管显示4
R_SLCDC_Modify(&g_slcdc0_ctrl, 24, 0x3, 0xF);
R_SLCDC_Modify(&g_slcdc0_ctrl, 29, 0x6, 0xF);

//准备并写入段显示数据,第五个数码管显示5
R_SLCDC_Modify(&g_slcdc0_ctrl, 30, 0xB, 0xF);
R_SLCDC_Modify(&g_slcdc0_ctrl, 39, 0x5, 0xF);

//准备并写入段显示数据,第六个数码管显示6
R_SLCDC_Modify(&g_slcdc0_ctrl, 40, 0xF, 0xF);
R_SLCDC_Modify(&g_slcdc0_ctrl, 41, 0x5, 0xF);
R_BSP_SoftwareDelay (1000, BSP_DELAY_UNITS_MILLISECONDS);

*/

}

#if BSP_TZ_SECURE_BUILD

/* Enter non-secure code */

R_BSP_NonSecureEnter();

#endif

}

/*******************************************************************************************************************//**

  • This function is called at various points during the startup process. This implementation uses the event that is

  • called right before main() to set up the pins.

  • @param[in] event Where at in the start up process the code is currently at

    **********************************************************************************************************************/

    void R_BSP_WarmStart (bsp_warm_start_event_t event)

    {

    if (BSP_WARM_START_RESET == event)

    {

    #if BSP_FEATURE_FLASH_LP_VERSION != 0

    /* Enable reading from data flash. */
     R_FACI_LP->DFLCTL = 1U;
    
     /* Would normally have to wait tDSTOP(6us) for data flash recovery. Placing the enable here, before clock and
      * C runtime initialization, should negate the need for a delay since the initialization will typically take more than 6us. */
    

#endif

}

if (BSP_WARM_START_POST_C == event)
{
    /* C runtime environment and system clocks are setup. */

    /* Configure pins. */
    R_IOPORT_Open(&IOPORT_CFG_CTRL, &IOPORT_CFG_NAME);

#if BSP_CFG_SDRAM_ENABLED

/* Setup SDRAM and initialize it. Must configure pins first. */
    R_BSP_SdramInit(true);

#endif

}

}

#if BSP_TZ_SECURE_BUILD

FSP_CPP_HEADER

BSP_CMSE_NONSECURE_ENTRY void template_nonsecure_callable ();

/* Trustzone Secure Projects require at least one nonsecure callable function in order to build (Remove this if it is not required to build). */

BSP_CMSE_NONSECURE_ENTRY void template_nonsecure_callable ()

{

}

FSP_CPP_FOOTER

#endif
image.png

image.png

image.png

上面的代码就是初始化LCD模块,并且在6个数码管里依次写入123456,间隔500ms
image.png

然后烧录代码到板子
image.png

6521909ac8f65506dc6745e50a91aab.jpg

详情看视频

更多回帖

发帖
×
20
完善资料,
赚取积分