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.

Maxim RS232 serial communication problem

Status
Not open for further replies.

n33dh3lp

Newbie level 4
Joined
Jul 26, 2004
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
82
maxim rs232

Hihi, i need some help here...i need to programm the RS232 chip to communicate with my PIC18f452(so i can transfer data from pic to PC or vice versa thru the serial port) in C language and im using C18 compiler...but im new to C language, i cant figure out how to write the codes..i seriously need some guidance..pls help it would be better if send me some sample codes for me to learn :) ...i need help ASAP...thankx alot in advance...
 

pic18 oerr c18

Hi,
Which is the chip you want to program. Normally we use max232 just for interfacing. There is no need to prgramthe chip as it just acts as level translator.
If you need UART code then there are plenty of them available on the net or in the Circuit Cellar / EPE Magazines.

B R M
 

getch cren oerr

hey thanks for the reply.. i'm trying to programme microchip pic18f452 so that i can communication it with the serial port.. and can you give me some links where i can find samples of the programme? thanks
 

rs232 cren=1

Example:
Code:
#include <pic18.h>
#include <stdio.h>
#include <string.h>
#include "usart.h"


/*==================================================================================================*/
void uart_init(void)
{
 TRISC7 = 1;
 TRISC6 = 0;
 CREN  = 0;
 TXSTA = 0x24;
 SPBRG = 0x2a;
 TXSTA = 0x24;
 RCSTA = 0x90;
 return;
} 
/*==================================================================================================*/
void putch(char c)
{while(!TXIF)	/* set when register is empty */
	continue;
 TXREG = c;
 return;
}
/*==================================================================================================*/
char getch(void)
{char rx_byte;
 while(1)
 	{while(!RCIF)	/* set when register is not empty */
		continue;
 	if (OERR ||FERR )
		{
 	 	CREN = 0;
	 	CREN = 1;
 	 	FERR=0;
//	 	TXREG= 0xaa;
	 	while (RCIF) rx_byte= RCREG;
	 	continue;
		}
	 break;
	}
 ok=1;
 return RCREG;	/* RXD9 and FERR are gone now */
}
/*==================================================================================================*/
char getche(void)
{char c;
 putch(c = getch());
 return c;
}
 

you can better use max233 because it is easy than max232
it like max232 but without any capacitor connection needed
 

wow max233 doesnt need any capacitor?!
 

You can use DS275 it small circuit
 

to goshka:


hi, i have some question to ask you regarding the code you posted. Firstly is the code meant for C18 compiler? Because the library of C18 compiler seems to have different coding from yours (example: getcUSART, DaTaRdyUSART, putrsUSART, WriteUSART.. etc.. ) So can i use exactly the same code as yours or must i change to the predefined marcos given by the C18 compiler? And also, i dont quite understand what's the "ok=1;"(at the receive part) and the whole of getche(void) part. What does these 2 parts mean?? Lastly, when i try to build your code, there is error prompting undefined symbols..how do you define all ur symbol?(example: TRISC , TXIF , RCSTA ,CREN ..etc)..sorry to ask so many questions im a newbie to C :)

If i use your code and i wanna transmit and receive some data and i write this manner will the code works?

***transmit***

void main() {
uart_init();
char buffer[10];
chat test=20;
while(1) {
putch(test); <---- will it transmit 20?
}
}

***receive***

char Data;
while(1) {
Data=getch(); <---- will receive data from usart and store at Data ?
}


Please reply me asap and thanks for the help in advance
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top