This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hai all
Iam trying to display the RTC value of msp430fr5739 on LCD and UART
Iam using CCS v6. I test RTC and uart but problem is that when reading second and minute the value display as ASCII character. How to convert it to decimel?
Can I directly access RTCSEC reg anywhere?
When I display it on lcd only one decimel place is print example as when we want to print 23 , it print only 2 but the RTC incrimented correctly and minut interrupt works properly.
The main configuration are below
RTCCTL01 |= RTCTEVIE + RTCRDYIE +RTCHOLD+RTCBCD; //register config
//ISR
#pragma vector=RTC_VECTOR
__interrupt void RTC_ISR(void)
{
switch(__even_in_range(RTCIV,16))
{
case RTC_NONE: // No interrupts
break;
case RTC_RTCRDYIFG: // RTCRDYIFG
P1OUT ^= 0x01; // Toggles P1.0 every second
while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF =RTCMIN;
while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF =RTCSEC;
break;
case RTC_RTCTEVIFG: // RTCEVIFG
__no_operation(); // Interrupts every minute
break;
case RTC_RTCAIFG: // RTCAIFG
break;
case RTC_RT0PSIFG: // RT0PSIFG
break;
case RTC_RT1PSIFG: // RT1PSIFG
break;
case 12: break; // Reserved
case 14: break; // Reserved
case 16: break; // Reserved
default: break;
}
}
BINU K said:Can I directly access RTCSEC reg anywhere?
Yes.
BINU K said:When I display it on lcd only one decimel place is print example as when we want to print 23 , it print only 2 but the RTC incrimented correctly and minut interrupt works properly.
You configure the RTC for BCD mode on the registers. Therefore the RTCSEC register is encoded as a packed BCD. To properly display the value on a terminal, you need to convert the value into two ASCII characters. Example:
char rtcsecbcd, char1, char2; rtcsecbcd = RTCSEC; // Get the value atomically before parsing char1 = ((rtcsecbcd>> 4) & 0x07) + 0x30; // Tens digit of seconds char2 = (rtcsecbcd & 0x0F) +0x30; // Ones digit of seconds
Also, polling on the UART flags to transmit multiple characters inside an ISR is bad practice. No other ISR's can happen during the time it takes to transmit all those characters. In a proper system, you should have a UART driver with a queue, and inside your RTC ISR, you just add the characters to the UART driver queue, and the UART driver sends the characters on an interrupt-based process.
thank you Brian , It works
It working in UART and Iam trying to check in LCD
hai all,
I get hour,minute and second correctly, but problem is that it is in char , I want to take a single intiger value
these are working code for ones and tens position
rtcsecbcd = RTCSEC; // Get the value atomically before parsing
sec2 = (rtcsecbcd & 0x0F) +0x30; // Ones digit of seconds
sec1 = ((rtcsecbcd>> 4) & 0x07) + 0x30; // Tens digit of seconds
rtcminbcd = RTCMIN; // Get the value atomically before parsing
min1 = ((rtcminbcd>> 4) & 0x07) + 0x30; // Tens digit
min2 = (rtcminbcd & 0x0F) +0x30; // Ones digit
rtchourbcd = RTCHOUR; //
hour2 = (rtchourbcd & 0x0F) +0x30; // Ones digit
hour1 = ((rtchourbcd &0x30)>>4)+0x30; // Tens digit
and I try like this
second=sec1*10+sec2
but not working , can suggest a method?
I want to write a value from keypad and serialy received data and also read
please help
The conversion used for sec2 and sec1 converts the BCD value form the RTC into two human-readable digits (ASCII code).
If you want a numerical value for the seconds, you don’t have to add the 0x30 (which is the ASCII code offset of the ‘0’ letter).
Or you configure the RTC to not use BCD mode. Then the content of the RTCSEC register is already the numerical value (0..59).
Same for all other RTC registers.
**Attention** This is a public forum