做了一块MSP430 F5529转接板看起来漂亮一点,没有就直接用杜邦线接线。
https://blog.csdn.net/x1131230123/article/details/108772807
Analog clock. Starting with the current time, draw a clock face and the hour, minute and seconds hand.
Use the RTC module in the MSP430, and move the hands to show the correct time.
1、
模拟时钟 OLED
功能:实时显示时钟;按键修改时钟。
2、
最终效果:

3、
硬件:OLED和MSP430 F5529自带的2个按键
c展开代码OLED接线
//            |             P3.1|<- Data In (UCB0SOMI)
//            |    F5       P3.0|-> Data Out (UCB0SIMO)   --D1(OLED)
//            |             P3.2|-> Serial Clock Out (UCB0CLK)  --D0(OLED)
//            |             P2.0|->RES(OLED)
//            |             P2.2|->DC(OLED)
//            |             P8.1|->CS(OLED)
4、
主函数中初始化时钟为25MHZ,初始化OLED,初始化2个按键。初始化模拟时钟的表盘显示,初始化MSP430 F5529内部的RTC模块,打开总中断。
c展开代码int main(void)
{
    WDTCTL = WDTPW + WDTHOLD; /* Stop WDT */
    initClock();                //25MHZ
    OLED_Init(); /* 初始化OLED */
    /*按键1 */
    P1DIR &= ~(BIT1);
    P1OUT |= (BIT1);
    P1REN |= (BIT1);
    /*按键2 */
    P2DIR &= ~(BIT1);
    P2OUT |= (BIT1);
    P2REN |= (BIT1);
    init_Point_Clock();
    Display_Pointer(Point_Time[1], 1);
    SetupRTC(); /* set RTC */
    _EINT();
    while (1)
    {
        KEY_Scan();
    }
}
每一秒发生中断,去更新模拟时钟的显示:去掉上次时间的指针显示----->显示这次的时间指针。每一秒发生中断,去更新时钟数字的显示。
c展开代码        Display_Pointer(Point_Time[1], 0); //去掉上次时间的指针显示
        Point_Time[1].hour = RTCHOUR;
        Point_Time[1].minute = RTCMIN;
        Point_Time[1].second = RTCSEC;
        Display_Pointer(Point_Time[1], 1); //显示这次的时间指针
主函数不断KEY_Scan()循环检测按键,处理按键。
按键1 修改想要更改的项目
按键2 增加数值
代码:
https://github.com/xxddccaa/blog_code_search
csharp展开代码https://docs.qq.com/sheet/DUEdqZ2lmbmR6UVdU?tab=BB08J2


本文作者:Dong
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC。本作品采用《知识共享署名-非商业性使用 4.0 国际许可协议》进行许可。您可以在非商业用途下自由转载和修改,但必须注明出处并提供原作者链接。 许可协议。转载请注明出处!