打印
[APM32F4]

【APM32F411V开发板测评】+用OLED屏显示板载RTC时间与日期

[复制链接]
193|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
stb988|  楼主 | 2024-5-6 15:13 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 stb988 于 2024-5-6 15:40 编辑

#每日话题# #申请原创#     外接了一块SSD1306驱动芯片的OLDE屏,用OLED屏来显示APM32F411V芯片自带的RTC时间,本来想用自带的IIC驱动来驱动oled,测试了一下,没有显示成功,索性就直接用模拟iiC实现吧,接的单片机PB6和PB7,查了数据手册,硬件iic也是这两个接口。   
接好线

移植网上的例程,发现能显示,但是显示一会会卡死,后来发现是写入速度太快,我把GPIO口调慢,和显示点的函数也加了空指令延时就解决了。
  GPIO_Config_T  gpioConfigStruct;
        
    /* Enable the GPIO_LED Clock */
    RCM_EnableAHB1PeriphClock(RCM_AHB1_PERIPH_GPIOB);

    /* Configure the GPIO_LED pin */
    GPIO_ConfigStructInit(&gpioConfigStruct);
    gpioConfigStruct.pin = GPIO_PIN_6|GPIO_PIN_7;
    gpioConfigStruct.mode = GPIO_MODE_OUT;
    gpioConfigStruct.speed = GPIO_SPEED_25MHz;
        

    GPIO_Config(GPIOB, &gpioConfigStruct);
    GPIOB->BSCL = GPIO_PIN_6|GPIO_PIN_7;
改成GPIO_SPEED_25MHz;
还有一个在oled初始化时,发现也必须延时一段时间,否则上电会显示倒的图像,还会显示亮度不够,
 //OLED_RES_Clr();
        delay_ms(1000);
//        OLED_RES_Set();
        
        OLED_WR_Byte(0xAE,OLED_CMD);//--turn off oled panel
        OLED_WR_Byte(0x00,OLED_CMD);//---set low column address
        OLED_WR_Byte(0x10,OLED_CMD);//---set high column address
        OLED_WR_Byte(0x40,OLED_CMD);//--set start line address  Set Mapping RAM Display Start Line (0x00~0x3F)
        OLED_WR_Byte(0x81,OLED_CMD);//--set contrast control register
        OLED_WR_Byte(0xCF,OLED_CMD);// Set SEG Output Current Brightness
        OLED_WR_Byte(0xA1,OLED_CMD);//--Set SEG/Column Mapping     0xa0左右反置 0xa1正常
        OLED_WR_Byte(0xC8,OLED_CMD);//Set COM/Row Scan Direction   0xc0上下反置 0xc8正常
        OLED_WR_Byte(0xA6,OLED_CMD);//--set normal display
        OLED_WR_Byte(0xA8,OLED_CMD);//--set multiplex ratio(1 to 64)
        OLED_WR_Byte(0x3f,OLED_CMD);//--1/64 duty
        OLED_WR_Byte(0xD3,OLED_CMD);//-set display offset        Shift Mapping RAM Counter (0x00~0x3F)
        OLED_WR_Byte(0x00,OLED_CMD);//-not offset
        OLED_WR_Byte(0xd5,OLED_CMD);//--set display clock divide ratio/oscillator frequency
        OLED_WR_Byte(0x80,OLED_CMD);//--set divide ratio, Set Clock as 100 Frames/Sec
        OLED_WR_Byte(0xD9,OLED_CMD);//--set pre-charge period
        OLED_WR_Byte(0xF1,OLED_CMD);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
        OLED_WR_Byte(0xDA,OLED_CMD);//--set com pins hardware configuration
        OLED_WR_Byte(0x12,OLED_CMD);
        OLED_WR_Byte(0xDB,OLED_CMD);//--set vcomh
        OLED_WR_Byte(0x40,OLED_CMD);//Set VCOM Deselect Level
        OLED_WR_Byte(0x20,OLED_CMD);//-Set Page Addressing Mode (0x00/0x01/0x02)
        OLED_WR_Byte(0x02,OLED_CMD);//
        OLED_WR_Byte(0x8D,OLED_CMD);//--set Charge Pump enable/disable
        OLED_WR_Byte(0x14,OLED_CMD);//--set(0x10) disable
        OLED_WR_Byte(0xA4,OLED_CMD);// Disable Entire Display On (0xa4/0xa5)
        OLED_WR_Byte(0xA6,OLED_CMD);// Disable Inverse Display On (0xa6/a7)
        OLED_Clear();
        OLED_WR_Byte(0xAF,OLED_CMD);
显示成功后,就可以把RTC开启,时间读取出来了

这是显示效果。
APM32F411_OLED.rar (7.87 MB)

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

35

主题

267

帖子

1

粉丝