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.

question about internal interrupt-MikroC !!!

Status
Not open for further replies.

asrock

Junior Member level 3
Joined
Sep 10, 2010
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,538
hello every one ....

as my project i made i faced a problem ..

my project is a simple receiver and transmitter using RF modules using two [16f877 xtal:8MHz]

and every circuit of my project has receiver and transmitter for receive and transmit data to other one...

here in the reviver circuit i made that when i receive a signal from transmitter circuit the receiver must send data .
but in the same time the receiver get ready for transmitting another data...

the problem was in condition for receiving this signal ... here i must make an [interrupt] to interrupt program execution and jump to transmitting mode for many cycles to be completed the data sending....

but i don't know how to make this interrupt and how to call it in condition ... [it's so simple interrupt program just for interrupting execution

so any one can give me the idea of this problem or a simple code to make this :plz

thx
 

hello,

Your probleme is not interrupt treatment,
PIC allready must use interrupts in UART functions,
you have to define a protocol for exchanging data between your 2 devices.

What can of data your are transmitting..
Raw data (binary data) or ascii data ?

simplest protocole can be use if ascii data
ENQ
ACK
NACK
...
response
to define which will talk, and witch will heard ..
search on the web the appropriate protocole ..

More serious protocole with binary data, as Modbus or other...

or you can defined by yourself , your own protocole.
 

thanks mr.paulfjujo

i don't use any protocol , sure i deal with UART library ,,,

and this is my code and i will explain my problem in it by comments:

Code:
char string0;

if (receiver_active==1)   { 	// here i just connect rf receiver(vcc) to pic pin for enable it  while  rf transmitter works ,and vice versa

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


              if (string0==20) { 	// here if i receive this signal (20) the program transmit data - just signal
	receiver_active==0;
                  transmitter_active==1;
             UART1_Write_Text("my data to be sent");
                  transmitter_active==0;
	receiver_active==1;
                  
          	// here the problem that sending through receiving data is not logicaly as this . bcz it take many cycles for that ,, !!!
            }
}

}

so i suggest if i put an interrupt for sending section , and execute it for many cycles and return back ,,,

what's your opinion ?!!!
 

hello,

it seems you do caracteres receiving by pooling !
in fact, with mikroC it is not evident how UART procedures are working,
example : does UART1_Write_Text uses char UARTx_Tx_Idle(); ?

for me C18 is more complicated but more efficient than MikroC
because we can declare an interrupt for receiving caracteres and another for sending more easily.
Maybe you have to write your own interrupt subroutine by using the UART register directly, not with MikroC librairy.

If i understund correctly, you need to send data just after receiving the caractere 20 (space)
and during the time of text sending ,you can not receiving other car ?

so solution could be Interrupt on receiving , every carcatere can be stored in a buffer , and you do analysis of the buffer in a main loop
to decide when you can transmit without disturbing receiving data.

or Maybe you can send your texte , car by car, in a timer interruption
when you receive car=20 ,
initialise the text to transmit in a variable ex char txt[32]; with strcpy...
put Timer interupt flag to 1 (Timerx allready initilised for ie: 1 mS)
in the interrupt subroutine
if (txt[j]!=0 UART1_Write( txt[j] ; else Timer Flag=0;
every xmS you send a car, until end of string (=0)
after disable interrupt
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top