Digital Clock using Interrupt

Discussion in 'Embedded Systems and Microcontrollers' started by PIYUSH SONI, Jan 13, 2014.

  1. PIYUSH SONI

    Thread Starter Member

    Nov 15, 2013
    32
    1
    Hi,
    I am using pic18f4520 mcu and coding in microC Pro for PIC. I am working on a digital clock using 128 64 GLCD. Here i want to get the clock display using RTC DS1307 but it's not working out.
    I have used Glcd command and while compiling the program it shows Reinterruncy error.
    Can anyone tell me why it's happening.
    Help me out...
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,431
    3,360
    You need to show your code.
     
  3. JohnInTX

    Moderator

    Jun 26, 2012
    2,341
    1,024
    This error?
    - Reentrancy is not allowed: function[%s] called from two threads


    The most likely cause is that you are calling the same function (or different functions that in turn call a common function) from both the main and interrupt code. Due to PIC specifics, most functions in any 8 bit C are not re-entrant.
     
    Last edited: Jan 13, 2014
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    If "Reinterrunc" is your problem then as John said you're calling a routine in the ISR... generally never do that, just use direct code in the ISR.

    Outside the ISR you can use variables as flags to see if something needs attention. Especially in a clock there is nothing happening until a new second or minute occurs, so when it does (assuming you trap that event in the ISR) you set a flag.

    The main code needs a loop that just tests that flag, and when it happens the main code resets the flag, then updates the display.

    BTW, if you go to a color display you can get one like mine:

    [​IMG]


    ;-)
     
    Brian Griffin and JohnInTX like this.
  5. JohnInTX

    Moderator

    Jun 26, 2012
    2,341
    1,024
    OK, ErnieM. That is very cool.
     
  6. Brian Griffin

    Member

    May 17, 2013
    40
    12
    Been using MikroC stuff for some time - do not put MikroC library functions in the interrupt.

    The thread OP must have accessed the I2C library in the interrupt. I fell into that trap before.

    ErnieM: I like that "digital clock". I have a spare MikroMedia for dsPIC board too, maybe I'll make one for myself if I got the free time. :)
     
Loading...