shaneelal
Member level 1
openusart
Hi,I'm using two PIC 18F452 microcontrollers in two devices that I'm building. One microcontroller has to transmit a reading to the second microcontroller. I'm using USART implementing rs-232. The first device transmits well,I checked the output using the hyperterminal of the pc.
I can't read the string that I sent to the second microcontroller. The second PIC just keeps waiting and waiting for data to be recieved.
I'm using the mcc18 compiler. Is it all possible to communicate between PICs using the USART in asynchronous mode?
these are excerpts from my code
configuration of usart of the device transmitting
code that transmits:
str is declared as
The transmitter works.
configuration of usart of the receiving device:
code to recieve(on the other PIC)
speed is declared as:
Hi,I'm using two PIC 18F452 microcontrollers in two devices that I'm building. One microcontroller has to transmit a reading to the second microcontroller. I'm using USART implementing rs-232. The first device transmits well,I checked the output using the hyperterminal of the pc.
I can't read the string that I sent to the second microcontroller. The second PIC just keeps waiting and waiting for data to be recieved.
I'm using the mcc18 compiler. Is it all possible to communicate between PICs using the USART in asynchronous mode?
these are excerpts from my code
configuration of usart of the device transmitting
Code:
OpenUSART( USART_TX_INT_OFF & USART_RX_INT_OFF &
USART_ASYNCH_MODE & USART_EIGHT_BIT &
USART_BRGH_HIGH &
USART_CONT_RX,25);
code that transmits:
Code:
speed=(distance/ReadTimer0());
ultoa(speed,str);
while(BusyXLCD());
SetDDRamAddr(0x14);
while(BusyXLCD());
putsXLCD(clear);
while(BusyXLCD());
SetDDRamAddr(0x14);
while(BusyXLCD());
putsXLCD(str);
while(BusyXLCD());
SetDDRamAddr(0x1C);
while(BusyXLCD());
putsXLCD(units);
while (BusyUSART());
putsUSART(str); //string located in data memory
while (BusyUSART());
str is declared as
Code:
char str[7];
The transmitter works.
configuration of usart of the receiving device:
Code:
OpenUSART( USART_TX_INT_OFF & USART_RX_INT_OFF &
USART_ASYNCH_MODE & USART_EIGHT_BIT &
USART_BRGH_HIGH &
USART_CONT_RX,25);
code to recieve(on the other PIC)
Code:
SetChanADC(ADC_CH0); //select voltage channel
Delay10TCYx(3);
ConvertADC();
while( BusyADC());
voltage_adc=ReadADC();
voltage = (voltage_adc * convFactor *100.0);
SetChanADC( ADC_CH1 );//select current channel
Delay10TCYx(3);
ConvertADC();
while( BusyADC());
current_adc=ReadADC();
current = (current_adc *1.2* convFactor *600.0);
while(!DataRdyUSART());
getsUSART(speed , 7);//obtain speed
while (BusyUSART());
speed is declared as:
Code:
char speed[7];