RXC0 bit does not fall down to 0 after reading UDR0 register

Go To Last Post
37 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

 

I'm working with a Atmega2561.

I want to receive a character from rx uart and transmit it to tx. like here (lesson 5): http://brittonkerin.com/cduino/lessons.html

My code:

unsigned char message;

void USART_init( void ) {
	int baudrate=12; // 4800 Bauds by default
	/* Set baud rate */
	UBRR0L = (unsigned char)baudrate;
	UBRR0H = (unsigned char)(baudrate>>8);
	
	/* Enable Receiver and Transmitter */
	UCSR0B = (1<<RXEN0)|(1<<TXEN0);
	
	/* Set frame format: 8data, 1stop bit */
	UCSR0C = (1<<UCSZ01)|(1<<UCSZ00);
}


void USART_Flush( void ) {
	unsigned char dummy;
	while ( UCSR0A & (1<<RXC0) ) dummy = UDR0;
}

unsigned char USART_rx( void ) {
	while( ! (UCSR0A & (1<<RXC0)) );
	return UDR0;
}

void USART_tx( unsigned char data ) {
	while( ! (UCSR0A & (1<<UDRE0)) );
	UDR0 = data;
}

void USART_putstring( const char *StringPtr ) {
	int cmp = 0;
	while ( strlen( StringPtr ) != cmp ) {
		USART_tx( StringPtr[cmp] );
		cmp++;
	}
}

/* Other */
void delay( uint32_t twait ) {
	while( twait-- )
	asm volatile( "nop" );
}

int main(void)
{				
	USART_init(); // Call the USART initialization code
		
    while(1)
    {
		message = USART_rx();
		delay(50000L);
		USART_tx(message);
    }
}

My problem is when i read the UDR0 register, the RXC0 bit does not fall down.

I found a dirty workaround (disable and re-enable the rx): 

UCSR0B = (0<<RXEN0)|(1<<TXEN0);
UCSR0B = (1<<RXEN0)|(1<<TXEN0);

I there something i do wrong?

 

Regards

 

This topic has a solution.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My problem is when i read the UDR0 register, the RXC0 bit does not fall down.

How/Where are you observing that?

 

Real chip with debugger?

Simulator in Atmel Studio?

Some other simulator?

Something else?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Real chip with debugger

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would suspect a fault in the debugger then. Try some kind of test that is non-debugger dependent such as setting an output pin with the state of RXC0 and observing it on a scope or logic analyser for example.

 

I rather suspect that if RXC0 in 2561 really didn't work someone else might have spotted this in the past 6..8 years or however long it has been since 2561 was released.

 

PS while you have the scope out monitor RXD0 - is there some kind of "noise" on the line that might be interpreted as arriving data? (oh and check for framing errors - if you are getting noise causing spurious activity the chances of it actually being framed right are probably low so you may find that FE0 is set).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for your answer.

The debugger sees the RXC0 bit stuck at 1 and the code execution runs really like if RXC0 bit is stuck at 1.surprise

But you're right, i'm not alone to work on this chip.laugh

I am going to observe it on a scope.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My problem is when i read the UDR0 register, the RXC0 bit does not fall down.

I found a dirty workaround (disable and re-enable the rx): 

UCSR0B = (0<<RXEN0)|(1<<TXEN0);
UCSR0B = (1<<RXEN0)|(1<<TXEN0);

Maybe some byte remains in the USART  (USART has two level buffer).

 

Instead of the code above, try your function USART_Flush(). This should remove all chars from the uart and RXC should be cleared.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Good idea Visovian, but i have already tested it: it doesn't work. sad

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your code in the message#1 looks absolutely fine to me.    The mega2561 will work exactly the same as any other AVR.

 

My only concern is the "UBRR=12" value.    Since the mega2561 is a SMD chip,   I bet that you are using a ready-made dev board with a real crystal and the maker has set the fuses properly.

 

So the UBRR=12 value is very unlikely to give you 4800 baud.    (it is assuming that you are running at 1MHz)

e.g. if it has an 8MHz crystal,  you would be running at 38400 baud.

 

Please post a link to your dev board.   e.g. an Ebay sale

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes it runs at 1MHz, that's why UBRR=12.

