Hi,
Thanks for helping me out. Actually my program is somehow up and running now but with a few limitations. (Pls take a careful look at //********** part).
My baud rate setting is 9600. For both interrupts, they do not run at the same time since flags are set to fire TxIRQ only after RxIRQ is done.
To Ake, pls take a look at my IRQ handlers. SCI2S1 is read and I suppose flags are properly cleared. I do not understand what you mean by the routine should not take more than 10%of the time. I believe the interrupts will shoot according to the baud rate which means 0.104 ms per character(9600b/s) and evertime each character is sent out or received, the interrupt will occur. Do correct me if my perception is wrong.
Here are my IRQ handlers. They are declared above main().
//---IRQ handlers---------------------------------------------------------
interrupt VSCI2RX void SCI2RXIRQ(){ //having declared VSCI2RX=20
ucSCI2S1_RxReadChar=SCI2S1; //clearing flag according to application note
ucRecvChar=SCI2D;
if((gucRxStrRdyFlg==RX_START)||(gucRxStrRdyFlg==RX_PROCESSING)){ //flags are set in main
SCI2Rx_getMAC(ucRecvChar); //receiving data (e.g. !1000#), this function is declared
}
}
interrupt VSCI2TX void SCI2TXIRQ(){ //having declared VSCI2TX=21
ucSCI2S1_TxReadChar=SCI2S1;
if((gucTxStrFlag==TX_START)||(gucTxStrFlag==TX_PROCESSING)){
SCI2Tx_sendPHY(&gaucTxChar[0]); //intend to transmit data (e.g. !001000#) upon receiving
}else{ //**********
SCI2C2_SBK=1;
SCI2C2_SBK=0;
}
}
//-------------------------------------------------------------------------------------------
In main(), I have enabled both TCIE and RIE. Here what I add in is
SCI2C2_SBK=1;
SCI2C2_SBK=0; so that I won't have the problem at all. The program works fine only if I add in this. If I do not queue a break character, the main program never gets a chance to execute at all. To be able to queue a break character, I need to use TCIE instead of TIE.
Here what I do not understand is why I cannot use TIE? The function to transmit data {which is SCI2Tx_sendPHY(&gaucTxChar[0]);} will only be executed according to the gucTxStrFlag settings (which I believe I have set them correctly in main()). If the right flags are not set, it won't transmit any data and shouldn't the whole program be alright? Well, if TIE is used instead of TCIE, the same problem of the main being not executed continue.
Do show me if you have any better solution than that.
And one more doubt. Is that possible to receive while at the same time transmitting? According to the vector no, RxIRQ has a higher vector priority than TxIRQ. Does that mean if I keep receiving, TxIRQ will never execute at all?
With Regards,
Lydia