AnsweredAssumed Answered

USART_SendData adding bits

Question asked by halford.dave on Jul 17, 2013
Latest reply on Mar 16, 2015 by das.sanjib
Hey I'm running the STM32L1 chip with an XBEE unit and everything works perfectly except my Tx adds bits when there is an even number in the unsigned char (I typedef this as BYTE) being sent. Shows in Putty and X-CTU.

My code is:

void init_pkg( DWORD val, __IO BYTE* buff )
{
     for ( int x = 0, len = TX_BUFF_SIZE - 1; x < len; x++ )
         {
             *buff++ = val + x;
         
    
         *buff++ = MSG_END_CHAR;

}

void xbee_IRQHandler( void )
{
     // -- Send buffer EMPTY interrupt -- //    
         if ( (USART_GetITStatus( XBEE_USART, USART_IT_TXE )) != RESET )
         {
                delay( XBEE_SEND_TMOUT );  
             USART_SendData( XBEE_USART, (TxBuffer[ TxCounter ] & 0x7F) );
        
             if ( (++TxCounter) == TxBufferSize )                            
             {
                     USART_ITConfig( XBEE_USART, USART_IT_TXE, DISABLE );        
             }
        
    }
}

Is there something i'm missing? I've checked the whole ASCII table and always adds a MSB when there's an even number of bits set.

Any help would be great as I'm lost.
Cheers

Outcomes