Briez
Member level 5
- Joined
- Nov 30, 2012
- Messages
- 83
- Helped
- 4
- Reputation
- 8
- Reaction score
- 4
- Trophy points
- 1,288
- Activity points
- 1,835
#define F_CPU 4000000UL
#include<avr/io.h>
#include<avr/interrupt.h>
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE ((( F_CPU / ( USART_BAUDRATE * 16UL))) - 1)
int main(void)
{
UCSRB |= (1 << RXEN ) | (1 << TXEN ); // Turn on the transmission and reception circuitry
UCSRC |= (1 << URSEL ) | (1 << UCSZ0 ) | (1 << UCSZ1 ); // Use 8- bit character sizes
UBRRH = ( BAUD_PRESCALE >> 8); // Load upper 8- bits of the baud rate value into the high byte of the UBRR register
UBRRL = BAUD_PRESCALE ; // Load lower 8- bits of the baud rate value into the low byte of the UBRR register
UCSRB |= (1 << RXCIE ); // Enable the USART Recieve Complete interrupt ( USART_RXC )
sei (); // Enable the Global Interrupt Enable flag so that interrupts can be processed
for (;;) // Loop forever
{
// Do nothing - echoing is handled by the ISR instead of in the main loop
}
}
ISR (USART_RXC_vect)
{
char ReceivedByte ;
ReceivedByte = UDR ; // Fetch the received byte value into the variable " ByteReceived "
UDR = ReceivedByte ; // Echo back the received byte back to the computer
}
Cross check your fuse settings
If u send "A" from uc then what is observation on Hyperterminal. How u confirm ur Frequency of controller. Use Timer & genrate some Time ISR from this we can confirm ur Frequency is Okay
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?