dual USART issue with ATMEGA128

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

Hi Guys,

Im working on am irrigation controller project. Using the ATmega128. USART0 is connected to a bluethhoth module and working fine. USART1 is connected to a GSM modem which is breathing but not working properly.

To debug i want to send the commands from bluethhoth interface to the GSM interface, but things are getting messy. chracters keep repeating foreever.

Would appriciate if someone would tell what im doing wrong.

i modifed USART.c ISR routins as follows:

ISR(SIG_USART0_RECV) {  
	unsigned char c;
	
	c = UDR0;					// Get received char
	if (EXC==0xff) //only if global variable is 0xff, exchange data across USARTS
	{
	UART1_putc(c);
	}
	else
	{
	rbuf[r_in & RMASK] = c;		// put in buffer (no check for overflow)
	r_in++;
	}
		// RMASK makes it unnecessary to range limit this
}

ISR(SIG_USART1_RECV) {  
	unsigned char c;
	c = UDR1;					// Get received char
	if (EXC==0xff)  //only if global variable is 0xff, exchange data across USARTS
	{
	UART_putc(c);
	}
	else
	{
	rbuf1[r1_in & RMASK] = c;		// put in buffer (no check for overflow)
	r1_in++;		// RMASK makes it unnecessary to range limit this
	}
}


Thanks Rodney Jr.

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

Don't call blocking (or any) functions from an ISR. The RECV interrupt should always write to the buffer. Make the choice as to whether to forward the character should be passed on or not later at the point where characters are being extracted from the buffer and used.

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

Ok,

I have reset the ISR the way they originally were.

someway in main i used this code.

while(2)
				{
				x=UART_rbuflen();
				for (i=1;i<=x;i++)
					{
					UART1_putc(UART_getc);
					}
				x=UART1_rbuflen();
				for (i=1;i<=x;i++)
					{
					UART_putc(UART1_getc);
					}
					
				}

still does not work.

Any Ideas?

Thanks

Rodney

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

Quote:
UART_putc(UART1_getc);
This makes no sense. Surely UART1_getc is a function, not a variable.

Regards,
Steve A.

The Board helps those that help themselves.