paone
Newbie level 5
- Joined
- Jan 17, 2014
- Messages
- 10
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 85
I have been trying to read data serially from labVIEW to atmega32 MCU(16Mhz) with baud rate 9600.
For this, Iam using USB to Serial converter(TTL). But MCU could not read any values from the labview.
While execution in VMlab software, the control is not entering into "ISR (USART_RXC_vect)" subroutine loop even though, when data is entered into UDR register. Where is the fault?? Is it in code...
In hardware also i could not find any change in PORTB in ISR loop. Where is the fault?? Is it in Serial converter(ttl) connections
I request anyone to provide me a correct code for serial data receive. Thanx in advance,
- - - Updated - - -
#include <avr\io.h> // Most basic include files
#include <avr\interrupt.h> // Add the necessary ones
#include <avr\signal.h> // here
void usart_init()
{
UCSRC |= (0 << URSEL);
UBRRL= 0x67;
UBRRH=0x00;
UCSRC |= (1 << URSEL)| (0<<UMSEL)| (0<<USBS) | (1 << UCSZ0) | (1 << UCSZ1);
UCSRB |= (1<<RXCIE)| (1 << RXEN);
ISR (USART_RXC_vect)
{
unsigned char value;
if(value == 1)
{
PORTB=0x01;
}
if(value ==2)
{PORTB=0x02;
}
if(value==3)
{PORTB=0x04;
}
if(value ==4)
{PORTB=0x08;
}
else {
PORTB = 0x00;
}
}
void main()
{
DDRB=0xFF;
PORTB=0x00;
usart_init();
sei();
}
- - - Updated - - -
My labview panel...
For this, Iam using USB to Serial converter(TTL). But MCU could not read any values from the labview.
While execution in VMlab software, the control is not entering into "ISR (USART_RXC_vect)" subroutine loop even though, when data is entered into UDR register. Where is the fault?? Is it in code...
In hardware also i could not find any change in PORTB in ISR loop. Where is the fault?? Is it in Serial converter(ttl) connections
I request anyone to provide me a correct code for serial data receive. Thanx in advance,
- - - Updated - - -
#include <avr\io.h> // Most basic include files
#include <avr\interrupt.h> // Add the necessary ones
#include <avr\signal.h> // here
void usart_init()
{
UCSRC |= (0 << URSEL);
UBRRL= 0x67;
UBRRH=0x00;
UCSRC |= (1 << URSEL)| (0<<UMSEL)| (0<<USBS) | (1 << UCSZ0) | (1 << UCSZ1);
UCSRB |= (1<<RXCIE)| (1 << RXEN);
ISR (USART_RXC_vect)
{
unsigned char value;
if(value == 1)
{
PORTB=0x01;
}
if(value ==2)
{PORTB=0x02;
}
if(value==3)
{PORTB=0x04;
}
if(value ==4)
{PORTB=0x08;
}
else {
PORTB = 0x00;
}
}
void main()
{
DDRB=0xFF;
PORTB=0x00;
usart_init();
sei();
}
- - - Updated - - -
My labview panel...