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.

pic18f452 serial comm problem

Status
Not open for further replies.

amit deulkar

Junior Member level 1
Joined
May 25, 2012
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,537
i am trying to send data to hyper terminal using following code but not working please help


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 <stdio.h>
#include <stdlib.h>
#include<p18f452.h>
#pragma config OSC=HS, OSCS=OFF
#pragma config PWRT=OFF, BOR=ON, BORV=45
#pragma config WDT =OFF
#pragma config DEBUG=OFF,LVP=OFF,STVR=OFF
void uart_init(void);
 
/*
 * 
 */
void main(void)
{
    uart_init();
    while(1)
    {
        TXREG=0x06;
        while(PIR1bits.TXIF==0);
    }
 
 
}
 
void uart_init(void)
{
    TRISCbits.TRISC6=0;     // tx pin as o/p
    TRISCbits.TRISC7=1;     // rx pin as i/p
    SPBRG=18;                //  (172800/9600)  FOR 9600 BAUD RATE
    TXSTA=0X20;             // TRANSMIT ENABLE
    RCSTAbits.SPEN=1;
    TXSTAbits.TXEN=1;
    //RCSTA=0X90;             // RECEIVE ENABLE
}

 

hyper terminal does not show some character send 48 ascii of 0 or asciis of 0 to 9,a to z. then check it will be working

- - - Updated - - -

hyper terminal does not show some character send 48 ascii of 0 or asciis of 0 to 9,a to z. then check it will be working if not then i think there will be ur h/w problem for h/w checking short tx, rx pins and check wheter data recieved
 

i try to send 0x30 ascii for zero but it showing some random figures 
 

then this mean ur baud rate is not according to crystal value or ur h/w problem
 

my crystal is 11.0592 according to calculation it get divided by 4 and uart ckt by 16so value comes 172800 which is divided by 9600 so it comes 18 so 18-1 =17 i put that but still not working
 

if we are using printf, getrsUSART,getcUSART() fns we can write.just try that functions..

i could transmit through pic to hyperterminal.
but i got problem in reading from keyboard.there is no echo.plz help me also
 

the best test is short the tx rx pin and then test keboard if ur echo is comming means pc recieving pin is working then write code in this way that when u get data from pc then retransmit to pc
 

the best test is short the tx rx pin and then test keboard if ur echo is comming means pc recieving pin is working then write code in this way that when u get data from pc then retransmit to pc

now hyper terminal showing data but it is not showing all data but alternate byte like i am sending AT+CMGF=1 and it is showing A+MF1 so what is problem
 

check ur mobile at commands manual

- - - Updated - - -

check ur mobile at commands manual
 

hello

before to test if the probleme is on receiving section :

When you send car , test before sending the car (not after! as in example in #1) , the TXTAbits.TRMT status

while(TXSTAbits.TRMT==0); // if full wait
TXREG=car;
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top