Hello everyone,
i want to use SW UART by using Timer A in MSP430FW427, i am able to transmit the byte but having problem in receiving a byte. P1.0 (CCI0A) is used as a transmit pin and P1.1(CCI0B) as a receive pin. ISR for this is as follows
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
CCR0 += Bitime; // Add Offset to CCR0
// RX
if (CCTL0 & CCIS1) // RX on CCI0B? CCIS0
{
if( CCTL0 & CAP ) // Capture mode = start bit edge
{
CCTL0 &= ~ CAP; // Capture to compare mode
CCR0 += Bitime_5;
}
else
{
RXTXData = RXTXData >> 1;
if (CCTL0 & SCCI) // Get bit waiting in receive latch
RXTXData |= 0x80;
BitCnt --; // All bits RXed?
if ( BitCnt == 0)
//>>>>>>>>>> Decode of Received Byte Here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
{
CCTL0 &= ~ CCIE; // All bits RXed, disable interrupt
//_BIC_SR_IRQ(CPUOFF); // Clear LPM0 bits from 0(SR)
RX_Ready();
} //Byte received end
//>>>>>>>>>> Decode of Received Byte Here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
} //end of else
} //End of Received
// TX
else
{
if ( BitCnt == 0)
CCTL0 &= ~ CCIE; // All bits TXed, disable interrupt
else
{
CCTL0 |= OUTMOD2; // TX Space
if (RXTXData & 0x01)
CCTL0 &= ~ OUTMOD2; // TX Mark
RXTXData = RXTXData >> 1;
BitCnt --;
}
}
}
and the RX_Ready function is
void RX_Ready (void)
{
BitCnt = 0x8; // Load Bit counter
CCTL0 = SCS + CCIS1 + OUTMOD0 + CM1 + CAP + CCIE; // Sync, Neg Edge, Capture
} //End of Function RX_Ready
Plz let me know what is the problem in it....
thanks in advance