Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

attiny2313 serial communication

Status
Not open for further replies.

eray81

Junior Member level 3
Joined
Jan 1, 2012
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,461
Hi,
I want to send data with attiny2313 to atmega32 mc. I use code below, but it doesnt work. when attiny2313 sends data to atmega32 , i cant see the right data on LCD connected to atmega32. what may the problem be?

Code:
#include <avr/io.h>  

  #include <avr/interrupt.h>  

  #include <util/delay.h>  
#define F_CPU 4000000
  //#define BAUDRATE 9600
//#define BAUD_CALC ((F_CPU/(BAUDRATE*16))-1) 
#define BAUD_CALC 25
 int main (void)  

 {  

   unsigned char data=0;  

                UBRRH = (unsigned char)(BAUD_CALC>>8);//Set baud rate
                UBRRL = (unsigned char)BAUD_CALC;//Set baud rate
                UCSRB = _BV(TXEN) | _BV(RXEN) | _BV(RXCIE);
                UCSRC = (0<<USBS)|(1<<UCSZ0)|(1<<UCSZ1)|(0<<UCSZ2)|(0<<UMSEL);//Set frame format

   for (;;){
	  USARTWriteChar(0x01);
	  _delay_ms(1000);
	    USARTWriteChar(0x02);
	  _delay_ms(1000);
	   USARTWriteChar(0x03);
	  _delay_ms(1000);
   }  

   

 }  
 
 void USARTWriteChar(char data)
{
   //Wait until the transmitter is ready
   while(!(UCSRA & (1<<UDRE)))
   {
      //Do nothing
   }
   //Now write the data to USART buffer
   UDR=data;
}
 

Try
Code:
USARTWriteChar(0x31)
instead of
Code:
USARTWriteChar(0x01)
.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top