Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

how to handle correct data during transmission in pic16f877

Status
Not open for further replies.
hello everyone i transmited data using the tx module of pic16f877 and i use hyper terminal inorder to get values, but ive obtain series of garbage characters supposed to be i should get a letter A which is 0x41h , could someone tell me what is the cause of the garbage generation?
 
hello everyone i transmited data using the tx module of pic16f877 and i use hyper terminal inorder to get values, but ive obtain series of garbage characters supposed to be i should get a letter A which is 0x41h , could someone tell me what is the cause of the garbage generation?

You've done something wrong.

Were you using a MAX232 (or similar) to invert the data?.

But basically you've told us nothing, either your hardware is faulty or your software is faulty.
 
The cause of the garbage generation is a mistake in your code. I can't see your code and so I can't try to guess at the cause of the problem.

Edit, or as Nigel pointed out a mistake in your hardware.:)

Mike.
 
Last edited:
The cause of the garbage generation is a mistake in your code. I can't see your code and so I can't try to guess at the cause of the problem.

Mike.

#include<pic.h>


void Usart_Init();


void main (void)
{
__CONFIG(3FF9H);
TRISA = 0xFF; //PORTA as input
TRISC = 0xC0;
PORTA = 0x00;
Usart_Init();
PEIE = 1;
GIE = 1;

while(1)
TXEN = 1;

}


void Usart_Init()
{
TXSTA = 0x24;
RCSTA = 0x90;
SPBRG = 25;
RCIE = 1;
TXIE = 1;
}

interrupt isr()
{
if (TXIF = 1)
{
TXREG = 0x41;
if (TRMT = 1)
TXEN = 0;
}
}
 
hello

You've done something wrong.

Were you using a MAX232 (or similar) to invert the data?.

But basically you've told us nothing, either your hardware is faulty or your software is faulty.

uhm sorry for not being detailed, actually im using a 74LS04(HEX inverter) to invert the data,i didnt use max232 cause its unavailable in our local electronic stores.
 
hello

No idea about C, but you haven't answered the question about the MAX232, nor (relating to the code) have you mentioned your clock speed.

uhm ive used 4Mhz Crystal to oscillate my circuit and also i set my SPBRG equal to 25 to get the 9600 baud rate in that way it can match with the hyper terminal baud rate option which is 9600. is it right?
 
I would suggest you get rid of the interrupt and just try and get a simple polled version working first. I don't know which compiler you are using but I would guess at this,
Code:
#include<pic.h>

    __CONFIG(3FF9H);    //<<<--- this looks wrong as well - LVP enabled

void Usart_Init();

void main (void)
{
    TRISA = 0xFF; //PORTA as input
    TRISC = 0xC0;
    PORTA = 0x00;
    Usart_Init(); 
    PEIE = 1;
    GIE = 1;
    
    while(1)
        TXREG=0x41;	//send "A"
        while(!TXIF);	//wait until sent
    }
    
    
void Usart_Init()
{
    TXSTA = 0x24;
    RCSTA = 0x90;
    SPBRG = 25;
}

Mike.
 
hi

i have send attachments so that you can see my connection my tx pin from pic 16f877 is connected to the input of the 74LS04 and the output is then send to the Rx pin of the serial cable/port of the pc.im sorry i cant explain clearly cause my english is poor.
 

Attachments

  • circuit.JPG
    circuit.JPG
    8.3 KB · Views: 141
tnx pommie

what do you mean LV?? in the configuration word 3FF9? I dont understand some say its just for code protection and for setting the watchdog timer and the timer module.
 
what do you mean LV?? in the configuration word 3FF9? I dont understand some say its just for code protection and for setting the watchdog timer and the timer module.

hi,
A 74 invertor will not get the job done.

EDIT:

Do it this way for PIC to PC
 

Attachments

  • esp01 Sep. 24.gif
    esp01 Sep. 24.gif
    3.5 KB · Views: 178
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top