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 check the uart transmission in proteus?

Status
Not open for further replies.
When ever a character is received the ISR will be executed...
If not it'll stay in while(1); or any other codes you need to run in...


thank u for your reply mathes...still i having doubt like.....i didnt write any isr and receiver coding..but i receive the character...how it is possible?can u explain it deeply?
 

Instead of ISR you can use pooling methode of Rx. You have to keep on checking the status register for the data available. If the data is available you can read it from data reg...
To avoid the waiting only we are going for the ISR...
 

i can receive the data"hello" in vt using proteus..but when i entered something in keyboard..it again displayed the data hello.....may i causing the interrupt by pressing something in the keyboard?that code is posted below...






PHP:
#include<htc.h>
#include<pic.h>
 
__CONFIG(FOSC_HS & WDTE_OFF & BOREN_OFF & LVP_OFF & DEBUG_OFF);
 
#define _XTAL_FREQ 20000000
 
void UART_Write(unsigned char uartData);
void UART_Write_Text(unsigned char *uartData);
 
void UART_Write(unsigned char uartData){
  while(!TXIF)
  continue;
    TXREG = uartData;
   
}
 
void UART_Write_Text(unsigned char *uartData){
 
    while(*uartData)
        UART_Write(*uartData++);
}
 
int main(void){
 
   // unsigned char x;
    //unsigned int rate=9600;
 
    TRISC6=1;
    TRISC7=1;
 
    //x = ((_XTAL_FREQ - (16 * rate)) / (16 * rate)); 
    
       
    BRGH = 1;
    SPBRG = 129;
    SYNC = 0;
    SPEN = 1;
    TXEN = 1;
    CREN = 1;
    //GIE = 1;
   // PEIE = 1;
    //TXIE = 1;
    //RCIE = 1;
 
  // INTCON = 0xC0;
 
    while(1){
 
        UART_Write_Text("Hello");
        __delay_ms(1000);
        //Add delay of 500 ms here
        while(!RCIF)
           continue;
           return RCREG;
 
    }
    
}

- - - Updated - - -

Instead of ISR you can use polling method of Rx. You have to keep on checking the status register for the data available. If the data is available you can read it from data reg...
To avoid the waiting only we are going for the ISR...


thank u mathes..i can understand.... need to call that interrupt fun in program or not?
 


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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include<htc.h> 
  
__CONFIG(FOSC_HS & WDTE_OFF & BOREN_OFF & LVP_OFF & DEBUG_OFF); 
  
#define _XTAL_FREQ 20000000 
  
void UART_Write(unsigned char uartData); 
void UART_Write_Text(unsigned char *uartData); 
 
void interrupt ISR(void)
{
    if(RCIF)  // If UART Rx Interrupt
    {
        if(OERR) // If over run error, then reset the receiver
        {
            CREN = 0;
            CREN = 1;
        }
 
        UART_Write(RCREG);  // Echo back received char
    }
}
  
void UART_Write(unsigned char uartData){ 
  while(!TXIF); 
      TXREG = uartData; 
    
} 
  
void UART_Write_Text(unsigned char *uartData){ 
  
    while(*uartData) 
        UART_Write(*uartData++); 
} 
  
int main(void){ 
  
    TRISC6=1; 
    TRISC7=1; 
          
    BRGH = 1; 
    SPBRG = 129; 
    SYNC = 0; 
    SPEN = 1; 
    TXEN = 1; 
    CREN = 1;
    TXIE  = 0;                      
    RCIE  = 1; 
     
    UART_Write_Text("Hello");
  
    while(1){ 
  
         ;          
         
    } 
     
}

 

hi jayanth...why we send the data again to the tx?

- - - Updated - - -

is that enough to transfer any data to any devices?
 

hi jayanth...why we send the data again to the tx?

- - - Updated - - -

is that enough to transfer any data to any devices?

Initially you are sending "hello" from uC to HT... By ISR you are receiving data from HT and if you need to display it on HT you need to send it again to HT...
That's why the Rx data is Txed again...
 

hi mathes....i can receive the data"hello" in vt using proteus..but when i entered something in keyboard..it again displayed the data hello.....may i causing the interrupt by pressing something in the keyboard?that code is posted below...
 
Last edited:

If you use my code then that doesn't happen. In you code uart prints "Hello" repeatedly because it is inside the while(1) loop. Why don't you study the code and understand how it functions. In my code there is ISR to receive UART data. If you send Hello then it is sent one character at a time to VT. The text that appears in VT also is read by ISR because I think you have enabled echo back in VT. Right click and uncheck Echo... in VT.
 

it is not printing repeatedly jayanth......when i pressed a key in keyboard it again displayed in vt...
 

put your Proteus image and jayanth code is working well .

and your code is also working if u put the code
Code:
UART_Write_Text("Hello");
out of the while (1) loop as jayanth mentioned.
 

put your Proteus image and jayanth code is working well .

and your code is also working if u put the code
Code:
UART_Write_Text("Hello");
out of the while (1) loop as jayanth mentioned.




yeah..its executing......i knew that....in my coding when u enter a key in keyboard again the data will displayed.....how it is possible?m asking that itself......just check that..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top