Digital Clock using Interrupt

Thread Starter

PIYUSH SONI

Joined Nov 15, 2013
32
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...
 

JohnInTX

Joined Jun 26, 2012
4,787
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:

ErnieM

Joined Apr 24, 2011
8,415
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:




;-)
 

Brian Griffin

Joined May 17, 2013
64
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. :)
 
Top