sherazi
Banned
- Joined
- Feb 15, 2010
- Messages
- 388
- Helped
- 61
- Reputation
- 126
- Reaction score
- 61
- Trophy points
- 1,318
- Location
- Muscat, Oman, Oman
- Activity points
- 0
#include <avr/io.h>
#include <avr/interrupt.h>
Void USART_Transmit(unsigned char data)
{
PORTC &=~0x20;//pc5 is used for enable of ma
while (!(UCSRA & (1<<UDRE))) sleep();
UDR = data;
}
unsigned char USART_Receive(void)
{
PORTC |=0x20;//PC5 is used for enable of max
while (!(UCSRA & (1<<RXC))) sleep();
return UDR;
}
void USART_Init(void)
{
// USART settings: 4800 baud 8-n-1
UBRRH = 0;
UBRRL = 207;
UCSRB = (1<<RXEN) | (1<<TXEN);
UCSRC = (1<<URSEL) | (1<<UCSZ1) | (1<<UCSZ0);
}
main()
{
USART_Init();
USART_TransmitString("OK!\r\n");
for (;;)
{
USART_Transmit(USART_Receive());
}
}
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?