My dev board is a custom one but the base came from https://www.crystalfontz.com/pro...

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Each demo board is preprogrammed with a microSD boot loader, which can load our "super simple" C example code, the miniBASIC interpreter, or your own application built with AVRStudio or WinAVR (both free) for this board's versatile ATMEGA2561. Use the JTAG port for more advanced programming and debugging. We have brought out all the ports to 0.1" centers. These demonstration boards are so powerful and convenient, they can be used as a base development platform for your project.

 

Well,  the schematic shows an 8MHz crystal.   The photo shows a crystal.

 

Seriously,   have you checked to see what speed your AVR is actually running at?

The title of this thread implies that you are getting more than one RXC0 for each byte.     This is what happens if your AVR is running at 38400 baud.   i.e. every zero bit looks like START bit.

 

Do you see the correct characters when you type in a 4800 baud Terminal?

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The schematic there shows:

 

I would be astonished if the manufacturer doesn't supply this board with CKSEL fuses set to enable this 8MHz crystal (and CKDIV8 cleared) so have you really reprogrammed the fuses to revert to 1MHz?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes i see the correct characters when my terminal is set at 4800 bauds.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

 

With the scope, i see that the RXC0 bit does not fall down.

The problem was the fuse settings.

Now my atmega runs at 8 Mhz and the RXC0 bit falls to 0 after reading UDR0 register.

 

Who said: "99.9% of UART errors are AVRs not being clocked right"?

 

Thanks

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

alst_flo wrote:

Hi all,

 

With the scope, i see that the RXC0 bit does not fall down.

The problem was the fuse settings.

Now my atmega runs at 8 Mhz and the RXC0 bit falls to 0 after reading UDR0 register.

 

Who said: "99.9% of UART errors are AVRs not being clocked right"?

 

Thanks

 

 

Hi alst_flo

 

i have similar problem .

my frequency of clock is int RC 8MHZ.

my transmission work good , my reciever by polling code no work .

RCX0 bit in UCSR0A is 1 !!!!!! 

by oscope on PB0 pin freq is 8mhz.

my code for recieving is :

 

char UART_recieve (void)
{
	while ( !(UCSR0A & (1<<RXC0)) );                 // wait while data is being received
	return UDR0;                                   // return 8-bit data
}

can you help me...

 

my device : atmega328 p

clock : int RC 8 mhz

VCC : 5V

compiler : AtmelStudio 7

 

fuse bits : 

BODLEVEL = DISABLED
RSTDISBL = [ ]
DWEN = [ ]
SPIEN = [X]
WDTON = [ ]
EESAVE = [X]
BOOTSZ = 2048W_3800
BOOTRST = [ ]
CKDIV8 = [ ]
CKOUT = [ ]
SUT_CKSEL = INTRCOSC_8MHZ_6CK_14CK_65MS

EXTENDED = 0xFF (valid)
HIGH = 0xD1 (valid)
LOW = 0xE2 (valid)
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What baud rate are you running at? 

For solid reliable serial comms, it is best to use an external xtal as the internal RC will drift with temperature and VCC voltage!

 

Jim

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

tanx for answer

my baudrate is 9600

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hosseinfathbag wrote:
my transmission work good , my reciever by polling code no work . RCX0 bit in UCSR0A is 1 !!!!!!

Isn't it supposed to be one?

 

Is your internal oscillator too far off from 8MHz to get good reception?

 

Post complete small test program, that shows your register setup.

 

How can you tell that

RCX0 bit in UCSR0A is 1 !!

Read UCSR0A and see if DOR or FE or UPE are set.

 

Tell configuration at both ends.  Mis-matched stop bit count, so framing errors?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:

hosseinfathbag wrote:
my transmission work good , my reciever by polling code no work . RCX0 bit in UCSR0A is 1 !!!!!!

Isn't it supposed to be one?

 

Is your internal oscillator too far off from 8MHz to get good reception?

 

Post complete small test program, that shows your register setup.

 

How can you tell that

RCX0 bit in UCSR0A is 1 !!

Read UCSR0A and see if DOR or FE or UPE are set.

 

Tell configuration at both ends.  Mis-matched stop bit count, so framing errors?

 

