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] Pic16f628-rs232 signal failure

Status
Not open for further replies.

KiuFelix

Newbie level 5
Joined
Apr 24, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,347
With reference to the PIC16F628 example from https://www.oz1bxm.dk/PIC/628uart.htm, I have managed to setup the circuit has indicated in the circuit diagram. I am familiar with CCS C programming and hence I used the C code to generate the hex file.

The problem is that I don't get the signal correctly. What I get instead of "PIC16F628 alive" output in a loop, I get only part of the expected text eg PIC16 mixed with unreadable characters like:
Code:
 PIC16F@~~"£~"~"
The connection appears to be good acording to the site.
Kindly someone help. Let me know the point I am missing.
Thanks


Code:
[CODE]//************************************************************ 
// Function:  Test the UART at 9600 baud 
// Processor: PIC16F628 at 4 MHz using internal RC oscillator 
// Hardware:  Testboard K4 
// Software:  CCS PCM 
// Author:    Lars Petersen, oz1bxm@pobox.com 
// Website:   www.qsl.net/oz1bxm/PIC/pic.htm 
//************************************************************

#include <16F628.h> 
#fuses INTRC_IO, NOLVP, NOWDT, PUT, BROWNOUT 
#use delay(clock=4000000) 
#use rs232(baud=9600, xmit=pin_B2, rcv=pin_B1)

main() {

   printf("PIC16F628 alive\n\r"); // send alive message

   while(true) { 
      putc(getc());               // echo the received characters 
   } 
}
 

Replace 1 uf capacitor with the 10uf capacitor and make the max232 circuit according to its datasheet..

instead of printf("PIC16F628 alive\n\r");

try sending the some strings only..

like
printf("PIC16F");

if the problem still persist, then replace the max232...

and if the problem still persist...
replace the oscillator...

---------- Post added at 21:49 ---------- Previous post was at 21:47 ----------

Replace 1 uf capacitor with the 10uf capacitor and make the max232 circuit according to its datasheet..

instead of printf("PIC16F628 alive\n\r");

try sending the some strings only..

like
printf("PIC16F");

if the problem still persist, then replace the max232...

and if the problem still persist...
replace the oscillator...
 

I tried using the 10uf in place of 1 uf. Still got the same problem. Edit my code to produce PIC16F only and no change. What is the purpose of the 100n capacitor from the vcc to ground. I am using 1uf instead. Got the idea from some circuit. What is it supposed to do? Tried adding some clock too. i.e using two 22 capacitor and a 4 hz crystal. But in UART is it really important?
 

Capacitor between supply and gnd is used to stable the supply variations..

If u are using 4 Mhz Cystal, What value i are putting in SPBRG Register, if it is 5 or 6 (I am calculating it for PIC16F877A)

Hope it may be same for ur controller

Baud Rate Calculator.PNG

5.5 is the exact value to be loaded, but ur compiler might be loading 5 or 6 (my assumption only) and that giving some percent of error.

So my advice is to set High Baud Rate Bit
Baud Rate Calculator.PNG

Don't know how to do so in your compiler..

Try to use the baud rate which, is having much less error or zero error..

I don;t know what to say after this..
 
Last edited:

Thanks you all. I finally go it work. There was some power fluctuation maybe because of the connections. This guide is helped me alot https://www.oz1bxm.dk/PIC/16F628-UART-test.htm. arunsharma0731 thanks for your suggestion on the calculator. It is something I find useful in future programing.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top