Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

MIKROC : error (help) !!!!!

Status
Not open for further replies.

Ihcaamel

Newbie level 4
Joined
May 5, 2011
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,317
I made ​​a program in mikroC and I used a function with variable of type char as subroutine.
my problem is that I am appealing to this sub program twice and this results in a compilation error:

2 365 Reentrancy is not allowed: function 'Emission_Message' called from two threads PR_PFE.c

47 365 Reentrancy is not allowed: function 'UART1_Write_Text' called from two threads __Lib_UART_c67.c

39 365 Reentrancy is not allowed: function 'UART1_Write' called from two threads __Lib_UART_c67.c

help me please !!!!!
 

Are you calling the same function from the interrupt subroutine and the main program?
MicroC doesn't allow that.
 

yes I did that and what is the solution????
 

Sorry for the delay.

You should avoid doing any processing in interrupt routine, and keep it as short as possible. Just rudimentary checking and simple data moving.
For example: if your program allows for regular checking of an variable, you could designate an register as a manual flag register, and use the interrupt routine just to set the flag in that register when the byte is received, or sent (or better yet, set it only when whole data chunk is received, or sent).

I'll try to attach a simple program that receives data on UART, and sends it back to terminal when RB0 button is pressed. Program is receiving until 0x0D is byte received. Same for sending.
USART receive, send and RB0 button work as interrupt.

I don't know which MCU you are using (this is for P16F628), but it should be enough to show the idea of what I'm trying to say.
 

Attachments

  • UART__interrupt_driven.txt
    3 KB · Views: 87
get to correct mistakes but I have a little problem here is the part of the program:

void main() { char R,X;trisb.f0=1;intcon=0xA0;tri sb.f6=0;
UART1_init(9600);
Delay_ms(100);
loop:
lecture_message ();
if(X==1){ Emission_Message(); Emission_presence();X=0; }

if(UART1_Data_Ready()){
R=UART1_Read();

if(R=='a'){ PORTB.f6=1; Emission_Message();
Emission_alume();}
else { if(R=='e' ){ PORTB.f6=0;Emission_Message(); Emission_Eteint();}
else {Emission_Message(); Emission_Erreur();};};};
goto loop;
}
void interrupt(){char X;X=1;intcon.f0=0;}


the problem is that when I break the spell and I returned to the main program I can find by loaded by a variable X
may be that the variable does not return a value or it is not the same in the main program ?????
how do I use the interruption to work in the main program ?????
knowing that my goal and send an SMS when you stop But mikroC does not allow the function call by two UART1_WRITE program that is why I try to work with a variable that I can act in Senior Program

please help me !!!!!!!!

---------- Post added at 02:03 ---------- Previous post was at 01:56 ----------

Sorry for the delay.

You should avoid doing any processing in interrupt routine, and keep it as short as possible. Just rudimentary checking and simple data moving.
For example: if your program allows for regular checking of an variable, you could designate an register as a manual flag register, and use the interrupt routine just to set the flag in that register when the byte is received, or sent (or better yet, set it only when whole data chunk is received, or sent).

I'll try to attach a simple program that receives data on UART, and sends it back to terminal when RB0 button is pressed. Program is receiving until 0x0D is byte received. Same for sending.
USART receive, send and RB0 button work as interrupt.

I don't know which MCU you are using (this is for P16F628), but it should be enough to show the idea of what I'm trying to say.



thank you Mr. bjuric I don't understand what you give me!
I work with PIC16F877A
once again thank you for your reply
 

Code:
void main() { char R,X;trisb.f0=1;intcon=0xA0;tri sb.f6=0;
UART1_init(9600);
Delay_ms(100);
loop:
lecture_message ();
if(X==1){ Emission_Message(); Emission_presence();X=0; }....
You didn't define the value of the variable X, and you're checking 'if (X==1)'. In the beginning of the program, X has no value (actually it holds some unknown value). Also R holds no value.


A dirty solution for the interrupt problem would be
char send_flag = 0;
char receive_flag = 0;

In the interrupt routine instead of UART1_WRITE, just set send_flag = 1.

And in the loop in the main program put an 'if' to check that register:
if (send_flag == 1) { send_flag = 0; UART1_WRITE(.....); }
And inside this 'if', do the things that you're doing now in the interrupt routine.
 

Code:
void main() { char R,X;trisb.f0=1;intcon=0xA0;tri sb.f6=0;
UART1_init(9600);
Delay_ms(100);
loop:
lecture_message ();
if(X==1){ Emission_Message(); Emission_presence();X=0; }....
You didn't define the value of the variable X, and you're checking 'if (X==1)'. In the beginning of the program, X has no value (actually it holds some unknown value). Also R holds no value.


A dirty solution for the interrupt problem would be
char send_flag = 0;
char receive_flag = 0;

In the interrupt routine instead of UART1_WRITE, just set send_flag = 1.

And in the loop in the main program put an 'if' to check that register:
if (send_flag == 1) { send_flag = 0; UART1_WRITE(.....); }
And inside this 'if', do the things that you're doing now in the interrupt routine.


Thank you Mr.Bjuric I corrected the error: (declaration of the variable X out all function to make it global)
May Allaah help you for the good
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top