ooooooohhhhhhhh . yes in main is ok , but in external interrupt dont work .

 

ISR(INT1_vect){

    char character = 0;
	character = UART_recieve();

}

im sure that ext int0 work.

and i changed source clock to ext 12 mhz .

Last Edited: Fri. Oct 19, 2018 - 04:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why would you have a "blocking" USART rx function in an ISR? 

Your design is questionable at best......

 

Jim

 

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hosseinfathbag wrote:
im sure that ext int0 work.

What does that have to do with any of my questions?

hosseinfathbag wrote:
and i changed source clock to ext 12 mhz .

So, then, answer the questions:

theusch wrote:
Post complete small test program, that shows your register setup. How can you tell that RCX0 bit in UCSR0A is 1 !! Read UCSR0A and see if DOR or FE or UPE are set. Tell configuration at both ends. Mis-matched stop bit count, so framing errors?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:

hosseinfathbag wrote:
im sure that ext int0 work.

What does that have to do with any of my questions?

hosseinfathbag wrote:
and i changed source clock to ext 12 mhz .

So, then, answer the questions:

theusch wrote:
Post complete small test program, that shows your register setup. How can you tell that RCX0 bit in UCSR0A is 1 !! Read UCSR0A and see if DOR or FE or UPE are set. Tell configuration at both ends. Mis-matched stop bit count, so framing errors?

 

complete small code :

 


#define  F_CPU 12000000UL
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>


void UART_transmit_char (char data)
{
	while (!( UCSR0A & (1<<UDRE0)));                // wait while register is free
	UDR0 = data;                                   // load data in the register
}


char UART_recieve (void)
{
	while ( !(UCSR0A & (1<<RXC0)) );                 // wait while data is being received
	return UDR0;                                   // return 8-bit data
}
	
	
int main(void)
{
     
     DDRB |= (1<<DDB0); //SET OUT PUT
    
	//setting external interrupt 1 for BLT connection
	DDRD &= ~(1<<DDD3); //SET INPUT
	EICRA |= (1<<ISC10);  //Any logical change on INT1 generates an interrupt reques
	EIMSK |= (1<<INT1);  //Enable interrupt 1
	
	
    //setting uart 
    UBRR0H = (((F_CPU)/(9600*16UL)-1)>>8);                    // shift the register right by 8 bits for UBRRH
	UBRR0L = ((F_CPU)/(9600*16UL)-1);                        // set baud rate value for UBRRL      
            
	UCSR0B|= (1<<TXEN0)|(1<<RXEN0);                // enable receiver and transmitter
	UCSR0C|= (1<<UCSZ00)|(1<<UCSZ01);             // 8bit data format

    sei();
    while (1) 
    {

		
    }
}


ISR(INT1_vect){
	

    char character = 0;
	int menu = 0;
	
	
	character = UART_recieve(); // NOT WORK !!!!! RXC0 IS 1 !!!!!
	
	if( character == 'a') PORTB |= (1<<PORTB0);
}




 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The usual practice is to use a UART Receive interrupt to handle incoming characters. Your interrupt is firing on the start bit and your are testing the receive status before the character has finished.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:

The usual practice is to use a UART Receive interrupt to handle incoming characters. Your interrupt is firing on the start bit and your are testing the receive status before the character has finished.

 

Jim

OK, very tanx.

so, i want to use UART Receive interrupt , but in interrupt vector in atmega328 UART RX INT is lower than EXT INT1.

How can i use them ?

 

for example :

 


#define  F_CPU 12000000UL
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>

#define BAUD 9600

char usart_recieve_char(void){

	char c = 0;
	while( udr==NULL);
	c = udr;
	udr = NULL;
	return c;
}

int main(){

    //init uart
    UBRR0H = (((F_CPU)/(BAUD*16UL)-1)>>8);                    // shift the register right by 8 bits for UBRRH
	UBRR0L = ((F_CPU)/(BAUD*16UL)-1);                        // set baud rate value for UBRRL      

	UCSR0B|= (1<<TXEN0)|(1<<RXEN0)|(1<<RXCIE0);                // enable receiver and transmitter
	UCSR0C|= (1<<UCSZ00)|(1<<UCSZ01);             // 8bit data format

    //init external interrrupt 1
    EICRA |= (1<<ISC10);  //Any logical change on INT1 generates an interrupt reques
	EIMSK |= (1<<INT1);  //Enable interrupt 1
	sei();

volatile char	udr = NULL;
volatile char usart_data[30];

    while(1){}
}

