USART_TX Interruption not entering (USART0_RXC)


hello guys, i'm having problems usart read 1 , more caracters register.


my usart init function:

code: [select]

void usart_interrupt_init(void)  // function correct

    //cli();
    ubrr0h = (baud_prescaler >> 8);
    ubrr0l =  baud_prescaler;                           
    ucsr0a &= ~(1 << u2x0); 
    ucsr0b = ((1<<rxen0)|(1<<txen0)|(1 << rxcie0));       
    ucsr0c = ((0<<usbs0)|(1 << ucsz01)|(1<<ucsz00)); 
    sei(); 
}


this code read single caracter. when try read caracter in main function sending serial monitor, read when type caracter twice.

code: [select]

char receive_data(void) {

  while ( !( ucsr0a & (1 << rxc0)) ) {

  }
  return udr0;
}


this usart interruption, seens code never enter it.

code: [select]

#define rx_buffer_size  128
volatile char rxbuffer[rx_buffer_size];
volatile uint8_t rxreadpos = 0;
volatile uint8_t rxwritepos = 0;

// code continues here       

isr(usart0_rxc)
{   
    rxbuffer[rxwritepos] = udr0;
     
    rxwritepos++;
     
    if(rxwritepos >= rx_buffer_size)
    {
        rxwritepos = 0;
    }
}

// end of code


when try print rxbuffer on main, nothing happens, if never entered in interruption.

obs: function working, need programm register , can't use it.
code: [select]

if(serial.available() > 0)
{
    teste = serial.read();
    printf("%c ",teste);
}

quote
this function working, need programm register , can't use it.
please describe why need re-invent wheel.

you should either use rxc interrupt vector or check rxc0 bit not both. might interpret code incorrectly that's fault, posted excerpts instead of complete code. post complete sketch if need more information.


Arduino Forum > Using Arduino > Programming Questions > USART_TX Interruption not entering (USART0_RXC)


arduino

Comments

Popular posts from this blog

Error compiling for board Arduino/Genuino Uno.

Installation database is corrupt

esp8266 (nodemcu 0.9) client.write très lent ???