Hello, pleasee anyone help me.
I'm having trouble making two interrupts work correctly in my code
the first refers to a clock, and the second to my UART communication
independent the two work properly, however when enabling the two at the same time the UART communication stops working properly, sending any data.
follows part of the code:
int main (void){
hfsec = 0;
sec = 0;
min = 10;
hour = 21;
WDTCTL = WDTPW + WDTHOLD; // Watch Dog timer
FLL_CTL0 = XCAP18PF; //0x0053 - FLL+ Control 0 = (0x30) - XIN Cap = XOUT Cap = 18pf
FLL_CTL1 = SCFQ_64K; //fdco=64k - 0x0054 - FLL+ Control 1 =
SCFQCTL = 0x28 + 5; //fLCD=fack/64 framing frequency~30hz - fMCLK = 2*fACLK
//Base timer 0.5sÖжÏÒ»´Î
IE2 |= 0x80; /* Interrupt Enable 2 */
LCDCTL = 0x5f; //s0-s11 fuctions as lcd segment lcdson=1 lcdon=1
P5SEL = 0xfc; //choose fuction:r13 r23 r33 com3.2.1
_BIS_SR(GIE); //equal to _EINT();*/
//_EINT();
UartConfig();
__bis_SR_register(GIE);
tx(0,"Diogel\r\n");
spi_setup();
while(1){ // main loop
lcd_clear();
varredura = kb_read();
savePass();
passRead();
if((KB_PORT_IN & LOG)==0){
log(); //here it returns me by serial communication the data of my memory
} // loop while (1)
} // função main
#pragma vector=BASICTIMER_VECTOR
//#pragma vector=TIMER0_A1_VECTOR
//#pragma vector=COMP_B_VECTOR
__interrupt void BT_ISR(void){
LPM3_EXIT;
hfsec++;
if(hfsec==2){
sec++;
hfsec=0;
}
// P6OUT^=LED0|LED1; //ledÃëµãÉÁ˸
// P6OUT^=LED0;
if(sec==60){
min++;
sec=0;
}
if(min==60){
hour++;
min=0;
}
if(hour==24){
hour=0;
}
SEC_H = tab[sec/10];
SEC_L = tab[sec%10];
MIN_H = tab[min/10];
MIN_L = tab[min%10];
HOUR_H = tab[hour/10];
HOUR_L = tab[hour%10];
}
// Timer A0 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) Timer_A (void)
#else
#error Compiler not supported!
#endif
{
CCR0 += Bitime; // Add Offset to CCR0
// RX
if (CCTL0 & CCIS0) // RX on CCI0B?
{
if( CCTL0 & CAP ) // Capture mode = start bit edge
{
CCTL0 &= ~ CAP; // Capture to compare mode
CCR0 += Bitime_5;
}
else
{
RXData = RXData >> 1;
if (CCTL0 & SCCI) // Get bit waiting in receive latch
RXData |= 0x80;
BitCntRX --; // All bits RXed?
if ( BitCntRX == 0) // se contador do RX zerar
//>>>>>>>>>> Decode of Received Byte Here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
{
if (pBufRxGPRS>=TamBufRxGPRS-2){
pBufRxGPRS=0;
}
if (RXData == 13){
RXEnter = 1;
// RXDado = 0;
// RXDado = (BufRxGPRS[pBufRxGPRS-3]<<16) | (BufRxGPRS[pBufRxGPRS-2]<<8) | (BufRxGPRS[pBufRxGPRS-1]);
// pBufRxGPRS=0;
}
BufRxGPRS[pBufRxGPRS++]=RXData;
CCTL0 &= ~ CCIE; // All bits RXed, disable interrupt
__bic_SR_register_on_exit(CPUOFF); // Clear LPM0 bits from 0(SR)
}
//>>>>>>>>>> Decode of Received Byte Here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
}
// TX
else
{
if ( BitCntTX == 0)
CCTL0 &= ~ CCIE; // All bits TXed, disable interrupt
else
{
CCTL0 |= OUTMOD2; // TX Space
if (TXData & 0x01)
CCTL0 &= ~ OUTMOD2; // TX Mark
TXData = TXData >> 1;
BitCntTX --;
}
}
}