This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Setting S0RIR

Hi,

After receiving a command on the serial port I want to disable all interrupts and then wait for the serial port to receive a byte. The following code shows what I am doing.

IEN = 0 ;
_nop_() ;
_nop_() ;

while( !S0RIR ) ;
rxbyte = ( uint8_t ) S0TBUF ;
S0RIR = 0 ;

It appears that I never pass the while loop. Does disabling the serial rx interrupt stop S0RIR being set ? Any ideas ?

I am using a ST10F168.

Cheers

Elliot

Parents
  • Hi Again

    This code works at 9600 baud but seems to have problems at higher rates and is contrary to the manual.

    uint8_t GetByte( void )
    {
    	uint8_t rx_char ;
    
    	while( !S0EIR && !S0RIR ) ;
    
    	rx_char = ( uint8_t ) S0RBUF ;
            S0RIR = 0 ;
    	S0EIR = 0 ;
    
    	return rx_char ;
    }
    

    but this code cause a reset

    uint8_t GetByte( void )
    {
    	uint8_t rx_char ;
    
    	while( !S0RIR ) ;
    
    	rx_char = ( uint8_t ) S0RBUF ;
            S0RIR = 0 ;
    
    	return rx_char ;
    }
    

    I am not using a watchdog and have no interrupts. Has anyone any theories on what might be happening ? This is driving me mad.

    Cheers

    Elliot

Reply
  • Hi Again

    This code works at 9600 baud but seems to have problems at higher rates and is contrary to the manual.

    uint8_t GetByte( void )
    {
    	uint8_t rx_char ;
    
    	while( !S0EIR && !S0RIR ) ;
    
    	rx_char = ( uint8_t ) S0RBUF ;
            S0RIR = 0 ;
    	S0EIR = 0 ;
    
    	return rx_char ;
    }
    

    but this code cause a reset

    uint8_t GetByte( void )
    {
    	uint8_t rx_char ;
    
    	while( !S0RIR ) ;
    
    	rx_char = ( uint8_t ) S0RBUF ;
            S0RIR = 0 ;
    
    	return rx_char ;
    }
    

    I am not using a watchdog and have no interrupts. Has anyone any theories on what might be happening ? This is driving me mad.

    Cheers

    Elliot

Children