ISR(USART_RX_vect){

	static int i;
	udr = UDR0;
	usart_data[i++] = udr;

	if ( udr == 0X0D)  //  "\r"
	{

		for( int i =0;i<30;i++) usart_data[i] = NULL;
		i = 0;
	}

}

ISR(INT1_vect){

    char x = usart_recieve_char();  // not work ISR(UART_RX_vect) in this ISR
    if(x== "a") PORTB |= (1<<PORTB3);

}

 

Last Edited: Sat. Oct 20, 2018 - 11:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hosseinfathbag wrote:
complete small code :

Complete?  No.  There is no source for

usart_recieve_char

 or

UART_recieve

Are you cuttiing and pasting the actual source code?  Or re-typing?

 

When using the AVR USART peripheral, no external interrupts are needed.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:

hosseinfathbag wrote:
complete small code :

Complete?  No.  There is no source for

usart_recieve_char

 or

UART_recieve

Are you cuttiing and pasting the actual source code?  Or re-typing?

 

When using the AVR USART peripheral, no external interrupts are needed.

 

are there?!

 

void UART_transmit_char (char data)
{
	while (!( UCSR0A & (1<<UDRE0)));                // wait while register is free
	UDR0 = data;                                   // load data in the register
}


char UART_recieve (void)
{
	while ( !(UCSR0A & (1<<RXC0)) );                 // wait while data is being received
	return UDR0;                                   // return 8-bit data
}

theusch wrote:
When using the AVR USART peripheral, no external interrupts are needed.

yes ,i know . in this project i connected bluetooth module INT to EXT INT1 in avr and i would like get data from bluetooth by UART RX interrupt in EXT INT1.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

im confused !!!!

when i use UART_recieve() in while(1) work correctly but in if() Not work !!!!!!

 

 


char UART_recieve (void)
{
	while ( !(UCSR0A & (1<<RXC0)) );                 // wait while data is being received
	return UDR0;                                   // return 8-bit data
}

int main(){

    bool connected = true;
    while(1){

        if (connected)
		{
			connected = false;
			UART_transmit_string("\r\nHi\r\nGarden Controller V1.00\r\n**************************\r\n");
			char c = UART_recieve();  // not work
			int menu = c - '0';

		}
    }

}

 

this work correctly :

 

char UART_recieve (void)
{
	while ( !(UCSR0A & (1<<RXC0)) );                 // wait while data is being received
	return UDR0;                                   // return 8-bit data
}

int main(){

    bool connected = true;
    while(1){

			connected = false;
			UART_transmit_string("\r\nHi\r\nGarden Controller V1.00\r\n**************************\r\n");
			char c = UART_recieve();  //ok
			int menu = c - '0';

    }

}

notice: i use ISR(INT!_vect){} that i  see this problem . without ISR(INT!_vect){} both above code are ok

Last Edited: Sat. Oct 20, 2018 - 04:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your UART_receive() is blocking. Once you call it, the program will sit there in a  loop, waiting for the  character to arrive. During that time, nothing else can happen except interrupts.

 

Your earlier statement:

so, i want to use UART Receive interrupt , but in interrupt vector in atmega328 UART RX INT is lower than EXT INT1.

indicates that you are missing an important fact about AVR interrupts. The  order of the interrupt table is ONLY important if two should hit at EXACTLY the same instant. When that happens, the service routine that is higher on the list gets executed first. When that is finished, the next one is executed. Generally, UART receive interrupts do not need to be serviced instantaneously. You have until the  completion of the next character to get the first character read. If you  wait longer than this, you will loose the first character and the Data OverRun bit in UCSR0A (M328 family) is set. This is rarely a problem unless the baud rate is really high or unless you have another ISR that takes way too long to  execute.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:

Your UART_receive() is blocking. Once you call it, the program will sit there in a  loop, waiting for the  character to arrive. During that time, nothing else can happen except interrupts.

 

