RS232+PIC16F690+MAX237 garbage data

Thread Starter

ArakelTheDragon

Joined Nov 18, 2016
1,353
Good day! I have made a schematic to send serial data with RS232 and PIC16F690. But I get garbage data on the Terminal, can anyone tell me why, I couldnt figure it out and I searched for it. On the terminal V2 I get garbage data, on V1 I get nothing and when I try to simulate sending data with the terminal, it does not work at all, I can not input anything.

Compiler: CCS PIC C
Debugger: Proteus 8.5
Processor: PIC16F690
Transmit Pin is RC6
Receive PIN is RC7
Converter IC: MAX237, MAX232

In the uploaded files I have given the schematic, virtual terminal settings and here I give the source code:

https://www.dropbox.com/s/kk6wq8i52jnt3p9/Proteus-RS232-PIC16F690-MAX237.txt?dl=0

Proteus-RS232-PIC16F690-MAX237.jpg
Proteus-RS232-PIC16F690-MAX237.png

moderators note: shown images full size
 
Last edited by a moderator:

ErnieM

Joined Apr 24, 2011
8,158
I don't use Proteus so I can't help with that other than to guess try using it without the MAX chips and probe the PIC signals directly.

As far as your circuit, you have the two R1 outputs of U2 and U4 tied together. That is not a good thing.
 

Thread Starter

ArakelTheDragon

Joined Nov 18, 2016
1,353
I did it only to test will the second IC MAX237 work, to see if the problem is in the converter. Otherwise with 1 circuit I get the same result.
 

Picbuster

Joined Dec 2, 2013
1,027
Good day! I have made a schematic to send serial data with RS232 and PIC16F690. But I get garbage data on the Terminal, can anyone tell me why, I couldnt figure it out and I searched for it. On the terminal V2 I get garbage data, on V1 I get nothing and when I try to simulate sending data with the terminal, it does not work at all, I can not input anything.

Compiler: CCS PIC C
Debugger: Proteus 8.5
Processor: PIC16F690
Transmit Pin is RC6
Receive PIN is RC7
Converter IC: MAX237, MAX232

In the uploaded files I have given the schematic, virtual terminal settings and here I give the source code:

https://www.dropbox.com/s/kk6wq8i52jnt3p9/Proteus-RS232-PIC16F690-MAX237.txt?dl=0
I don't know the compiler used however you should take oscillator in account look at the baud rate table in the pic16f 690 manual.
Did you try different baud rates at the terminal?
I never had any problems with the 690 running at 8MHz internal speed and a baud rate 19k2 9600 4800 38400.
But not all baud rates are possible at a given speed the above mentioned table will explain.
Picbuster
 

bertus

Joined Apr 5, 2008
21,371
Hello,

Do I see a clock of 4M at the delay command?

Code:
#include <16F690.h>
/****CONFIGURATION******/
#fuses NOMCLR, NOWDT, NOPROTECT, NOBROWNOUT, INTRC_IO /* Ext. reset, no watchdog, no code protect, no brownout reset, ext.
oscilator */

/****RS232 CONFIGURATION****/
#use delay(clock=4M) /* We specify the clock frequency to use the "delay_()" function */
#use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8, errors) /* RS232 parameters, baud rate = 9600, no parity bit, transmit pin = RC6, receive pin = RC7, 8 bits per transmitted data, hardware UART won't lockup,freeze when more than 2 characters come from the PC */



void main(void)
{
unsigned int8 read_byte; /* The byte read from the EEPROM (24AA128) */

/*****Initialization********/

/******Analog inputs block******/
/* By default, on power-on, reset, these pins are enabled, if we want to use them as digital, we
need to disable them in the initialization section to spare memory and time in initializing them in
the "while(1)" cycle */
setup_comparator (NC_NC_NC_NC); /* Disable analog comparators, pins are available as digital */
setup_vref (FALSE); /* Disable the programmable voltage reference, pin is available as digital */
setup_adc (NO_ANALOGS); /* Disable the ADC module, AN pins are available as digital */

output_c(0);

/******Main loop********/
while (1)
{
/* To transmit data */
int value = 1;
putc ('A'); /* Transmit a character via RS232 */
putc ('B');
puts ("Test-string"); /* Transmit a string via RS232 */
printf ("Transmit a value: %d", value); /* Send formatted string via RS232 */
printf ("Text/n");

/* To receive data */
//char ch;
//char string[32];
//ch = getc (); /* Receive a single character via RS232 */
//gets (string); /* Receive a string via RS232, reads characters into the string, until
/*"RETURN" character (13) is encountered */
}
}
I copied the code so everybody else can see it directly.

Bertus
 

Thread Starter

ArakelTheDragon

Joined Nov 18, 2016
1,353
I will try with the different values, in the old days older converters needed 10mF, I tried with 100nF also, but it didnt work.

If I connect the Terminal directly to the pins will that have any effect, since the RS232 voltages are +-12V, while the PIC gives +5/0V?
 

Thread Starter

ArakelTheDragon

Joined Nov 18, 2016
1,353
You were right, the data was inverted, when I set the terminal to inverted data it worked!

Thanks to everyone for the help! My Next project will be I2C, where I already have a few questions, but I will start a new topic.
 

bertus

Joined Apr 5, 2008
21,371
Hello,

The RS232 standard uses signals between ±3 and ±15 Volts:
https://en.wikipedia.org/wiki/RS-232

The MAX chips convert the +5 Volts to ±10 Volts, wich is in range of the RS232 standard.
At the MAX232 you can measure the +10 Volts at pin 2 and the -10 Volts at pin 6.
At the MAX237 you can measure the +10 Volts at pin 11 and the -10 Volts at pin 15.

If the voltage are not correct, then the charge pumps are not working.

Bertus
 
Top