EmbeddedRelated.com
Forums

RXBUF UART

Started by hragsarkissian April 6, 2009
Hi,
Is there anyway i can clear the RXBUF for the uart. I have implemented a timeout. So what happens, if nothing is received from the UART, the timer will time out the uart interrupt. but RXBUF will still have the previous value. Therefore i was wondering if it is possible to clear it everytime before going into the interrupt.

Thanks,
Hrag

Beginning Microcontrollers with the MSP430

Hi Hrag,
> Is there anyway i can clear the RXBUF for the uart.
What would that accomplish? Even if RXBUF could be 'cleared' to 0x00, that is still a value. The flag RXIFG clears automatically when RXBUF has been read, so there is your 'RXBUF clear' indicator.
RXBUF is read only by the way, and you can always use a global variable in RAM to store whatever you need.

Michael K.
--- In m..., "hragsarkissian" wrote:
>
> Hi,
> Is there anyway i can clear the RXBUF for the uart. I have implemented a timeout. So what happens, if nothing is received from the UART, the timer will time out the uart interrupt. but RXBUF will still have the previous value. Therefore i was wondering if it is possible to clear it everytime before going into the interrupt.
>
> Thanks,
> Hrag
>

Here is my implementation:

int receiveRF()
{

//enable TimerA interrupt
TACCTL0 |= (CCIE);
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3, interrupts enabled
TACCTL0 &= ~(CCIE); //disable TimerA interrupt

return UCA0RXBUF;

}

#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR()
{

_BIC_SR_IRQ(LPM3_bits + GIE); // Clear LPM3 bits from 0(SR)
}

#pragma vector=TIMER0_A0_VECTOR
__interrupt void TIMERA0_ISR(void)
{
for(int j = 0; j < 22; j++)
{
pause(); //this just creates a pause
}
TACCR0 += 50000;
_BIC_SR_IRQ(LPM3_bits + GIE);
}

the receiveRF function will basically return the received RXBUF. I have implemented the timeout so that if in my case nothing is received (due to a loss of communication) i would like my function to return 0. That is why i was trying to clear the RXBUF so that it could return 0 after the timout. Is there any other way i could achieve the same?

Thanks,
Hrag
--- In m..., "tintronic" wrote:
>
> Hi Hrag,
> > Is there anyway i can clear the RXBUF for the uart.
> What would that accomplish? Even if RXBUF could be 'cleared' to 0x00, that is still a value. The flag RXIFG clears automatically when RXBUF has been read, so there is your 'RXBUF clear' indicator.
> RXBUF is read only by the way, and you can always use a global variable in RAM to store whatever you need.
>
> Michael K.
> --- In m..., "hragsarkissian" wrote:
> >
> > Hi,
> > Is there anyway i can clear the RXBUF for the uart. I have implemented a timeout. So what happens, if nothing is received from the UART, the timer will time out the uart interrupt. but RXBUF will still have the previous value. Therefore i was wondering if it is possible to clear it everytime before going into the interrupt.
> >
> > Thanks,
> > Hrag
>