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.

Bug in Driverlib 2.91.00.20 RTC_C_setCounterValue function?



Hello,

Function RTC_C_setCounterValue has following code:

 if(mode == RTC_C_COUNTERSIZE_8BIT && counterValue > 0xF)
    {
        counterValue = 0xF;
    }
    else if(mode == RTC_C_COUNTERSIZE_16BIT && counterValue > 0xFF)
    {
        counterValue = 0xFF;
    }
    else if(mode == RTC_C_COUNTERSIZE_24BIT && counterValue > 0xFFFFFF)
    {
        counterValue = 0xFFFFFF;
    }

Should not the code be:

if (mode == RTC_C_COUNTERSIZE_8BIT && counterValue > UINT8_MAX) {
		counterValue = UINT8_MAX;
	} else if (mode == RTC_C_COUNTERSIZE_16BIT && counterValue > UINT16_MAX) {
		counterValue = UINT16_MAX;
	} else if (mode == RTC_C_COUNTERSIZE_24BIT && counterValue > 0xFFFFFF) {
		counterValue = 0xFFFFFF;
	}

And another question, is the lack of writing zero to RTCCTL0_H register at the end of functions RTC_C_initCounter and RTC_C_initCounterPrescale are intended?

Edit:

RTC_C_initCalendar function:

void RTC_C_initCalendar(uint16_t baseAddress,
                        Calendar *CalendarTime,
                        uint16_t formatSelect)
{
    HWREG8(baseAddress + OFS_RTCCTL0_H) = RTCKEY_H;

    HWREG8(baseAddress + OFS_RTCCTL13_L) |= RTCHOLD;
    HWREG8(baseAddress + OFS_RTCCTL13) |= RTCMODE;      ///<<< This line is required and missing in driverlib?

    HWREG16(baseAddress + OFS_RTCCTL13_L) &= ~(RTCBCD);
    HWREG16(baseAddress + OFS_RTCCTL13_L) |= formatSelect;

    HWREG8(baseAddress + OFS_RTCTIM0_L) = CalendarTime->Seconds;
    HWREG8(baseAddress + OFS_RTCTIM0_H) = CalendarTime->Minutes;
    HWREG8(baseAddress + OFS_RTCTIM1_L) = CalendarTime->Hours;
    HWREG8(baseAddress + OFS_RTCTIM1_H) = CalendarTime->DayOfWeek;
    HWREG8(baseAddress + OFS_RTCDATE_L) = CalendarTime->DayOfMonth;
    HWREG8(baseAddress + OFS_RTCDATE_H) = CalendarTime->Month;
    HWREG16(baseAddress + OFS_RTCYEAR) = CalendarTime->Year;

    HWREG8(baseAddress + OFS_RTCCTL0_H) = 0x00;
}

**Attention** This is a public forum