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.

[SOLVED] how to send 'a' char on atmega uart just once or some input occur

Status
Not open for further replies.

ud23

Advanced Member level 3
Advanced Member level 3
Joined
Apr 20, 2011
Messages
926
Helped
185
Reputation
370
Reaction score
180
Trophy points
1,323
Visit site
Activity points
6,138
hi all i want to do some simple program want send char 'a' only one time not continuous on UART of atmega 8535
Code:
void USARTWriteChar(char data)
{
   //Wait untill the transmitter is ready
   
   
   while(!(UCSRA & (1<<UDRE)));
   //{
      //Do nothing
   //}

   //Now write the data to USART buffer
   UDR = data;	 
  
}

i am using this function for sending data but it sending continuous 'a' on hyper when some switch press
i want to send just one time when switch press.Is there any flag bit to stop continuous transmit.
 

Check these links
http://extremeelectronics.co.in/av...r-microcontrollers-reading-and-writing-data/
http://www.engineersgarage.com/emb...projects/serial-communication-atmega16-usart
http://deans-avr-tutorials.googlecode.com/svn/trunk/InterruptUSART/Output/InterruptUSART.pdf

Code:
//Global Variables
unsigned int doonce = 0;


void USARTWriteChar(char data)
{
   if(doonce == 0) {
   	//Wait untill the transmitter is ready
   
   
   	while(!(UCSRA & (1<<UDRE)));
   	//{
      		//Do nothing
   	//}

   	//Now write the data to USART buffer
   	UDR = data;
	doonce = 1;
   }	 
  
}

I think your USARTWriteChar() is called infinitely in the while(1) loop. So, if you send any character to the function it gets printed infinitely.
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top