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] UART sending and receiving help

Status
Not open for further replies.

john blue

Advanced Member level 3
Joined
Jun 7, 2007
Messages
821
Helped
213
Reputation
430
Reaction score
204
Trophy points
1,323
Activity points
4,749
My UART keeps sending data out after a character is received. May I know how to do so that, when i send once, it will receive once without ussing interrupt if possible?
 

can you be more clear.. what you say is possible but the requirement is not clear.....

explain clearly what you want.........

---------- Post added at 22:50 ---------- Previous post was at 22:46 ----------

which controller, IDE compiler , programming language to be used...
 

Pic18f4550, mplab, c18

---------- Post added at 18:24 ---------- Previous post was at 18:21 ----------

Here is my code, i manage to receive and sent data at baoud rate 1200 but my next problem is that once it get new data it will continue printing it on hyperterminal, then it will continue with the new character. I need a program that print once when i sent one character without using interrupt. Is it possible?


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <p18f4550.h>
  #include <usart.h>
  #include <delays.h>
  #include <uart.h>
 
 
 
 
  void main()
  {
       char data;
       char mybuff [] = "Hello";
       char *ptr;
       char buff[100];
       
                 
           //  ptr = RCREG; // point the pointer to buffer[0] 
       
       
       OpenUSART(USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE &
                 USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_LOW, 255);
 
       while(1)
       {
            data = getcUSART();
           
               putcUSART( data ); 
             
           
            
             
       }
 CloseUSART();
  }

 

getcUSART returns the character that's in the receive buffer without regard to whether it is a new character or not. You need to change your code to check if a NEW character is in the receive buffer. Something like this:
Code:
while(1)
{
    if (DataRdyUSART())
    {
         data = getcUSART();
         putcUSART( data ); 
    }                
}
 

getcUSART returns the character that's in the receive buffer without regard to whether it is a new character or not. You need to change your code to check if a NEW character is in the receive buffer. Something like this:
Code:
while(1)
{
    if (DataRdyUSART())
    {
         data = getcUSART();
         putcUSART( data ); 
    }                
}

ok. Thanks a lot. will try and get back to you :)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top