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.

Hardware for RS232 with PIC

Status
Not open for further replies.

vilfred

Member level 1
Joined
Mar 21, 2018
Messages
37
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
368
Hi.. The hardware such as PIC16F877A, MAX232, USB to UART cable(i.e. one end compatible with usb port in PC, and other end is DB9 connector), 8MHz crystal oscillator, 33Pf (2 no.), 10uF(4 no.), are used in my UART project. I'm connecting these in bread board. I used pickit3 to program my IC.
1). PIC16F877A
- 13th and 14th are connected by oscillator and osc is grounded by two 33pF capacitors.
- 11th pin is connected to supply(+5V), 12th pin is grounded.
- RC6(TX) pin is connected to MAX232 10th pin(Tx), likewise RC7(RX) pin is connected to MAX232 9th pin(Rx).
2).MAX232
- 16th pin is connected to supply(+5V), and 15th pin is grounded.
- 10uF is connected across 16th pin and 2nd pin.
- 1st and 3rd pins are connected by 10uF similarly 4th and 5th pins, and 6th pin is grounded.
- DB9 connector Rx(2nd pin) is connected to 7th pin, and Tx (3rd pin) is connected to 8th pin.
- 5th pin of DB9 connector is grounded.
This is my setup and i'm trying to send a single character with LED indication, the code is attached below. My IC is programmed well using pickit3. I also checked the code in Proteus, it generated A in virtual terminal.
In real time i received nothing in terminal window, i've checked the baudrate, parity, stop bits, etc... also i downloaded several codes like this and dump the hex code and checked, but i didn't get any output. Software - MPLAB X IDE.
Please give me a solution i'm doing this project for a long time. Whether my hardware setup is correct?
 

Attachments

  • New Text Document.txt
    1.1 KB · Views: 56

Hi,

A schematic is by far more informative than a textual description.

Usually
Rx <-- Tx and
Tx --> Rx:
Be sure your connection is correct. Please check that the output of one device goes to the input of the other device. (Read datasheets)

Klaus
 

hello


MAX232 ... and 6th pin is grounded.

No, you must insert a capacitor capacitor - on pin 6 and capacitor + to ground
more details [B]here [/B]

some MAX232 requier less value of capacitoe , like 1µF instead of 10µF

today, it is more easy to use a USB/TLL cable like Prolific or other ( with FTDI device integrated).
 

The MAX232 is outdated, being recommended the MAX233 which has fixed some issues on its predecessor, particularly when interfacing with computers having no legacy serial ports, as in the case of USB/Serial adapters. Unfortunately, both devices are not pin compatible.
 

Sorry for late reply...
By using proper capacitors and baudrate value, i got a result along with more continues reception of garbage values. I find that decoupling capacitors are mandatory to reduce errors.

I've connected 1uF across 15th and 16th pin of MAX232, and in my code i just changed my baudrate value as 51.
Thanks all...
 
Last edited:

The Watchdog feature is enabled on your code, but you don`t manage its counter anywhere.
 

Initially i thought to put WDT(watchdog timer) in OFF state, but mistakenly i made it ON, so only i haven't use counters in software. According to my knowledge watchdog timer is used to reset the MCU if any interrupt occurs, which is based on a counter that counts down from some initial value to zero. Usually, software selects the counter's initial value and periodically restarts it. Whether it will affect the output generation?
Thanks...
 

According to my knowledge watchdog timer is used to reset the MCU if any interrupt occurs, which is based on a counter that counts down from some initial value to zero. Usually, software selects the counter's initial value and periodically restarts it. Whether it will affect the output generation?
No to the above statement. When enabled, watchdog counter will count down from the value you just stored, and will reset the system when its value reaches 0; therefore you need to periodically update the value on its timer. I don`t know precisely how it works on PIC, but it is the general working process. In other words, if everithing works as expected (ie, program execution not being trapped within an endless loop), your program will prevent the system from being reset by calling watchdog updater; when running some routine which requires more time to be accomplished, you can update a larger value in watchdog counter.
 

We seem to have gone down a bit of a rabbit hole with the WDT but the simplest way to handle it is to turn it off. The WDT is there to restart your MCU if something has gone wrong that has caused it to (effectively) stop working. That is not your problem right now. It can be added back in at a later stage if required. (BTW you need to execute the CLRWDT instruction before the WDT times out; typically you put this in the main loop.)
As for the 'garbage characters' being sent, the usual cause for that is selecting the wrong BAUD rate. Use a scope and just continuously send a character such as 0x55 and measure the pulse widths.
Susan
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top