TI中文支持网
TI专业的中文技术问题搜集分享网站

tm4c129x时钟显示

如何实现在TM4C129X开发板的QVGA LCD上显示时间,哪位大神有这方面的代码,参考代码也行?十分感谢!

xyz549040622:

/*Code made with energia-0101E0012This code is suposed to help clarify anyone with doubts of how to use very basic fuctions of the RTCin the hibernation peripheral and also the hardware calendar mode. Any sugestions and improvements are always welcomeThis example only changes and show hour, minutes and seconds but there's:psTime->tm_minpsTime->tm_secpsTime->tm_monpsTime->tm_mdaypsTime->tm_wdaypsTime->tm_yearpsTime->tm_hour*/
#include "driverlib/hibernate.c"void HibernateHandler(void)
{//Use this to reset interrupt flaguint32_t ui32Status = HibernateIntStatus(1);HibernateIntClear(ui32Status);//Place here code to execute every second, ex: LCD or 7 segment display//Altough it should be as fastest as possible//To keep the interrupt hapening every second you need thisHibernateRTCMatchSet(0,HibernateRTCGet()+1);}/*It's need a struct pointer of the type "tm" so i use new to do that. This type of struct is defined in the driverlib/hibernationyou could also create it like this: tm temp; and then use &temp and temp.values in the fuctions*/
tm *temp = new tm;void setup()
{Serial.begin(9600);// put your setup code here, to run once://Enable Hibernate peripheral. I'm using Energia so i use F_CPU for geting the clock frequencyHibernateEnableExpClk(F_CPU);HibernateRTCEnable();//We set a interrupt for the RTC after second. You can change the valueHibernateRTCMatchSet(0,HibernateRTCGet()+1);HibernateIntRegister(HibernateHandler);HibernateIntEnable(HIBERNATE_INT_RTC_MATCH_0);//Set up calender mode. HibernateCounterMode() is always needed but can be set to 12hr modeHibernateCounterMode(HIBERNATE_COUNTER_24HR);HibernateCalendarSet(temp); //<-- the struct declared//We change the hour, minutes and secondstemp->tm_hour= 23;temp->tm_min=59;temp->tm_sec = 50;//This fuction below is what actualy updates the values inside the peripheral.//if you don't use it, the value changes above won't do anytighHibernateCalendarSet(temp);}void loop()
{//This is to take the "live" values that the RTC keeps updating into our structHibernateCalendarGet(temp);Serial.print(temp->tm_hour);Serial.print(':');Serial.print(temp->tm_min);Serial.print(':');Serial.println(temp->tm_sec);delay(1000);
}

网上找到的。没验证过,使用的是RTC的功能,自己对照的库函数的数据手册看吧。

zhuyanmeng ZHU:

回复 xyz549040622:

TM4C129X有内置的RTC吗?可以显示实时时间吗

xyz549040622:

回复 zhuyanmeng ZHU:

是有RTC模式的,但是没有用过,是否可以像RTC时钟芯片那样,自动计算时间日期呢,你需要具体研究下。

zhuyanmeng ZHU:

回复 xyz549040622:

他有RTC的例程吗?

xyz549040622:

回复 zhuyanmeng ZHU:

看我二楼的程序,官方没提供例程。

赞(0)
未经允许不得转载:TI中文支持网 » tm4c129x时钟显示
分享到: 更多 (0)