0
\$\begingroup\$

I'm quite new in the microcontroller world, since I work on it only for my internship. But I have a problem in my main project. I was implementing an automaton based on a PIC18F46J50, and we printed the final product on a board using a new pic. I choosed a PIC18F45K22.

We realised yesterday that this PIC does not handle th RTCC module, and it is one of the main features of this project. Since the board is already printed, it's a big problem to find a PIC with the same number of PIN, but it's my year project, so it's quite important for me to find a solution so here is my question.

Is there any other PIC that have 44 PIN (or 40) and a RTCC module ? Or is there any way to implement a RTCC module without it on the PIC ?

\$\endgroup\$
3
  • \$\begingroup\$ You can use Microchip Advanced Part Selector to search for another PIC with the same number of pins and an RTCC \$\endgroup\$
    – m.Alin
    Commented Aug 1, 2015 at 12:37
  • \$\begingroup\$ And yes, you can implement an RTCC in software, provided that your system doesn't lose power. \$\endgroup\$
    – m.Alin
    Commented Aug 1, 2015 at 12:38
  • \$\begingroup\$ ok, it's to late to by an other PIC, but we made some software modification and it can do the trick. btw an other solution would have been to use RTCC module trough I2C or SPI bus \$\endgroup\$
    – Nico Balas
    Commented Aug 4, 2015 at 14:15

1 Answer 1

1
\$\begingroup\$

I found a software solution, I programmed the calendar in interuption.

this is the solution for PIC18F45K22 on TIMER 1 in low interupt.

if(PIR1bits.TMR1IF && PIE1bits.TMR1IE)
  {
      PIR1bits.TMR1IF =0; /* Clear Interrupt Flag 1 */
      TMR1H = TMR1H_INIT;
      TMR1L = TMR1L_INIT;
      hal_clk_ITtask();
  }

and the hal_clk_ITtask();

void hal_clk_ITtask()
{
tmdt.f.sec ++;
if(tmdt.f.sec == 60)
{
    tmdt.f.min ++;
    tmdt.f.sec = 0;
}
if(tmdt.f.min == 60)
{
    tmdt.f.hour ++;
    tmdt.f.min = 0;
}
if(tmdt.f.hour == 24)
{
    tmdt.f.day ++;
    tmdt.f.hour = 0;
}
if(tmdt.f.day == 7)
{
    tmdt.f.day = 0;
}
}

but I can't be sure of the precision. I didn't test it for more than an hour.

\$\endgroup\$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.