FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Author Topic: FT900 RTC Interrupt - Help needed  (Read 12152 times)

NW27

  • Newbie
  • *
  • Posts: 7
    • View Profile
FT900 RTC Interrupt - Help needed
« on: June 25, 2018, 07:32:28 AM »

Hi,

I have the RTC oscillator ticking over. So the RTC_start, RTC_Read, RTC_Write and RTC_Stop seem to be working.
It seems to be adding about 36 counts per second. Is this correct? This seems to be a bit of a strange value. How do you set a divisor for this?

Ultimately, what I would like to do is have a RTC interrupt that happens every second.

I am using the MikroC compiler from Mikro Electronica.
I have the RTC interrupt vector (void RTC_ISR() iv IVT_RTC_IRQ ics ICS_AUTO ) pointing to my RTC Time updating code but basically the system just locks up when I enable the interrupt
Using     RTC_IEN_bit = 1 ;
RTC_CCR looks like 0x00 00 00 05.

Do I need to do something at the end of the interrupt ie clear a flag etc?

Thanks,
Neil.

Code: [Select]
tByte rtc_start(void)
{
//    RTC->RTC_CCR |= MASK_RTC_CCR_EN;
    RTC_EN_bit = 1 ;
    return 0;
}


tByte rtc_stop(void)
{
//    RTC->RTC_CCR &= ~MASK_RTC_CCR_EN;
    RTC_EN_bit = 0 ;
    return 0;
}


tByte rtc_write(unsigned long val)
{
//    RTC->RTC_CLR = val;
    RTC_CLR = val;
    return 0;
}

tByte rtc_read(unsigned long *val)
{
//    *val = RTC->RTC_CCVR;
    *val = RTC_CCVR;
    return 0;
}


tByte rtc_init(rtc_wrap_t wrap)
{
    tByte iRet = 0;
    if (wrap > rtc_wrap_enabled)
    {
        iRet = -1;
    }

    if (iRet == 0)
    {
        rtc_write(0UL);

        switch(wrap)
        {
            case rtc_wrap_disabled: RTC_CCR |= RTC_WEN; break ;
            case rtc_wrap_enabled: RTC_CCR &= ~RTC_WEN; break ;
            default: break;
        }
    }

    RTC_IEN_bit = 1 ;
    return iRet;
}


void RTC_ISR() iv IVT_RTC_IRQ ics ICS_AUTO {
  tbyte a ;
  if (++RTClock.second==60)        //keep track of time, date, month, and year
  {
    RTClock.second=0;
    if (++RTClock.minute==60)
    {
      RTClock.minute=0;
      if (++RTClock.hour==24)
      {
        RTClock.hour=0;
        if (++RTClock.dow==7) RTClock.dow= SUN ;
        if (++RTClock.date==32)
        {

Etc etc
Logged

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 892
    • View Profile
Re: FT900 RTC Interrupt - Help needed
« Reply #1 on: June 25, 2018, 09:23:14 AM »

Hello,

Since you are using the MikroC compiler from Mikro Electronica you will need to contact them for support.

Best Regards,
FTDI Community
Logged

NW27

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: FT900 RTC Interrupt - Help needed
« Reply #2 on: June 25, 2018, 10:35:35 AM »

Hi,
It is your micro and I'm asking you for help with regard to usage of the interrupt registers in your micro.
I am not asking for help with the compiler.
Neil.
Logged

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 892
    • View Profile
Re: FT900 RTC Interrupt - Help needed
« Reply #3 on: June 25, 2018, 01:41:49 PM »

Hello,

We provide some example code in AN_360 FT9xx Example Applications.
See RTC Example 2 which demonstrates RTC interrupt every 2 seconds. This example should be useful to you.

These examples are provided with the free FT9xx Toolchain which is different from the MikroE tools.

Note that the RTC functionality between FT90x and FT93x is different and this is commented in the source code since the toolchain supports both MCU variants.
The RTC in FT90x is a simple counter. It provides information as a basic “system on” timer. The RTC in FT930 provides more detailed information and is powered by an external battery source.

Best Regards,
FTDI Community
Logged

NW27

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: FT900 RTC Interrupt - Help needed
« Reply #4 on: June 26, 2018, 06:59:49 AM »

Hi,

When I perform a RTC_Read every 1Sec, I get a count difference of 32.

What would be the expected difference for a 32.768KHz osc?

Code: [Select]

int8_t RTC_Read(uint32_t *val)
{
    *val = RTC->RTC_CCVR;
    return 0;
}

main()
  RTC_Read(&a);
  delay_ms(1000);
  RTC_Read(&b);

  c = b-a ;
  // The value of C = 32

Logged

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 892
    • View Profile
Re: FT900 RTC Interrupt - Help needed
« Reply #5 on: June 28, 2018, 04:39:47 PM »

Hello,

There is no benchmark data available on this however we could contact R&D to request more information on this if it's critical to your needs.

Please contact us at support1@ftdichip.com.

Best Regards,
FTDI Community
Logged