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.

how to connect two pic with usart by using mickroC compiler

Status
Not open for further replies.

saeed.n1

Newbie level 3
Joined
Jul 15, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,311
hello everyone am new to this forum and also new to microcontrollers
am using microchip controllers pic16F628A and mickroC compiler

i want to know how to connect two pic with usart port ??
and also how to connect one of the pic's to pc??

so kindly if anyone can help me or guide me i will be thankful
 

Re: how to connect tow pic with usart by using mickroC compiler



---------- Post added at 16:46 ---------- Previous post was at 16:45 ----------

I believe there is already a function in mikroC to help you to do it
 

Re: how to connect tow pic with usart by using mickroC compiler

If connect UART between PIC to PIC, just use TTL level, no need to convert to RS232.
TX first PIC connect to RX second PIC.
RX first PIC connect to TX second PIC.
Then, you learn how to code UART transmit and receive.
 

Examples of PIC to PC connectivity using Asynchronous full duplex mode (RS-232):

UART Library (mC PRO for PIC) - Reference example at end of page

USART/RS232 Communication between PC (VB 6.0) and PIC Microcontroller (MikroC 8.2) - Example with custom frontend written in VB6


For connectivity between to PICs using the USART you have several choices, Asynchronous (like above examples) or Synchronous (I2C or SPI).

thank you for you help
i had seen the example and tried to do like it but with no luck
what is killing me is how can i transmit and receive my program (the code that i have written) by using this usart

---------- Post added at 11:57 ---------- Previous post was at 11:53 ----------

If connect UART between PIC to PIC, just use TTL level, no need to convert to RS232.
TX first PIC connect to RX second PIC.
RX first PIC connect to TX second PIC.
Then, you learn how to code UART transmit and receive.

i know how to connect it but i don't know how to code it and how to use mikroc usart library
i want to see an example or project that use usart

thank you for you help
 

Please look at bigdogguru's link.

char uart_rd;

void main() {

UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize

UART1_Write_Text("Start");
while (1) { // Endless loop
if (UART1_Data_Ready()) { // If data is received,
uart_rd = UART1_Read(); // read the received data,
UART1_Write(uart_rd); // and send data via UART
}
}
}

?

If you have any problem with your code please post it
 

thank you for you help
i had seen the example and tried to do like it but with no luck
what is killing me is how can i transmit and receive my program (the code that i have written) by using this usart

Post or upload your program, so that one of us can take a look at it. A schematic of the circuit you are coding for would also be helpful.

Are you using a development board or circuit you've constructed?
 

bigdogguru , john blue i really appreciate your help and i really did fine your links very helpful

what am trying to build is a remote control circuit for my robot with two pic (transmitter & receiver) , so i used a RF circuit (for transmitting & receiving) wirelessly
and this RF circuit transmit & receive data via serial port USART

my code is so simple all what i want to know how can I use mikroC compiler library to send my code via usart port and the second pic will understand this data

i will write simple code which control the direction of my robot, and i want from you so kindly to add to it a USART library

//USART direction control


void main() {

trisa=15; //make porta as input a1...a3
trisb=0; //make portb as output

while(1){

if (porta.f0==1)portb.f0=1; //move forward
if (porta.f1==1)portb.f1=1; //move backwoard
if (porta.f2==1)portb.f2=1; //move left
if (porta.f3==1)portb.f3=1; //move right
}
}

the question again is how can i use USART
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top