Your earlier statement:

so, i want to use UART Receive interrupt , but in interrupt vector in atmega328 UART RX INT is lower than EXT INT1.

indicates that you are missing an important fact about AVR interrupts. The  order of the interrupt table is ONLY important if two should hit at EXACTLY the same instant. When that happens, the service routine that is higher on the list gets executed first. When that is finished, the next one is executed. Generally, UART receive interrupts do not need to be serviced instantaneously. You have until the  completion of the next character to get the first character read. If you  wait longer than this, you will loose the first character and the Data OverRun bit in UCSR0A (M328 family) is set. This is rarely a problem unless the baud rate is really high or unless you have another ISR that takes way too long to  execute.

 

Jim

 

very thanks for complete answer .

i used another device (M328 on arduino by 16mhz) and its worked !

that fusebits > 

LOW:0XFF

HIGH: 0XDE

EXTENDED: 0XFD

 

and for me : (M328 12MHZ)

LOW:0XE6

HIGH: 0XD9

EXTENDED: 0XFF

 

I thing fusebit for me in wrong .

can you say that fiusebit for 12MHZ what to be ?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fuse no different at 12MHz compared 8MHz or 16MHz.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:

Fuse no different at 12MHz compared 8MHz or 16MHz.

 

Jim

 

OK , YOUR ARE RIGHT .

so , my micro has been destroied

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am not sure how you reach that conclusion.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

very very thanks from every body. my problem solved !

my bluetooth module for first connection send some character to avr so, A Data OverRun occurs when the receive buffer is full.

 

i read 10 times UDR0.

 

ISR(INT1_vect){
	
	set_buzzer;
	_delay_ms(200);
	clear_buzzer;
	for(int i=0;i<10;i++) {static char trash = 0;trash = UDR0;}//Clean buffer of usart for extera character from first connection of bluetooth module
	connected = true;
	
}

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

There is no reason to make trash = 0. You are just putting UDR0 character into the variable trash, over and over. There is no buffer, in the usual sense. The usual way would be to use an array as the buffer. If you insist on calling it trash, I would

 

for(int i=0;i<10;i++) 
    {
    trash[i] = UDR0;
    }

But even that is bad, because you are doing this over and over for each character. Not Good!

 

I recommend that you search out something like: buffered UART read

 

This is a very standard problem and there are examples all over the net.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jim, I think he's referring to the USART hardware's two-frame receive buffer.  He's dumping it because his BT adapter sends multiple characters upon connecting.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

But, he will get a separate interrupt on every character, no? And, I do NOT understand the insistence for using INT1 interrupt rather than a proper Rx Complete interrupt. The only thing that I can imagine is that the 200ms delay inside the ISR (really bad form) is long enough so that all of the characters will be received. But, the process in the code will ONLY identify the last one which is the last character to be copied into "trash".

 

I would do it something like this:

 

...
volatile uint8_t i;
volatile char * Buffer[10];
volatile uin8_t RxFlag;

ISR(USART_RX_vect)
    {
    char temp = UDR0;
    buffer[i] = temp;
    if (temp == '\r')  //carriage return at end of string?
        {
        i = 0;      //resetfor next message
        RxFlag = 1; //signal that a full message has arrived
        }
    else            //no carriage return yet
        {
        i ++;       //index for next character
        RxFlag = 0  //make sure the full message signal is clear
        }
    }

 Note that there is no protection against over-run of buffer[] or a few other nice details.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Sat. Oct 20, 2018 - 11:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:

But, he will get a separate interrupt on every character, no? And, I do NOT understand the insistence for using INT1 interrupt rather than a proper Rx Complete interrupt. The only thing that I can imagine is that the 200ms delay inside the ISR (really bad form) is long enough so that all of the characters will be received. But, the process in the code will ONLY identify the last one which is the last character to be copied into "trash".

 

Jim

 

1NT1 ISR isnt for receive character ,its for understanding connection of bluetooth module . when im connecting to bluetooth the ints pin of it drop to 3.3 volt and i connected it to AVR INT1. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Your algorithm of waiting inside the connect interrupt is really bad. Look at the example I added to see how it is usually done.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net