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.

Help Needed: P18F452 and Serial Port

Status
Not open for further replies.

medorpg

Newbie level 5
Newbie level 5
Joined
Nov 4, 2009
Messages
9
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,338
Hi,
I Really need your help in connecting my PIC18F452 to PC

I don't know where to start
if there's any book or a tutorial which is suitable to my PIC it would be great

I have the Max232 chip and the needed hardware



What I mainly need is
sending strings from the PIC to the PC Terminal

and sending chars from PC Terminal to PIC

it's a project in my college PLEASE HELP
 

vijay s

Full Member level 3
Full Member level 3
Joined
Jun 14, 2008
Messages
159
Helped
27
Reputation
54
Reaction score
9
Trophy points
1,298
Location
Coimbatore, India
Activity points
2,152
oops... you forget to inform what compiler you are using??
Any how i have given the code For Hi-Tech compiler

use below function to send a character from PIC to PC
Code:
void putcUART(unsigned char Chr)
{
	while(!TXSTAbits.TRMT);
	TXREG = Chr;
	while(!TXSTAbits.TRMT);
}

use below function to send string from PIC to PC
Code:
void putrsUART(const unsigned char *str)
{
	while(*str)
	{
		while(!TXSTAbits.TRMT);
		putchUART(*str++);
	}
}

Reply what compiler u are using and what exactly u need

__
Click Helped Button if it helps you
 

    medorpg

    Points: 2
    Helpful Answer Positive Rating

medorpg

Newbie level 5
Newbie level 5
Joined
Nov 4, 2009
Messages
9
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,338
Sorry,
I'm using MikroC
and for simulation I use Proteus ISIS

I am using C for programming, What language you used here ?
 

vijay s

Full Member level 3
Full Member level 3
Joined
Jun 14, 2008
Messages
159
Helped
27
Reputation
54
Reaction score
9
Trophy points
1,298
Location
Coimbatore, India
Activity points
2,152
The program i wrote above is for Hi-Tech Compiler in C Language....

if you are using MikroC, ur work is very simple....
MikroC comes with rich library.. goto Help file and search for UART Functions.. it will show you the library functions to send string from PIC to PC...

and there will be an function to accept character from PC in PIC... use that function in interrupt ISR ,so every time you get a character from PC, u can read that....

use MikroC Help file and Search this Forum for existing discussion
 

medorpg

Newbie level 5
Newbie level 5
Joined
Nov 4, 2009
Messages
9
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,338
I used the Usart_Init(9600); command

then Usart_Write(CC);

CC is a char variable

but nothing works

please help
 

vijay s

Full Member level 3
Full Member level 3
Joined
Jun 14, 2008
Messages
159
Helped
27
Reputation
54
Reaction score
9
Trophy points
1,298
Location
Coimbatore, India
Activity points
2,152
I'm not familiar with MikroC library files....
check ur Hardware.... check the voltage level in MAX232 chip as specified in Datasheet....

Config receiver pin of RX as input and TX pin as Output.. read Help file about using UART..
 

sumiii

Junior Member level 3
Junior Member level 3
Joined
Apr 4, 2011
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,490
I want to convert hex(result generated from A/D) to ASCII in order to transmit serially data.
Plz help me
 

hussain_kiet

Full Member level 5
Full Member level 5
Joined
Mar 15, 2007
Messages
260
Helped
45
Reputation
90
Reaction score
28
Trophy points
1,308
Location
Karachi, Pakistan
Activity points
2,802
I want to convert hex(result generated from A/D) to ASCII in order to transmit serially data.
Plz help me

do you want to transmit ascii equivalent of hex value or ascii equivalent of decimal value...
eg ADC read 0xFF which is 255 in decimal now what you want to transmit
"FF" ASCII format
or
"255" ASCII format
..???
 

sumiii

Junior Member level 3
Junior Member level 3
Joined
Apr 4, 2011
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,490
Many ADC chips provide data in binary (hex). To display the data on an LCD or PC screen we need to convert it to ASCII.

I am using C-language and hi-tech compiler and PIC18FXX series ...

I hope you understand my problem.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top