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.

Problems with receiving/transmitting using hypertermianl.

Status
Not open for further replies.

fzn10

New Member
HI, iv learned alot about micro controllers in the past week. Iv been stuck on a problem for two days now and just cant figure it out. Im trying to connect my computer to my PIC16F876. Iv uploaded my program(attached) using MPLAB and all hardware is setup.

When I input characters through my keyboard i can see the square wave going into my MAX232 and than into my PIC(pin 18) through my oscilliscope, however its giving me no output on the screen. I checked my TX(pin17) and there is no output either, What is happening i think is that when i call my AAsUSARTgetByte() function, its alwayse returning zero which corresponds to an error. Note that some of the functions in the code attached are not being used so pay no attention to them. Do you guys know of any thing i can try to fix this problem. Thanks
 

Attachments

  • main.c
    3.8 KB · Views: 217
This is the real file. pretty much the same, had a syntax error in the last one.
 

Attachments

  • main.c
    3.8 KB · Views: 169
I would start out by testing, in order:
- PC cable - short pins 2 and 3 on the rs232 connector. you should get echo on your terminal program.
- rs232 driver. pull the chip out of the socket and put a jumper between the tx and rx pins. you should get echo.
- then test output. try sending a single char in a loop.
- then work on getting input working.

make sure that tx and rx are connected to the correct pins on the max232.

as to your program, I'd lose floating point. also, its not clear what compiler you are using but I bet an int isn't 32 bit. what is your clock rate? should be 4 mhz for your brg settings.
 
Hi, thanks for that reply, thats a nice testing technique, the weird thing is that i did steps 1-3 and they all passed than hooked up the circuit again to see if it works and "voilla", it worked. really weird, nothing different with connections or anything. The only thing is that when i type something "de" displayes and than a new line is started, the problem is that it doesnt go back to the begining of the new line, rather it just continuse. What do you mean by loosing "floating point". Im using an 8Mhz Crystal btw.

thanks for your help.
 
glad you were able to get it working.

your default sbrg is 25 which at 8 mhz would give you 19.2K. your comment says 9.6K

in the changebaud routine, the argument is a float. since you don't call that routine, maybe the compiler is smart enough to not generate code for it but floating point is pretty huge on a PIC. I'd rewrite it and use define constants instead of the actual baud rate. that way you can use an unsigned char which is the natural "word" size of the PIC.

you have to output a carriage return and a line feed. uncomment the last line in main(). or make your "putchar" routine send a newline when it sees a linefeed.
 
In addition to what Philba said about float's, it really isn't a good idea to compare floats and int's using the == operator, it often leads to unexpected results.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top